@slidev/docs 51.6.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +39 -0
- package/builtin/cli.md +96 -0
- package/builtin/components.md +359 -0
- package/builtin/layouts.md +217 -0
- package/custom/config-code-runners.md +78 -0
- package/custom/config-context-menu.md +40 -0
- package/custom/config-fonts.md +105 -0
- package/custom/config-highlighter.md +74 -0
- package/custom/config-katex.md +18 -0
- package/custom/config-mermaid.md +47 -0
- package/custom/config-monaco.md +99 -0
- package/custom/config-parser.md +232 -0
- package/custom/config-routes.md +28 -0
- package/custom/config-shortcuts.md +36 -0
- package/custom/config-transformers.md +43 -0
- package/custom/config-unocss.md +46 -0
- package/custom/config-vite.md +83 -0
- package/custom/config-vue.md +25 -0
- package/custom/directory-structure.md +134 -0
- package/custom/index.md +192 -0
- package/features/block-frontmatter.md +39 -0
- package/features/build-with-pdf.md +42 -0
- package/features/bundle-remote-assets.md +29 -0
- package/features/canvas-size.md +32 -0
- package/features/click-marker.md +31 -0
- package/features/code-block-line-numbers.md +32 -0
- package/features/code-block-max-height.md +32 -0
- package/features/direction-variant.md +31 -0
- package/features/draggable.md +82 -0
- package/features/drawing.md +74 -0
- package/features/eject-theme.md +27 -0
- package/features/frontmatter-merging.md +49 -0
- package/features/global-layers.md +99 -0
- package/features/icons.md +58 -0
- package/features/import-snippet.md +48 -0
- package/features/importing-slides.md +69 -0
- package/features/index.md +93 -0
- package/features/latex.md +80 -0
- package/features/line-highlighting.md +57 -0
- package/features/mdc.md +31 -0
- package/features/mermaid.md +37 -0
- package/features/monaco-editor.md +36 -0
- package/features/monaco-run.md +44 -0
- package/features/monaco-write.md +22 -0
- package/features/plantuml.md +26 -0
- package/features/prettier-plugin.md +55 -0
- package/features/recording.md +28 -0
- package/features/remote-access.md +69 -0
- package/features/rough-marker.md +46 -0
- package/features/shiki-magic-move.md +53 -0
- package/features/side-editor.md +17 -0
- package/features/slide-hook.md +33 -0
- package/features/slide-scope-style.md +44 -0
- package/features/slot-sugar.md +83 -0
- package/features/transform-component.md +29 -0
- package/features/twoslash.md +37 -0
- package/features/vscode-extension.md +80 -0
- package/features/zoom-slide.md +33 -0
- package/guide/animations.md +456 -0
- package/guide/component.md +36 -0
- package/guide/exporting.md +240 -0
- package/guide/faq.md +134 -0
- package/guide/global-context.md +169 -0
- package/guide/hosting.md +220 -0
- package/guide/index.md +161 -0
- package/guide/layout.md +32 -0
- package/guide/syntax.md +179 -0
- package/guide/theme-addon.md +62 -0
- package/guide/ui.md +86 -0
- package/guide/why.md +112 -0
- package/guide/write-addon.md +48 -0
- package/guide/write-layout.md +45 -0
- package/guide/write-theme.md +109 -0
- package/index.md +6 -0
- package/package.json +47 -0
- package/resources/addon-gallery.md +32 -0
- package/resources/covers.md +16 -0
- package/resources/learning.md +22 -0
- package/resources/showcases.md +10 -0
- package/resources/theme-gallery.md +32 -0
|
@@ -0,0 +1,240 @@
|
|
|
1
|
+
---
|
|
2
|
+
outline: deep
|
|
3
|
+
---
|
|
4
|
+
|
|
5
|
+
# Exporting
|
|
6
|
+
|
|
7
|
+
Usually the slides are displayed in a web browser, but you can also export them to PDF, PPTX, PNG, or Markdown files for sharing or printing. This feature is available through the CLI command [`slidev export`](../builtin/cli#export).
|
|
8
|
+
|
|
9
|
+
However, interactive features in your slides may not be available in the exported files. You can build and host your slides as a web application to keep the interactivity. See [Building and Hosting](./hosting) for more information.
|
|
10
|
+
|
|
11
|
+
## The Browser Exporter <Badge> Recommended </Badge> {#browser}
|
|
12
|
+
|
|
13
|
+
> Available since v0.50.0-beta.11
|
|
14
|
+
|
|
15
|
+
Slidev provides a UI in the browser for exporting your slides. You can access it by clicking the "Export" button in "More options" menu in the [navigation bar](./ui#navigation-bar), or go to `http://localhost:<port>/export` directly.
|
|
16
|
+
|
|
17
|
+
In the UI, you can export the slides as PDF, or capture the slides as images and download them as a PPTX or zip file.
|
|
18
|
+
|
|
19
|
+
Note that browsers other than **modern Chromium-based browsers** may not work well with the exporting UI. If you encounter any issues, please try use the CLI instead.
|
|
20
|
+
|
|
21
|
+
> The following content of this page is for the CLI only.
|
|
22
|
+
|
|
23
|
+
## The CLI {#cli}
|
|
24
|
+
|
|
25
|
+
Exporting to PDF, PPTX, or PNG relies on [Playwright](https://playwright.dev) for rendering the slides. Therefore [`playwright-chromium`](https://npmjs.com/package/playwright-chromium) is required to be installed in your project:
|
|
26
|
+
|
|
27
|
+
::: code-group
|
|
28
|
+
|
|
29
|
+
```bash [pnpm]
|
|
30
|
+
$ pnpm add -D playwright-chromium
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
```bash [npm]
|
|
34
|
+
$ npm i -D playwright-chromium
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
```bash [yarn]
|
|
38
|
+
$ yarn add -D playwright-chromium
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
```bash [bun]
|
|
42
|
+
$ bun add -D playwright-chromium
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
:::
|
|
46
|
+
|
|
47
|
+
## Formats
|
|
48
|
+
|
|
49
|
+
### PDF
|
|
50
|
+
|
|
51
|
+
After installing `playwright-chromium` as described above, you can export your slides to PDF using the following command:
|
|
52
|
+
|
|
53
|
+
```bash
|
|
54
|
+
$ slidev export
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
By default, the PDF will be placed at `./slides-export.pdf`.
|
|
58
|
+
|
|
59
|
+
### PPTX
|
|
60
|
+
|
|
61
|
+
Slidev can also export your slides as a PPTX file:
|
|
62
|
+
|
|
63
|
+
```bash
|
|
64
|
+
$ slidev export --format pptx
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
Note that all the slides in the PPTX file will be exported as images, so the text will not be selectable. Presenter notes will be conveyed into the PPTX file on a per-slide basis.
|
|
68
|
+
|
|
69
|
+
In this mode, the `--with-clicks` option is enabled by default. To disable it, pass `--with-clicks false`.
|
|
70
|
+
|
|
71
|
+
### PNGs and Markdown
|
|
72
|
+
|
|
73
|
+
When passing in the `--format png` option, Slidev will export PNG images for each slide instead of a PDF:
|
|
74
|
+
|
|
75
|
+
```bash
|
|
76
|
+
$ slidev export --format png
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
You can also compile a markdown file composed of compiled png using `--format md`:
|
|
80
|
+
|
|
81
|
+
```bash
|
|
82
|
+
$ slidev export --format md
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
## Options
|
|
86
|
+
|
|
87
|
+
Here are some common options you can use with the `slidev export` command. For a full list of options, see the [CLI documentation](../builtin/cli#export).
|
|
88
|
+
|
|
89
|
+
### Export Clicks Steps
|
|
90
|
+
|
|
91
|
+
By default, Slidev exports one page per slide with clicks animations disabled. If you want to export slides with multiple steps into multiple pages, pass the `--with-clicks` option:
|
|
92
|
+
|
|
93
|
+
```bash
|
|
94
|
+
$ slidev export --with-clicks
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
### Output Filename
|
|
98
|
+
|
|
99
|
+
You can specify the output filename with the `--output` option:
|
|
100
|
+
|
|
101
|
+
```bash
|
|
102
|
+
$ slidev export --output my-pdf-export
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
Or in the headmatter configuration:
|
|
106
|
+
|
|
107
|
+
```yaml
|
|
108
|
+
---
|
|
109
|
+
exportFilename: my-pdf-export
|
|
110
|
+
---
|
|
111
|
+
```
|
|
112
|
+
|
|
113
|
+
### Export with Range
|
|
114
|
+
|
|
115
|
+
By default, all slides in the presentation are exported. If you want to export a specific slide or a range of slides you can set the `--range` option and specify which slides you would like to export:
|
|
116
|
+
|
|
117
|
+
```bash
|
|
118
|
+
$ slidev export --range 1,6-8,10
|
|
119
|
+
```
|
|
120
|
+
|
|
121
|
+
This option accepts both specific slide numbers and ranges. The example above would export slides 1,6,7,8 and 10.
|
|
122
|
+
|
|
123
|
+
### Multiple Exports
|
|
124
|
+
|
|
125
|
+
You can also export multiple slides at once:
|
|
126
|
+
|
|
127
|
+
```bash
|
|
128
|
+
$ slidev export slides1.md slides2.md
|
|
129
|
+
```
|
|
130
|
+
|
|
131
|
+
Or (only available in certain shells):
|
|
132
|
+
|
|
133
|
+
```bash
|
|
134
|
+
$ slidev export *.md
|
|
135
|
+
```
|
|
136
|
+
|
|
137
|
+
In this case, each input file will generate its own PDF file.
|
|
138
|
+
|
|
139
|
+
### Dark Mode
|
|
140
|
+
|
|
141
|
+
In case you want to export your slides using the dark version of the theme, use the `--dark` option:
|
|
142
|
+
|
|
143
|
+
```bash
|
|
144
|
+
$ slidev export --dark
|
|
145
|
+
```
|
|
146
|
+
|
|
147
|
+
### Timeouts
|
|
148
|
+
|
|
149
|
+
For big presentations, you might want to increase the Playwright timeout with `--timeout`:
|
|
150
|
+
|
|
151
|
+
```bash
|
|
152
|
+
$ slidev export --timeout 60000
|
|
153
|
+
```
|
|
154
|
+
|
|
155
|
+
### Wait
|
|
156
|
+
|
|
157
|
+
Some parts of your slides may require a longer time to render. You can use the `--wait` option to have an extra delay before exporting:
|
|
158
|
+
|
|
159
|
+
```bash
|
|
160
|
+
$ slidev export --wait 10000
|
|
161
|
+
```
|
|
162
|
+
|
|
163
|
+
There is also a `--wait-until` option to wait for a state before exporting each slide. If you keep encountering timeout issues, you can try setting this option:
|
|
164
|
+
|
|
165
|
+
```bash
|
|
166
|
+
$ slidev export --wait-until none
|
|
167
|
+
```
|
|
168
|
+
|
|
169
|
+
Possible values:
|
|
170
|
+
|
|
171
|
+
- `'networkidle'` - (_default_) consider operation to be finished when there are no network connections for at least `500` ms. This is the safest, but may cause timeouts.
|
|
172
|
+
- `'domcontentloaded'` - consider operation to be finished when the `DOMContentLoaded` event is fired.
|
|
173
|
+
- `'load'` - consider operation to be finished when the `load` event is fired.
|
|
174
|
+
- `'none'` - do not wait for any event.
|
|
175
|
+
|
|
176
|
+
::: warning
|
|
177
|
+
When specifying values other than `'networkidle'`, please make sure the printed slides are complete and correct. If some contents are missing, you may need to use the `--wait` option.
|
|
178
|
+
:::
|
|
179
|
+
|
|
180
|
+
### Executable Path
|
|
181
|
+
|
|
182
|
+
Chromium may miss some features like codecs that are required to decode some videos. You can set the browser executable path for Playwright to your Chrome or Edge using `--executable-path`:
|
|
183
|
+
|
|
184
|
+
```bash
|
|
185
|
+
$ slidev export --executable-path [path_to_chromium]
|
|
186
|
+
```
|
|
187
|
+
|
|
188
|
+
### PDF Outline
|
|
189
|
+
|
|
190
|
+
> Available since v0.36.10
|
|
191
|
+
|
|
192
|
+
You can generate the PDF outline by passing the `--with-toc` option:
|
|
193
|
+
|
|
194
|
+
```bash
|
|
195
|
+
$ slidev export --with-toc
|
|
196
|
+
```
|
|
197
|
+
|
|
198
|
+
### Omit Background
|
|
199
|
+
|
|
200
|
+
When exporting to PNGs, you can remove the default browser background by passing `--omit-background`:
|
|
201
|
+
|
|
202
|
+
```bash
|
|
203
|
+
$ slidev export --omit-background
|
|
204
|
+
```
|
|
205
|
+
|
|
206
|
+
The default browser background is the white background visible on all browser windows and is different than other backgrounds applied throughout the application using CSS styling. [See Playwright docs](https://playwright.dev/docs/api/class-page#page-screenshot-option-omit-background). You will then need to apply additional CSS styling to the application to reveal the transparency.
|
|
207
|
+
|
|
208
|
+
Here is a basic example that covers all backgrounds in the application:
|
|
209
|
+
|
|
210
|
+
```css
|
|
211
|
+
* {
|
|
212
|
+
background: transparent !important;
|
|
213
|
+
}
|
|
214
|
+
```
|
|
215
|
+
|
|
216
|
+
## Troubleshooting
|
|
217
|
+
|
|
218
|
+
### Missing Content or Animation not Finished
|
|
219
|
+
|
|
220
|
+
If you find that some content is missing or the animations are not finished in the exported PDF, you can try adding a wait time before exporting each slide:
|
|
221
|
+
|
|
222
|
+
```bash
|
|
223
|
+
$ slidev export --wait 1000
|
|
224
|
+
```
|
|
225
|
+
|
|
226
|
+
### Broken Emojis
|
|
227
|
+
|
|
228
|
+
If the PDF or PNG are missing Emojis, you are likely missing required fonts (such as. e.g. [Google's _Noto Emoji_](https://fonts.google.com/noto/specimen/Noto+Emoji)) in your environment.
|
|
229
|
+
|
|
230
|
+
This can affect e.g. CI/CD-like in-container sort of Linux environments. It can be fixed e.g. like this:
|
|
231
|
+
|
|
232
|
+
```bash
|
|
233
|
+
$ curl -L --output NotoColorEmoji.ttf https://github.com/googlefonts/noto-emoji/raw/main/fonts/NotoColorEmoji.ttf
|
|
234
|
+
$ sudo mv NotoColorEmoji.ttf /usr/local/share/fonts/
|
|
235
|
+
$ fc-cache -fv
|
|
236
|
+
```
|
|
237
|
+
|
|
238
|
+
### Wrong Context in Global Layers
|
|
239
|
+
|
|
240
|
+
See the tip in https://sli.dev/features/global-layers.
|
package/guide/faq.md
ADDED
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
---
|
|
2
|
+
outline: deep
|
|
3
|
+
---
|
|
4
|
+
|
|
5
|
+
# FAQ
|
|
6
|
+
|
|
7
|
+
## Assets Handling {#assets-handling}
|
|
8
|
+
|
|
9
|
+
You may use static assets like images and videos in your slides. Since Slidev is based on Vite, you can import them directly in your markdown files.
|
|
10
|
+
|
|
11
|
+
URLs that can be statically analyzed as assets can use relative paths:
|
|
12
|
+
|
|
13
|
+
```md
|
|
14
|
+

|
|
15
|
+
<img src="./image.png" />
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
In the above case, the URLs will be resolved to `/BASE_URL/assets/image.png` after build.
|
|
19
|
+
|
|
20
|
+
However, relative paths in frontmatter and other components will be broken after build:
|
|
21
|
+
|
|
22
|
+
```md
|
|
23
|
+
---
|
|
24
|
+
background: ./image.png # Broken after build
|
|
25
|
+
---
|
|
26
|
+
|
|
27
|
+
<Comp src="./image.png" />
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
In the above case, the URLs are not statically analyzable and will be preserved as-is, which will result in 404 errors after build.
|
|
31
|
+
|
|
32
|
+
To solve this, you can place these assets in the [public folder](../custom/directory-structure#public) and use an absolute path to import them:
|
|
33
|
+
|
|
34
|
+
```md
|
|
35
|
+
---
|
|
36
|
+
background: /image.png
|
|
37
|
+
---
|
|
38
|
+
|
|
39
|
+
<Comp src="/image.png" />
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
For more details, refer to [Vite's documentation](https://vitejs.dev/guide/assets.html).
|
|
43
|
+
|
|
44
|
+
## Positioning {#positioning}
|
|
45
|
+
|
|
46
|
+
Since Slidev is web-based, CSS is the primary way to position elements. Here are some useful tips for position elements:
|
|
47
|
+
|
|
48
|
+
### Grids And Flexboxes
|
|
49
|
+
|
|
50
|
+
You can use CSS Grids to create complex layouts:
|
|
51
|
+
|
|
52
|
+
::: code-group
|
|
53
|
+
|
|
54
|
+
```md [Two columns]
|
|
55
|
+
<div class="grid grid-cols-2 gap-4">
|
|
56
|
+
<div>
|
|
57
|
+
The first column
|
|
58
|
+
</div>
|
|
59
|
+
<div>
|
|
60
|
+
The second column
|
|
61
|
+
</div>
|
|
62
|
+
</div>
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
```md [Complex case]
|
|
66
|
+
<div class="grid grid-cols-[200px_1fr_10%] gap-4">
|
|
67
|
+
<div>
|
|
68
|
+
The first column (200px)
|
|
69
|
+
</div>
|
|
70
|
+
<div>
|
|
71
|
+
The second column (auto fit)
|
|
72
|
+
</div>
|
|
73
|
+
<div>
|
|
74
|
+
The third column (10% width to parent container)
|
|
75
|
+
</div>
|
|
76
|
+
</div>
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
:::
|
|
80
|
+
|
|
81
|
+
And use Flexboxes to create more responsive layouts:
|
|
82
|
+
|
|
83
|
+
::: code-group
|
|
84
|
+
|
|
85
|
+
```md [Horizontal]
|
|
86
|
+
<div class="flex items-center">
|
|
87
|
+
<div>
|
|
88
|
+
First block
|
|
89
|
+
</div>
|
|
90
|
+
<div>
|
|
91
|
+
Second block
|
|
92
|
+
</div>
|
|
93
|
+
</div>
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
```md [Vertical]
|
|
97
|
+
<div class="flex flex-col items-center">
|
|
98
|
+
<div>
|
|
99
|
+
Centered content
|
|
100
|
+
</div>
|
|
101
|
+
</div>
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
:::
|
|
105
|
+
|
|
106
|
+
Learn more: [CSS Grids](https://css-tricks.com/snippets/css/complete-guide-grid/), [flexboxes](https://css-tricks.com/snippets/css/a-guide-to-flexbox/), or even [Masonry](https://css-tricks.com/native-css-masonry-layout-in-css-grid/).
|
|
107
|
+
|
|
108
|
+
### Absolute Position
|
|
109
|
+
|
|
110
|
+
You can use UnoCSS to position elements absolutely:
|
|
111
|
+
|
|
112
|
+
```md
|
|
113
|
+
<div class="absolute left-30px bottom-30px">
|
|
114
|
+
This is a left-bottom aligned footer
|
|
115
|
+
</div>
|
|
116
|
+
```
|
|
117
|
+
|
|
118
|
+
Or use the draggable elements feature:
|
|
119
|
+
|
|
120
|
+
<LinkCard link="features/draggable" />
|
|
121
|
+
|
|
122
|
+
## Adjust Sizes {#adjust-size}
|
|
123
|
+
|
|
124
|
+
- Adjust all slides's size:
|
|
125
|
+
|
|
126
|
+
<LinkCard link="features/canvas-size" />
|
|
127
|
+
|
|
128
|
+
- Adjust several slides' size:
|
|
129
|
+
|
|
130
|
+
<LinkCard link="features/zoom-slide" />
|
|
131
|
+
|
|
132
|
+
- Adjust some elements' size:
|
|
133
|
+
|
|
134
|
+
<LinkCard link="features/transform-component" />
|
|
@@ -0,0 +1,169 @@
|
|
|
1
|
+
# Global Context
|
|
2
|
+
|
|
3
|
+
Slidev injects several global context values for advanced navigation controls.
|
|
4
|
+
|
|
5
|
+
## Direct Usage {#direct-usage}
|
|
6
|
+
|
|
7
|
+
You can access them directly in your slides or components:
|
|
8
|
+
|
|
9
|
+
```md
|
|
10
|
+
<!-- slides.md -->
|
|
11
|
+
|
|
12
|
+
# Page 1
|
|
13
|
+
|
|
14
|
+
Current page is: {{ $nav.currentPage }}
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
```vue
|
|
18
|
+
<!-- Foo.vue -->
|
|
19
|
+
|
|
20
|
+
<template>
|
|
21
|
+
<div>Title: {{ $slidev.configs.title }}</div>
|
|
22
|
+
<button @click="$nav.next">
|
|
23
|
+
Next Click
|
|
24
|
+
</button>
|
|
25
|
+
<button @click="$nav.nextSlide">
|
|
26
|
+
Next Slide
|
|
27
|
+
</button>
|
|
28
|
+
</template>
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
## Composable Usage {#composable-usage}
|
|
32
|
+
|
|
33
|
+
> Available since v0.48.0
|
|
34
|
+
|
|
35
|
+
If you want to get the context programmatically (also type-safely), you can import composables from `@slidev/client`:
|
|
36
|
+
|
|
37
|
+
```vue
|
|
38
|
+
<script setup>
|
|
39
|
+
import { onSlideEnter, onSlideLeave, useDarkMode, useIsSlideActive, useNav, useSlideContext } from '@slidev/client'
|
|
40
|
+
|
|
41
|
+
const { $slidev } = useSlideContext()
|
|
42
|
+
const { currentPage, currentLayout, currentSlideRoute } = useNav()
|
|
43
|
+
const { isDark } = useDarkMode()
|
|
44
|
+
const isActive = useIsSlideActive()
|
|
45
|
+
onSlideEnter(() => { /* ... */ })
|
|
46
|
+
onSlideLeave(() => { /* ... */ })
|
|
47
|
+
// ...
|
|
48
|
+
</script>
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
> [!NOTE]
|
|
52
|
+
> Previously, you might see the usage of importing nested modules like `import { isDark } from '@slidev/client/logic/dark.ts'`, this is **NOT RECOMMENDED** as they are internal implementation details and may change in the future. Always use the public APIs from `@slidev/client` if possible.
|
|
53
|
+
|
|
54
|
+
::: warning
|
|
55
|
+
|
|
56
|
+
When the `useSlideContext` composable is used in a file, the automatic injection of `$slidev` will be disabled. You need to manually get the `$slidev` object to the `useSlideContext` function.
|
|
57
|
+
|
|
58
|
+
:::
|
|
59
|
+
|
|
60
|
+
<SeeAlso :links="['features/slide-hook']" />
|
|
61
|
+
|
|
62
|
+
## Properties {#properties}
|
|
63
|
+
|
|
64
|
+
### `$slidev` {#slidev}
|
|
65
|
+
|
|
66
|
+
The global context object.
|
|
67
|
+
|
|
68
|
+
### `$frontmatter` {#frontmatter}
|
|
69
|
+
|
|
70
|
+
The frontmatter object of the current slide. Note that this is empty for components out of the slides like <LinkInline link="features/global-layers" />.
|
|
71
|
+
|
|
72
|
+
### `$clicks` {#clicks}
|
|
73
|
+
|
|
74
|
+
`$clicks` hold the number of clicks on the current slide. Can be used conditionally to show different content on clicks.
|
|
75
|
+
|
|
76
|
+
```html
|
|
77
|
+
<div v-if="$clicks > 3">Content</div>
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
See the <LinkInline link="guide/animations" /> guide for more information.
|
|
81
|
+
|
|
82
|
+
### `$nav` {#nav}
|
|
83
|
+
|
|
84
|
+
A reactive object holding the properties and controls of the slide navigation. For examples:
|
|
85
|
+
|
|
86
|
+
```js
|
|
87
|
+
$nav.next() // go next step
|
|
88
|
+
$nav.nextSlide() // go next slide (skip clicks)
|
|
89
|
+
$nav.go(10) // go slide #10
|
|
90
|
+
|
|
91
|
+
$nav.currentPage // current slide number
|
|
92
|
+
$nav.currentLayout // current layout name
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
For more properties available, refer to the [`SlidevContextNav` interface](https://github.com/slidevjs/slidev/blob/main/packages/client/composables/useNav.ts).
|
|
96
|
+
|
|
97
|
+
### `$page` {#page}
|
|
98
|
+
|
|
99
|
+
`$page` holds the number of the current page, 1-indexed.
|
|
100
|
+
|
|
101
|
+
```md
|
|
102
|
+
Page: {{ $page }}
|
|
103
|
+
|
|
104
|
+
Is current page active: {{ $page === $nav.currentPage }}
|
|
105
|
+
```
|
|
106
|
+
|
|
107
|
+
> [!Note] > `$nav.clicks` is a global state while `$clicks` is the local clicks number for each slide.
|
|
108
|
+
|
|
109
|
+
### `$renderContext` {#render-context}
|
|
110
|
+
|
|
111
|
+
`$renderContext` holds the current render context, which can be `slide`, `overview`, `presenter` or `previewNext`
|
|
112
|
+
|
|
113
|
+
```md
|
|
114
|
+
<div v-if="['slide', 'presenter'].includes($renderContext)">
|
|
115
|
+
This content will only be rendered in main slides view
|
|
116
|
+
</div>
|
|
117
|
+
```
|
|
118
|
+
|
|
119
|
+
You can also use the [`<RenderWhen>` component](../builtin/components#renderwhen).
|
|
120
|
+
|
|
121
|
+
### `$slidev.configs` {#configs}
|
|
122
|
+
|
|
123
|
+
A reactive object holding the configurations for the slide project. For example:
|
|
124
|
+
|
|
125
|
+
```md
|
|
126
|
+
---
|
|
127
|
+
title: My First Slidev!
|
|
128
|
+
---
|
|
129
|
+
|
|
130
|
+
# Page 1
|
|
131
|
+
|
|
132
|
+
---
|
|
133
|
+
|
|
134
|
+
# Any Page
|
|
135
|
+
|
|
136
|
+
{{ $slidev.configs.title }} // 'My First Slidev!'
|
|
137
|
+
```
|
|
138
|
+
|
|
139
|
+
### `$slidev.themeConfigs` {#theme-configs}
|
|
140
|
+
|
|
141
|
+
A reactive object holding the parsed theme configurations:
|
|
142
|
+
|
|
143
|
+
```yaml
|
|
144
|
+
---
|
|
145
|
+
title: My First Slidev!
|
|
146
|
+
themeConfig:
|
|
147
|
+
primary: '#213435'
|
|
148
|
+
---
|
|
149
|
+
```
|
|
150
|
+
|
|
151
|
+
Then the theme can access the primary color like:
|
|
152
|
+
|
|
153
|
+
```md
|
|
154
|
+
{{ $slidev.themeConfigs.primary }} // '#213435'
|
|
155
|
+
```
|
|
156
|
+
|
|
157
|
+
## Types {#types}
|
|
158
|
+
|
|
159
|
+
If you want to get a type programmatically, you can import types like `TocItem` from `@slidev/types`:
|
|
160
|
+
|
|
161
|
+
```vue
|
|
162
|
+
<script setup>
|
|
163
|
+
import type { TocItem } from '@slidev/types'
|
|
164
|
+
|
|
165
|
+
function tocFunc(tree: TocItem[]): TocItem[] {
|
|
166
|
+
// ...
|
|
167
|
+
}
|
|
168
|
+
</script>
|
|
169
|
+
```
|