@digicrafters/slidev-export-cli
v1.0.1
Published
CLI tool to export Slidev presentations based on a JSON configuration file.
Maintainers
Readme
slidev-export-cli
README-fr.md only on repository
An open-source CLI tool designed to automate and simplify PDF exports from Slidev presentations. It generates multiple exports from a single Slidev source using a JSON configuration file.
This tool is particularly well-suited for long teaching materials (courses, modules, chapters), where each export represents a targeted version of the same document. You can easily produce one PDF per chapter, per module, or per variant, while maintaining one single Slidev source file.
Key Features
- Automatic token replacement in
.mdfiles (e.g.,$chapter-title$,$output-file-name$,$file-name$, etc.) - Multiple configurable exports defined in a JSON file
- Native integration with
slidev export→ full support for custom options (--wait,--with-toc, etc.) - Automatic handling of temporary files
- Selective export using indexes (
0 3 4) - Compatible with Windows, macOS, and Linux
- Usable via
npx, as a local dependency, or globally - Ideal for generating one PDF per chapter from long-form Slidev content
Installation
Option 1 — As a devDependency (recommended)
npm install --save-dev @digicrafters/slidev-export-cliOption 2 — Via npx (no installation)
npx @digicrafters/slidev-export-cli path/to/config.jsonOption 3 — Global installation
npm install -g @digicrafters/slidev-export-cliUsage
From the root of your Slidev project:
cd my-slidev-project
slidev-export-cli path/to/config.jsonExamples
Full export
slidev-export-cli config/chapters.jsonSelective export (indexes 0, 2, and 4)
slidev-export-cli config/chapters.json 0 2 4example/ Directory
The project includes a ready-to-use example:
example/
├── configuration-file.json → configuration with multiple exports
└── slidev-chapter.md → Slidev file using token placeholdersTry it immediately:
cd example
slidev-export-cli configuration-file.jsonSeveral PDFs will be generated inside export/, each one corresponding to a different parameter set.
Configuration Example
{
"targetPath": "slidev-chapter.md",
"tempPath": "temp-chapter.md",
"deleteTempFile": false,
"exportOptions": ["--with-toc"],
"exports": [
{
"replacementValues": [
{ "name": "output-file-name", "value": "generated-file-01" },
{ "name": "file-name", "value": "chapter-01" },
{ "name": "some-name", "value": "value for first export" },
{ "name": "another-name","value": "another first export value" }
]
},
{
"replacementValues": [
{ "name": "output-file-name", "value": "generated-file-02" },
{ "name": "file-name", "value": "chapter-02" },
{ "name": "some-name", "value": "value for second export" },
{ "name": "another-name","value": "another second export value" }
]
}
]
}Tokens in Markdown Files
General format:
$token-name$Examples:
$output-file-name$$file-name$$some-name$$another-name$
Excerpt from the provided Slidev example:
exportFilename: ../export/$output-file-name$.pdfAutomatic Validation
Before exporting, the tool validates:
- the existence of the JSON configuration file,
- the validity of the configured paths,
- the existence of the target Markdown file,
- the validity of provided export indexes,
- that the indexes do not exceed the number of configured export entries.
If an error occurs, an explicit message is displayed and the export stops.
Recommended npm Scripts
Inside your Slidev project (package.json):
{
"scripts": {
"export:slides": "slidev-export-cli config/configuration-file.json"
}
}Run it with:
npm run export:slidesProject Philosophy
slidev-export-cli aims to remain simple, reliable, and easy to extend.
Its goals include:
- streamlining the export of educational or documentation material,
- automating the generation of segmented PDFs,
- integrating smoothly into automated publication or CI workflows.
Contributions are welcome: bug fixes, feature ideas, improvements—anything that helps the Slidev community.
npm Publishing (for maintainers)
The package is automatically built before publishing:
npm run build
npm publishFor scoped packages:
npm publish --access publicLicense
MIT © DigiCrafters
Contributing
- Fork the repository
- Create a feature branch
- Open a pull request
- Report a bug or propose an enhancement
All contributions are welcome.
Contact
For questions or suggestions, open an issue on: https://framagit.org/digicrafters/slidev-export-cli
