Skip to content

Commit

Permalink
Add programmatic API to docs
Browse files Browse the repository at this point in the history
  • Loading branch information
zachleat committed Nov 15, 2024
1 parent 61908a1 commit 3a55f1b
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -101,3 +101,30 @@ npx @11ty/import fediverse [email protected]
# Import recent Bluesky posts (via RSS)
npx @11ty/import bluesky @11ty.dev
```

### Programmatic API

```js
import { Importer } from "@11ty/import";

let importer = new Importer();

importer.setOutputFolder("."); // --output
importer.setCacheDuration("24h"); // --cacheduration
importer.setVerbose(true); // --quiet
importer.setSafeMode(false); // --overwrite
importer.setDryRun(false); // --dryrun
importer.setDraftsFolder("drafts");
importer.setAssetsFolder("assets");

// Sources (one or more)
importer.addSource("bluesky", "@11ty.dev");

let entries = await importer.getEntries({
contentType: "markdown", // --format
});

await importer.toFiles(entries);

importer.logResults();
```

0 comments on commit 3a55f1b

Please sign in to comment.