Skip to content

Commit be04853

Browse files
authored
feat: add --without-notes option for build (#2387)
1 parent fa85375 commit be04853

File tree

6 files changed

+30
-7
lines changed

6 files changed

+30
-7
lines changed

docs/builtin/cli.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ Options:
5959
- `--base` (`string`, default: `/`): base URL (see https://vitejs.dev/config/shared-options.html#base)
6060
- `--download` (`boolean`, default: `false`): allow the download of the slides as a PDF inside the SPA
6161
- `--theme`, `-t` (`string`): override theme
62+
- `--without-notes` (`boolean`, default: `false`): exclude speaker notes from the SPA
6263

6364
## `slidev export [...entry]` {#export}
6465

docs/guide/hosting.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,14 @@ You can change the output directory using `--out`.
3434
$ slidev build --out my-build-folder
3535
```
3636

37+
### Remove speaker notes {#without-notes}
38+
39+
If you are sharing the built slides publicly and don't want to include your speaker notes, run the build with `--without-notes`:
40+
41+
```bash
42+
$ slidev build --without-notes
43+
```
44+
3745
### Multiple Builds {#multiple-builds}
3846

3947
You can build multiple slide decks in one go by passing multiple markdown files as arguments:

packages/slidev/node/cli.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -347,6 +347,10 @@ cli.command(
347347
type: 'boolean',
348348
describe: 'allow download as PDF',
349349
})
350+
.option('without-notes', {
351+
type: 'boolean',
352+
describe: 'exclude speaker notes from the built output',
353+
})
350354
.option('inspect', {
351355
default: false,
352356
type: 'boolean',
@@ -355,11 +359,11 @@ cli.command(
355359
.strict()
356360
.help(),
357361
async (args) => {
358-
const { entry, theme, base, download, out, inspect } = args
362+
const { entry, theme, base, download, out, inspect, 'without-notes': withoutNotes } = args
359363
const { build } = await import('./commands/build')
360364

361365
for (const entryFile of entry as unknown as string[]) {
362-
const options = await resolveOptions({ entry: entryFile, theme, inspect, download, base }, 'build')
366+
const options = await resolveOptions({ entry: entryFile, theme, inspect, download, base, withoutNotes }, 'build')
363367

364368
printInfo(options)
365369
await build(

packages/slidev/node/vite/loaders.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ export function createSlidesLoader(
2222
options: ResolvedSlidevOptions,
2323
serverOptions: SlidevServerOptions,
2424
): Plugin {
25-
const { data, mode, utils } = options
25+
const { data, mode, utils, withoutNotes } = options
2626

2727
const notesMd = MarkdownIt({ html: true })
2828
notesMd.use(markdownItLink)
@@ -363,6 +363,9 @@ export function createSlidesLoader(
363363
}
364364

365365
function renderNote(text: string = '') {
366+
if (withoutNotes)
367+
return ''
368+
366369
let clickCount = 0
367370
const notesAutoRuby: Record<string, string | undefined> = (data.headmatter as any).notesAutoRuby || {}
368371

@@ -399,6 +402,7 @@ export function createSlidesLoader(
399402
function withRenderedNote(data: SlideInfo): SlideInfo {
400403
return {
401404
...data,
405+
...withoutNotes && { note: '' },
402406
noteHTML: renderNote(data?.note),
403407
}
404408
}

packages/types/src/cli.ts

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,9 @@ export interface ExportArgs extends CommonArgs {
2020
}
2121

2222
export interface BuildArgs extends ExportArgs {
23-
out: string
24-
base?: string
25-
download?: boolean
26-
inspect: boolean
23+
'out': string
24+
'base'?: string
25+
'download'?: boolean
26+
'inspect': boolean
27+
'without-notes'?: boolean
2728
}

packages/types/src/options.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,11 @@ export interface SlidevEntryOptions {
4141
* Base URL in dev or build mode
4242
*/
4343
base?: string
44+
45+
/**
46+
* Exclude speaker notes from the built output
47+
*/
48+
withoutNotes?: boolean
4449
}
4550

4651
export interface ResolvedSlidevOptions extends RootsInfo, SlidevEntryOptions {

0 commit comments

Comments
 (0)