返回 slidev
index.md
根目录 / docs / custom / index.md
1 # Customizations
2
3 Slidev is fully customizable, from styling to tooling configurations. It allows you to configure the tools underneath ([Vite](/custom/config-vite), [UnoCSS](/custom/config-unocss), [Monaco](/custom/config-monaco), etc.)
4
5 ## Slides Deck Configs {#headmatter}
6
7 You can configure the whole slides project in the frontmatter of your **first** slide (i.e. headmatter). The following shows the default value for each option:
8
9 ```yaml
10 ---
11 # theme id, package name, or local path
12 # Learn more: https://sli.dev/guide/theme-addon.html#use-theme
13 theme: default
14 # addons, can be a list of package names or local paths
15 # Learn more: https://sli.dev/guide/theme-addon.html#use-addon
16 addons: []
17 # title of your slide, will inferred from the first header if not specified
18 title: Slidev
19 # titleTemplate for the webpage, `%s` will be replaced by the slides deck's title
20 titleTemplate: '%s - Slidev'
21 # information for your slides, can be a Markdown string
22 info: false
23 # author field for exported PDF or PPTX
24 author: Your Name Here
25 # keywords field for exported PDF, comma-delimited
26 keywords: keyword1,keyword2
27
28 # enable presenter mode, can be boolean, 'dev' or 'build'
29 presenter: true
30 # enable browser exporter, can be boolean, 'dev' or 'build'
31 browserExporter: dev
32 # enabled pdf downloading in SPA build, can also be a custom url
33 download: false
34 # filename of the export file
35 exportFilename: slidev-exported
36 # export options
37 # use export CLI options in camelCase format
38 # Learn more: https://sli.dev/guide/exporting.html
39 export:
40 format: pdf
41 timeout: 30000
42 dark: false
43 withClicks: false
44 withToc: false
45 # enable twoslash, can be boolean, 'dev' or 'build'
46 twoslash: true
47 # show line numbers in code blocks
48 lineNumbers: false
49 # enable monaco editor, can be boolean, 'dev' or 'build'
50 monaco: true
51 # Where to load monaco types from, can be 'cdn', 'local' or 'none'
52 monacoTypesSource: local
53 # explicitly specify extra local packages to import the types for
54 monacoTypesAdditionalPackages: []
55 # explicitly specify extra local modules as dependencies of monaco runnable
56 monacoRunAdditionalDeps: []
57 # download remote assets in local using vite-plugin-remote-assets, can be boolean, 'dev' or 'build'
58 remoteAssets: false
59 # controls whether texts in slides are selectable
60 selectable: true
61 # enable slide recording, can be boolean, 'dev' or 'build'
62 record: dev
63 # enable Slidev's context menu, can be boolean, 'dev' or 'build'
64 contextMenu: true
65 # enable wake lock, can be boolean, 'dev' or 'build'
66 wakeLock: true
67 # enable PWA support to precache assets for offline use, can be boolean, 'dev' or 'build'
68 # Learn more: https://sli.dev/features/pwa.html
69 pwa: false
70 # take snapshot for each slide in the overview
71 overviewSnapshots: false
72 # router mode for vue-router, can be "history", "hash", or "memory"
73 routerMode: history
74 # ignore duplicate forward navigation within this many milliseconds (0 disables it)
75 advanceDebounce: 0
76
77 # color scheme for the slides:
78 # - 'auto' follows the system preference and allows switching
79 # - 'light' or 'dark' forces that scheme and disables switching
80 # - 'light dark' or 'dark light' sets the default and allows switching
81 colorSchema: auto
82 # aspect ratio for the slides
83 aspectRatio: 16/9
84 # real width of the canvas, unit in px
85 canvasWidth: 980
86 # defines the default transition between slides
87 # Learn more: https://sli.dev/guide/animations.html#slide-transitions
88 transition: undefined # or BuiltinSlideTransition | string | TransitionGroupProps | null
89 # defines the default animation presets for click animations
90 # Learn more: https://sli.dev/guide/animations.html#click-animation-presets
91 clickAnimation: undefined # or comma-delimited string
92 # used for theme customization, will inject root styles as `--slidev-theme-x` for attribute `x`
93 themeConfig:
94 primary: '#5d8392'
95
96 # favicon, can be a local file path or URL
97 favicon: 'https://cdn.jsdelivr.net/gh/slidevjs/slidev/assets/favicon.png'
98 # URL of PlantUML server used to render diagrams
99 # Learn more: https://sli.dev/features/plantuml.html
100 plantUmlServer: https://www.plantuml.com/plantuml
101 # fonts will be auto-imported from Google fonts
102 # Learn more: https://sli.dev/custom/config-fonts.html
103 fonts:
104 sans: Roboto
105 serif: Roboto Slab
106 mono: Fira Code
107
108 # default frontmatter applies to all slides
109 defaults:
110 layout: default
111 # ...
112
113 # drawing options
114 # Learn more: https://sli.dev/guide/drawing.html
115 drawings:
116 enabled: true
117 persist: false
118 presenterOnly: false
119 syncAll: true
120
121 # HTML tag attributes
122 htmlAttrs:
123 dir: ltr
124 lang: en
125
126 # SEO meta tags
127 seoMeta:
128 ogTitle: Slidev Starter Template
129 ogDescription: Presentation slides for developers
130 ogImage: https://cover.sli.dev
131 ogUrl: https://example.com
132 twitterCard: summary_large_image
133 twitterTitle: Slidev Starter Template
134 twitterDescription: Presentation slides for developers
135 twitterImage: https://cover.sli.dev
136 twitterSite: username
137 twitterUrl: https://example.com
138 ---
139 ```
140
141 Check out the [type definitions](https://github.com/slidevjs/slidev/blob/main/packages/types/src/config.ts) for more details.
142
143 For `colorSchema`, `auto` follows the system preference and allows switching, while `light` and `dark` force that scheme. Use `light dark` or `dark light` to allow switching while choosing the initial default: the first scheme is the default when there is no saved manual preference. Manual selections are saved in browser local storage and shared by presentations on the same origin.
144
145 ## Per-slide Configs {#frontmatter}
146
147 Also every slide accepts the following configuration in its frontmatter block. The following shows the default value for each option:
148
149 ```yaml
150 ---
151 # custom clicks count
152 # Learn more: https://sli.dev/guide/animations#total
153 clicks: 0
154 # custom start clicks count
155 clicksStart: 0
156 # background image URL, local asset path, or color/gradient
157 background: undefined # or string (e.g. 'https://cover.sli.dev' or '/image.png')
158 # completely disable and hide the slide
159 disabled: false
160 # the same as `disabled`
161 hide: false
162 # hide the slide for the <Toc> components
163 hideInToc: false
164 # defines the layout component applied to the slide
165 layout: <"cover" if the slide is the first slide, otherwise "default">
166 # custom class(es) added to the slide root element
167 class: undefined # or string | string[] | Record<string, unknown>
168 # override the title level for the <TitleRenderer> and <Toc> components
169 # only if `title` has also been declared
170 level: 1
171 # mount this slide before entering
172 preload: true
173 # create a route alias that can be used in the URL or with the <Link> component
174 routeAlias: undefined # or string
175 # includes a markdown file
176 # Learn more: https://sli.dev/guide/syntax.html#importing-slides
177 src: undefined # or string
178 # override the title for the <TitleRenderer> and <Toc> components
179 # only if `title` has also been declared
180 title: undefined # or string
181 # defines the transition between the slide and the next one
182 # Learn more: https://sli.dev/guide/animations.html#slide-transitions
183 transition: undefined # or BuiltinSlideTransition | string | TransitionGroupProps | null
184 # defines the default animation presets for click animations in this slide
185 # Learn more: https://sli.dev/guide/animations.html#click-animation-presets
186 clickAnimation: undefined # or comma-delimited string
187 # custom zoom scale
188 # useful for slides with a lot of content
189 zoom: 1
190 # used as positions of draggable elements
191 # Learn more: https://sli.dev/features/draggable.html
192 dragPos: {} # type: Record<string, string>
193 ---
194 ```
195
196 Check out the [type definition](https://github.com/slidevjs/slidev/blob/main/packages/types/src/frontmatter.ts#L260) for more details.
197
198 ## Directory Structure
199
200 Slidev uses directory structure conventions to minimalize the configuration surface and make extensions in functionality flexible and intuitive.
201
202 Refer to the [Directory Structure](/custom/directory-structure) section.
203
204 ## Config Tools
205
206 <script setup>
207 import VPLink from 'vitepress/dist/client/theme-default/components/VPLink.vue'
208 import customizations from '../.vitepress/customizations'
209 </script>
210
211 <li v-for="c of customizations.slice(2)" :key="c.text">
212 <VPLink :href="c.link">
213 {{ c.text }}
214 </VPLink>
215 </li>
216
216 lines MARKDOWN