返回 slidev
frontmatter.ts
根目录 / packages / types / src / frontmatter.ts
1 import type { BuiltinLayouts } from './builtin-layouts'
2 import type { SlidevThemeConfig } from './types'
3
4 export interface Headmatter extends HeadmatterConfig, Omit<Frontmatter, 'title' | 'transition'> {
5 /**
6 * Default frontmatter options applied to all slides
7 */
8 defaults?: Frontmatter
9 }
10
11 export interface HeadmatterConfig extends TransitionOptions {
12 /**
13 * Title of the slides
14 */
15 title?: string
16 /**
17 * String template to compose title
18 *
19 * @example "%s - Slidev" - to suffix " - Slidev" to all pages
20 * @default '%s - Slidev'
21 */
22 titleTemplate?: string
23 /**
24 * Theme to use for the slides
25 *
26 * See https://sli.dev/guide/theme-addon#use-theme
27 * @default 'default'
28 */
29 theme?: string
30 /**
31 * List of Slidev addons
32 *
33 * @default []
34 */
35 addons?: string[]
36 /**
37 * Download remote assets in local using vite-plugin-remote-assets
38 *
39 * @default false
40 */
41 remoteAssets?: boolean | 'dev' | 'build'
42 /**
43 * Show a download button in the SPA build,
44 * could also be a link to custom pdf
45 *
46 * @default false
47 */
48 download?: boolean | string
49 /**
50 * Show a copy button in code blocks
51 *
52 * @default true
53 */
54 codeCopy?: boolean
55 /**
56 * Show copy button in magic move code blocks
57 *
58 * `'final'` for only show copy button on the final step
59 * `'always'` or `true` for show copy button on all steps
60 *
61 * @default true
62 */
63 magicMoveCopy?: boolean | 'final' | 'always'
64 /**
65 * The author of the slides
66 */
67 author?: string
68 /**
69 * Information shows on the built SPA
70 * Can be a markdown string
71 *
72 * @default false
73 */
74 info?: string | boolean
75 /**
76 * Prefer highlighter
77 *
78 * See https://sli.dev/custom/config-highlighter.html
79 * @default shiki
80 */
81 highlighter?: 'shiki'
82 /**
83 * Enable Twoslash
84 *
85 * @default true
86 */
87 twoslash?: boolean | 'dev' | 'build'
88 /**
89 * Show line numbers in code blocks
90 *
91 * @default false
92 */
93 lineNumbers?: boolean
94 /**
95 * Force slides color schema
96 *
97 * @default 'auto'
98 */
99 colorSchema?: 'dark' | 'light' | 'all' | 'auto'
100 /**
101 * Router mode for vue-router
102 *
103 * - `history`: the slide number is reflected in the URL path
104 * - `hash`: hash-based routing, for static hosts or subdirectory deploys
105 * - `memory`: routing is kept in memory, so the URL never reflects the slide number and cannot be used to navigate — useful for kiosk or externally driven "follower" decks (deep-links, `/presenter`, `/overview` and export-by-URL are unavailable)
106 *
107 * @default 'history'
108 */
109 routerMode?: 'hash' | 'history' | 'memory'
110 /**
111 * Aspect ratio for slides
112 * should be like `16/9` or `1:1`
113 *
114 * @default '16/9'
115 */
116 aspectRatio?: number | string
117 /**
118 * The actual width for slides canvas.
119 * unit in px.
120 *
121 * @default '980'
122 */
123 canvasWidth?: number
124 /**
125 * Controls whether texts in slides are selectable
126 *
127 * @default true
128 */
129 selectable?: boolean
130 /**
131 * Configure for themes, will inject intro root styles as
132 * `--slidev-theme-x` for attribute `x`
133 *
134 * This allows themes to have customization options in frontmatter
135 * Refer to themes' document for options avaliable
136 *
137 * @default {}
138 */
139 themeConfig?: SlidevThemeConfig
140 /**
141 * Configure fonts for the slides and app
142 *
143 * @default {}
144 */
145 fonts?: FontOptions
146 /**
147 * Configure the icon for app
148 *
149 * @default 'https://cdn.jsdelivr.net/gh/slidevjs/slidev/assets/favicon.png'
150 */
151 favicon?: string
152 /**
153 * Options for drawings
154 *
155 * @default {}
156 */
157 drawings?: DrawingsOptions
158 /**
159 * URL of PlantUML server used to render diagrams
160 *
161 * @default https://www.plantuml.com/plantuml
162 */
163 plantUmlServer?: string
164 /**
165 * Enable slides recording
166 *
167 * @default 'dev'
168 */
169 record?: boolean | 'dev' | 'build'
170 /**
171 * Expose the server to inbound requests (listen to `0.0.0.0`)
172 *
173 * Pass a string to set the password for accessing presenter mode.
174 *
175 * @default false
176 */
177 remote?: string | boolean
178 /**
179 * Engine for Atomic CSS
180 *
181 * See https://unocss.dev/
182 * @deprecated
183 * @default 'unocss'
184 */
185 css?: 'unocss'
186 /**
187 * Enable presenter mode
188 *
189 * @default true
190 */
191 presenter?: boolean | 'dev' | 'build'
192 /**
193 * Enable browser exporter
194 *
195 * @default 'dev'
196 */
197 browserExporter?: boolean | 'dev' | 'build'
198 /**
199 * Attributes to apply to the HTML element
200 *
201 * @default {}
202 */
203 htmlAttrs?: Record<string, string>
204 /**
205 * Suppport Comark syntax
206 *
207 * https://comark.dev/syntax/markdown
208 *
209 * @default false
210 */
211 comark?: boolean
212 /**
213 * @deprecated MDC is now Comark. Use the `comark` option instead
214 * @default false
215 */
216 mdc?: boolean
217 /**
218 * Enable built-in editor
219 *
220 * @default true
221 */
222 editor?: boolean
223 /**
224 * Enable the MCP (Model Context Protocol) server endpoint on the dev server,
225 * allowing AI agents to inspect and edit the slides
226 *
227 * @default true
228 */
229 mcp?: boolean
230 /**
231 * Enable context menu
232 *
233 * @default true
234 */
235 contextMenu?: boolean | 'dev' | 'build' | null
236 /**
237 * Enable wake lock
238 */
239 wakeLock?: boolean | 'dev' | 'build'
240 /**
241 * Enable PWA support: a service worker precaches all deck assets on first
242 * load so a served deck works fully offline afterward. Heavy; opt-in.
243 * @default false
244 */
245 pwa?: boolean | 'dev' | 'build'
246 /**
247 * Force the filename used when exporting the presentation.
248 * The extension, e.g. .pdf, gets automatically added.
249 *
250 * @default ''
251 */
252 exportFilename?: string | null
253 /**
254 * Enable Monaco
255 *
256 * See https://sli.dev/custom/config-monaco.html
257 * @default true
258 */
259 monaco?: boolean | 'dev' | 'build'
260 /**
261 * Where to load monaco types from
262 *
263 * - `cdn` - load from CDN with `@typescript/ata`
264 * - `local` - load from local node_modules
265 *
266 * @default 'local'
267 */
268 monacoTypesSource?: 'cdn' | 'local' | 'none'
269 /**
270 * Additional node packages to load as monaco types
271 *
272 * @default []
273 */
274 monacoTypesAdditionalPackages?: string[]
275 /**
276 * Packages to ignore when loading monaco types
277 *
278 * @default []
279 */
280 monacoTypesIgnorePackages?: string[]
281 /**
282 * Additional local modules to load as dependencies of monaco runnable
283 *
284 * @default []
285 */
286 monacoRunAdditionalDeps?: string[]
287 /**
288 * Whether to run monaco runnable code in strict mode
289 *
290 * @default true
291 */
292 monacoRunUseStrict?: boolean
293 /**
294 * Seo meta tags settings
295 *
296 * @default {}
297 */
298 seoMeta?: SeoMeta
299 /**
300 * Auto replace words with `<ruby>` tags in notes
301 *
302 * @default {}
303 *
304 * @example
305 * ```yaml
306 * notesAutoRuby:
307 * 大丈夫: だいじょうぶ
308 * ```
309 */
310 notesAutoRuby?: Record<string, string>
311 /**
312 * The expected duration of the slide
313 *
314 * @example
315 * ```yaml
316 * duration: 35min
317 * ```
318 *
319 * @default '30min'
320 */
321 duration?: string | number
322 /**
323 * Timer mode
324 *
325 * @default 'stopwatch'
326 */
327 timer?: 'stopwatch' | 'countdown'
328 /**
329 * Duration for shiki magic move transitions in milliseconds
330 *
331 * @default 800
332 */
333 magicMoveDuration?: number
334 /**
335 * Configure Shiki
336 *
337 * @default {}
338 */
339 shiki?: ShikiOptions
340 /**
341 * Default click animation for the slides
342 */
343 clickAnimation?: string
344 /**
345 * Preload images extracted from slides for faster navigation.
346 *
347 * - `true` - enable with default look-ahead of 3 slides
348 * - `false` - disable image preloading
349 * - `{ ahead: number }` - enable with custom look-ahead window
350 *
351 * @default true
352 */
353 preloadImages?: boolean | { ahead?: number }
354 }
355
356 export interface Frontmatter extends TransitionOptions {
357 /**
358 * Slide layout to use
359 *
360 * Default to 'cover' for the first slide, 'default' for the rest
361 */
362 layout?: BuiltinLayouts | string
363 /**
364 * Custom class added to the slide root element
365 */
366 class?: string | string[] | Record<string, unknown>
367 /**
368 * Manually specified the total clicks needed to this slide
369 *
370 * When not specified, the clicks will be calculated by the usage of v-clicks
371 *
372 * See https://sli.dev/guide/animations
373 */
374 clicks?: number
375 /**
376 * Manually specified the total clicks needed to this slide to start
377 *
378 * @default 0
379 */
380 clicksStart?: number
381 /**
382 * Preload the slide when the previous slide is active
383 * @default true
384 */
385 preload?: boolean
386 /**
387 * Completely hide and disable the slide
388 */
389 hide?: boolean
390 /**
391 * Same as `hide`, completely hide and disable the slide
392 */
393 disabled?: boolean
394 /**
395 * Hide the slide for the `<Toc>` components
396 *
397 * See https://sli.dev/builtin/components#toc
398 */
399 hideInToc?: boolean
400 /**
401 * Override the title for the `<TitleRenderer>` and `<Toc>` components
402 * Only if `title` has also been declared
403 */
404 title?: string
405 /**
406 * Override the title level for the `<TitleRenderer>` and `<Toc>` components
407 * Only if `title` has also been declared
408 */
409 level?: number
410 /**
411 * Create a route alias that can be used in the URL or with the `<Link>` component
412 */
413 routeAlias?: string
414 /**
415 * Custom zoom level for the slide
416 * @default 1
417 */
418 zoom?: number
419 /**
420 * Default click animation for the slide
421 */
422 clickAnimation?: string
423 /**
424 * Store the positions of draggable elements
425 * Normally you don't need to set this manually
426 *
427 * See https://sli.dev/features/draggable
428 */
429 dragPos?: Record<string, string>
430 /**
431 * Includes a markdown file
432 *
433 * See https://sli.dev/guide/syntax.html#importing-slides
434 */
435 src?: string
436 // /**
437 // * Set time split for the end of the slide
438 // *
439 // * Accepts:
440 // * - 10:05
441 // * - 10m5s
442 // * - +10s (relative to the previous point)
443 // */
444 // timesplit?: string
445 // /**
446 // * Set title for the time split
447 // *
448 // * Default to slide title
449 // */
450 // timesplitTitle?: string
451 }
452
453 export interface DrawingsOptions {
454 /**
455 * Persist the drawings to disk
456 * Passing string to specify the directory (default to `.slidev/drawings`)
457 *
458 * @default false
459 */
460 persist?: boolean | string
461
462 /**
463 * @default true
464 */
465 enabled?: boolean | 'dev' | 'build'
466
467 /**
468 * Only allow drawing from presenter mode
469 *
470 * @default false
471 */
472 presenterOnly?: boolean
473
474 /**
475 * Sync drawing for all instances
476 *
477 * @default true
478 */
479 syncAll?: boolean
480 }
481
482 export interface FontOptions {
483 /**
484 * Sans serif fonts (default fonts for most text)
485 */
486 sans?: string | string[]
487 /**
488 * Serif fonts
489 */
490 serif?: string | string[]
491 /**
492 * Monospace fonts, for code blocks and etc.
493 */
494 mono?: string | string[]
495 /**
496 * Load webfonts for custom CSS (does not apply anywhere by default)
497 */
498 custom?: string | string[]
499 /**
500 * Weights for fonts
501 *
502 * @default [200, 400, 600]
503 */
504 weights?: string | (string | number)[]
505 /**
506 * Import italic fonts
507 *
508 * @default false
509 */
510 italic?: boolean
511 /**
512 * @default 'google'
513 */
514 provider?: 'none' | 'google' | 'coollabs'
515 /**
516 * Specify web fonts names, will detect from `sans`, `mono`, `serif` if not provided
517 */
518 webfonts?: string[]
519 /**
520 * Specify local fonts names, be excluded from webfonts
521 */
522 local?: string[]
523 /**
524 * Use fonts fallback
525 *
526 * @default true
527 */
528 fallbacks?: boolean
529 }
530
531 export interface ShikiOptions {
532 /**
533 * Options passed to Shiki Magic Move for customizing code transition animations
534 *
535 * See https://shiki.style/packages/magic-move#options for the full list of options
536 *
537 * @default {}
538 */
539 magicMove?: ShikiMagicMoveOptions
540 }
541
542 export interface ShikiMagicMoveOptions {
543 /**
544 * Ratio of the duration to delay the move animation
545 *
546 * @default 0.3
547 */
548 delayMove?: number
549 /**
550 * Ratio of the duration to delay the leave animation
551 *
552 * @default 0
553 */
554 delayLeave?: number
555 /**
556 * Ratio of the duration to delay the enter animation
557 *
558 * @default 0.7
559 */
560 delayEnter?: number
561 /**
562 * Ratio of the duration to delay the container animation
563 *
564 * @default 0.4
565 */
566 delayContainer?: number
567 /**
568 * Easing function, in the CSS `transition-timing-function` format
569 *
570 * @default 'ease'
571 */
572 easing?: string
573 /**
574 * Apply animation to the container
575 *
576 * @default false
577 */
578 animateContainer?: boolean
579 /**
580 * Apply styles (color and background) to the container
581 *
582 * @default true
583 */
584 containerStyle?: boolean
585 /**
586 * Stagger the animation of the tokens, in milliseconds
587 *
588 * @default 1
589 */
590 stagger?: number
591 /**
592 * Split the tokens at the edge of diff chunks
593 *
594 * @default false
595 */
596 splitTokens?: boolean
597 /**
598 * Enhance the matching algorithm to match tokens that has same content
599 */
600 enhanceMatching?: boolean
601 }
602
603 export type BuiltinSlideTransition = 'fade' | 'fade-out' | 'slide-up' | 'slide-down' | 'slide-left' | 'slide-right' | 'view-transition'
604
605 export interface TransitionOptions {
606 /**
607 * Page transition, powered by Vue's `<TransitionGroup/>`
608 *
609 * Built-in transitions:
610 * - fade
611 * - fade-out
612 * - slide-left
613 * - slide-right
614 * - slide-up
615 * - slide-down
616 * - view-transition
617 *
618 * See https://sli.dev/guide/animations.html#pages-transitions
619 *
620 * See https://vuejs.org/guide/built-ins/transition.html
621 */
622 transition?: BuiltinSlideTransition | string | TransitionGroupProps | null
623 }
624
625 export interface TransitionGroupProps {
626 appear?: boolean
627 persisted?: boolean
628 tag?: string
629 moveClass?: string
630 css?: boolean
631 duration?: number | {
632 enter: number
633 leave: number
634 }
635 enterFromClass?: string
636 enterActiveClass?: string
637 enterToClass?: string
638 appearFromClass?: string
639 appearActiveClass?: string
640 appearToClass?: string
641 leaveFromClass?: string
642 leaveActiveClass?: string
643 leaveToClass?: string
644 }
645
646 /**
647 * The following type should map to unhead MataFlat type
648 */
649 export interface SeoMeta {
650 ogTitle?: string
651 ogDescription?: string
652 ogImage?: string
653 ogUrl?: string
654 twitterCard?: 'summary' | 'summary_large_image' | 'app' | 'player'
655 twitterSite?: string
656 twitterTitle?: string
657 twitterDescription?: string
658 twitterImage?: string
659 twitterUrl?: string
660 }
661
661 lines TYPESCRIPT