slidev-addon-agent 0.0.1
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 +54 -0
- package/agent/constants.ts +119 -0
- package/agent/deck-context.ts +67 -0
- package/agent/index.ts +201 -0
- package/agent/middleware.ts +163 -0
- package/agent/skills/slidev/README.md +61 -0
- package/agent/skills/slidev/SKILL.md +189 -0
- package/agent/skills/slidev/references/animation-click-marker.md +37 -0
- package/agent/skills/slidev/references/animation-drawing.md +68 -0
- package/agent/skills/slidev/references/animation-rough-marker.md +53 -0
- package/agent/skills/slidev/references/api-slide-hooks.md +37 -0
- package/agent/skills/slidev/references/build-og-image.md +36 -0
- package/agent/skills/slidev/references/build-pdf.md +40 -0
- package/agent/skills/slidev/references/build-remote-assets.md +34 -0
- package/agent/skills/slidev/references/build-seo-meta.md +43 -0
- package/agent/skills/slidev/references/code-groups.md +64 -0
- package/agent/skills/slidev/references/code-import-snippet.md +55 -0
- package/agent/skills/slidev/references/code-line-highlighting.md +50 -0
- package/agent/skills/slidev/references/code-line-numbers.md +46 -0
- package/agent/skills/slidev/references/code-magic-move.md +57 -0
- package/agent/skills/slidev/references/code-max-height.md +37 -0
- package/agent/skills/slidev/references/code-twoslash.md +42 -0
- package/agent/skills/slidev/references/core-animations.md +196 -0
- package/agent/skills/slidev/references/core-cli.md +140 -0
- package/agent/skills/slidev/references/core-components.md +197 -0
- package/agent/skills/slidev/references/core-exporting.md +148 -0
- package/agent/skills/slidev/references/core-frontmatter.md +195 -0
- package/agent/skills/slidev/references/core-global-context.md +155 -0
- package/agent/skills/slidev/references/core-headmatter.md +188 -0
- package/agent/skills/slidev/references/core-hosting.md +152 -0
- package/agent/skills/slidev/references/core-layouts.md +286 -0
- package/agent/skills/slidev/references/core-syntax.md +155 -0
- package/agent/skills/slidev/references/diagram-latex.md +55 -0
- package/agent/skills/slidev/references/diagram-mermaid.md +44 -0
- package/agent/skills/slidev/references/diagram-plantuml.md +45 -0
- package/agent/skills/slidev/references/editor-monaco-run.md +44 -0
- package/agent/skills/slidev/references/editor-monaco-write.md +24 -0
- package/agent/skills/slidev/references/editor-monaco.md +50 -0
- package/agent/skills/slidev/references/editor-prettier.md +40 -0
- package/agent/skills/slidev/references/editor-side.md +23 -0
- package/agent/skills/slidev/references/editor-vscode.md +55 -0
- package/agent/skills/slidev/references/layout-canvas-size.md +25 -0
- package/agent/skills/slidev/references/layout-draggable.md +57 -0
- package/agent/skills/slidev/references/layout-global-layers.md +50 -0
- package/agent/skills/slidev/references/layout-slots.md +75 -0
- package/agent/skills/slidev/references/layout-transform.md +33 -0
- package/agent/skills/slidev/references/layout-zoom.md +39 -0
- package/agent/skills/slidev/references/presenter-notes-ruby.md +35 -0
- package/agent/skills/slidev/references/presenter-recording.md +30 -0
- package/agent/skills/slidev/references/presenter-remote.md +40 -0
- package/agent/skills/slidev/references/presenter-timer.md +34 -0
- package/agent/skills/slidev/references/style-direction.md +34 -0
- package/agent/skills/slidev/references/style-icons.md +46 -0
- package/agent/skills/slidev/references/style-scoped.md +50 -0
- package/agent/skills/slidev/references/syntax-block-frontmatter.md +39 -0
- package/agent/skills/slidev/references/syntax-frontmatter-merging.md +49 -0
- package/agent/skills/slidev/references/syntax-importing-slides.md +60 -0
- package/agent/skills/slidev/references/syntax-mdc.md +51 -0
- package/agent/skills/slidev/references/tool-eject-theme.md +27 -0
- package/agent/tools/export-tool.ts +216 -0
- package/agent/tools/review-tool.ts +136 -0
- package/app/index.ts +124 -0
- package/components/MessageItem.vue +231 -0
- package/components/SlidevAgentNavButton.vue +48 -0
- package/components/SlidevAgentSidebar.vue +766 -0
- package/components/SubagentCard.vue +184 -0
- package/components/TypingDots.vue +62 -0
- package/dist/agent/constants.js +117 -0
- package/dist/agent/deck-context.js +47 -0
- package/dist/agent/index.js +167 -0
- package/dist/agent/middleware.js +134 -0
- package/dist/agent/slide-preview-tool.js +257 -0
- package/dist/agent/tools/export-tool.js +167 -0
- package/dist/agent/tools/review-tool.js +111 -0
- package/dist/app/index.js +101 -0
- package/dist/bin/slidev-agent.js +155 -0
- package/dist/lib/bridge.js +151 -0
- package/dist/lib/env.js +17 -0
- package/dist/lib/headless-tools.js +10 -0
- package/dist/lib/langgraph-init.js +59 -0
- package/dist/lib/review-tool.js +98 -0
- package/lib/bridge.ts +212 -0
- package/lib/config.ts +79 -0
- package/lib/env.ts +38 -0
- package/lib/headless-tool-impl.ts +26 -0
- package/lib/headless-tools.ts +11 -0
- package/lib/langgraph-init.ts +79 -0
- package/lib/messages.ts +169 -0
- package/lib/render-chat-markdown.ts +19 -0
- package/lib/sidebar.ts +573 -0
- package/lib/state.ts +44 -0
- package/package.json +65 -0
- package/public/deepagents.svg +12 -0
|
@@ -0,0 +1,197 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: components
|
|
3
|
+
description: Ready-to-use components in Slidev
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Built-in Components
|
|
7
|
+
|
|
8
|
+
Ready-to-use components in Slidev.
|
|
9
|
+
|
|
10
|
+
## Navigation
|
|
11
|
+
|
|
12
|
+
### Link
|
|
13
|
+
|
|
14
|
+
Navigate to slide:
|
|
15
|
+
```md
|
|
16
|
+
<Link to="5">Go to slide 5</Link>
|
|
17
|
+
<Link to="intro">Go to intro</Link> <!-- with routeAlias -->
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
### SlideCurrentNo / SlidesTotal
|
|
21
|
+
|
|
22
|
+
```md
|
|
23
|
+
Slide <SlideCurrentNo /> of <SlidesTotal />
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
### Toc (Table of Contents)
|
|
27
|
+
|
|
28
|
+
```md
|
|
29
|
+
<Toc />
|
|
30
|
+
<Toc maxDepth="2" />
|
|
31
|
+
<Toc columns="2" />
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
Props:
|
|
35
|
+
- `columns` - Number of columns
|
|
36
|
+
- `maxDepth` / `minDepth` - Heading depth filter
|
|
37
|
+
- `mode` - 'all' | 'onlyCurrentTree' | 'onlySiblings'
|
|
38
|
+
|
|
39
|
+
### TitleRenderer
|
|
40
|
+
|
|
41
|
+
Render slide title:
|
|
42
|
+
```md
|
|
43
|
+
<TitleRenderer no="3" />
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
## Animations
|
|
47
|
+
|
|
48
|
+
### VClick / VClicks
|
|
49
|
+
|
|
50
|
+
```md
|
|
51
|
+
<VClick>Shows on click</VClick>
|
|
52
|
+
|
|
53
|
+
<VClicks>
|
|
54
|
+
|
|
55
|
+
- Item 1
|
|
56
|
+
- Item 2
|
|
57
|
+
|
|
58
|
+
</VClicks>
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
### VAfter
|
|
62
|
+
|
|
63
|
+
```md
|
|
64
|
+
<VClick>First</VClick>
|
|
65
|
+
<VAfter>Shows with first</VAfter>
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
### VSwitch
|
|
69
|
+
|
|
70
|
+
```md
|
|
71
|
+
<VSwitch>
|
|
72
|
+
<template #1>State 1</template>
|
|
73
|
+
<template #2>State 2</template>
|
|
74
|
+
</VSwitch>
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
## Drawing
|
|
78
|
+
|
|
79
|
+
### Arrow
|
|
80
|
+
|
|
81
|
+
```md
|
|
82
|
+
<Arrow x1="10" y1="10" x2="100" y2="100" />
|
|
83
|
+
<Arrow x1="10" y1="10" x2="100" y2="100" two-way />
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
Props: `x1`, `y1`, `x2`, `y2`, `width`, `color`, `two-way`
|
|
87
|
+
|
|
88
|
+
### VDragArrow
|
|
89
|
+
|
|
90
|
+
Draggable arrow:
|
|
91
|
+
```md
|
|
92
|
+
<VDragArrow />
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
## Layout
|
|
96
|
+
|
|
97
|
+
### Transform
|
|
98
|
+
|
|
99
|
+
Scale elements:
|
|
100
|
+
```md
|
|
101
|
+
<Transform :scale="0.5">
|
|
102
|
+
<LargeContent />
|
|
103
|
+
</Transform>
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
Props: `scale`, `origin`
|
|
107
|
+
|
|
108
|
+
### AutoFitText
|
|
109
|
+
|
|
110
|
+
Auto-sizing text:
|
|
111
|
+
```md
|
|
112
|
+
<AutoFitText :max="200" :min="50" modelValue="Hello" />
|
|
113
|
+
```
|
|
114
|
+
|
|
115
|
+
## Media
|
|
116
|
+
|
|
117
|
+
### SlidevVideo
|
|
118
|
+
|
|
119
|
+
```md
|
|
120
|
+
<SlidevVideo v-click autoplay controls>
|
|
121
|
+
<source src="/video.mp4" type="video/mp4" />
|
|
122
|
+
</SlidevVideo>
|
|
123
|
+
```
|
|
124
|
+
|
|
125
|
+
Props: `controls`, `autoplay`, `autoreset`, `poster`, `timestamp`
|
|
126
|
+
|
|
127
|
+
### Youtube
|
|
128
|
+
|
|
129
|
+
```md
|
|
130
|
+
<Youtube id="dQw4w9WgXcQ" />
|
|
131
|
+
<Youtube id="dQw4w9WgXcQ" width="600" height="400" />
|
|
132
|
+
```
|
|
133
|
+
|
|
134
|
+
### Tweet
|
|
135
|
+
|
|
136
|
+
```md
|
|
137
|
+
<Tweet id="1423789844234231808" />
|
|
138
|
+
<Tweet id="1423789844234231808" :scale="0.8" />
|
|
139
|
+
```
|
|
140
|
+
|
|
141
|
+
## Conditional
|
|
142
|
+
|
|
143
|
+
### LightOrDark
|
|
144
|
+
|
|
145
|
+
```md
|
|
146
|
+
<LightOrDark>
|
|
147
|
+
<template #dark>Dark mode content</template>
|
|
148
|
+
<template #light>Light mode content</template>
|
|
149
|
+
</LightOrDark>
|
|
150
|
+
```
|
|
151
|
+
|
|
152
|
+
### RenderWhen
|
|
153
|
+
|
|
154
|
+
```md
|
|
155
|
+
<RenderWhen context="presenter">
|
|
156
|
+
Only in presenter mode
|
|
157
|
+
</RenderWhen>
|
|
158
|
+
```
|
|
159
|
+
|
|
160
|
+
Context values:
|
|
161
|
+
- `main` - Main presentation view
|
|
162
|
+
- `visible` - Visible slides
|
|
163
|
+
- `print` - Print/export mode
|
|
164
|
+
- `slide` - Normal slide view
|
|
165
|
+
- `overview` - Overview mode
|
|
166
|
+
- `presenter` - Presenter mode
|
|
167
|
+
- `previewNext` - Next slide preview
|
|
168
|
+
|
|
169
|
+
## Branding
|
|
170
|
+
|
|
171
|
+
### PoweredBySlidev
|
|
172
|
+
|
|
173
|
+
```md
|
|
174
|
+
<PoweredBySlidev />
|
|
175
|
+
```
|
|
176
|
+
|
|
177
|
+
## Draggable
|
|
178
|
+
|
|
179
|
+
### VDrag
|
|
180
|
+
|
|
181
|
+
```md
|
|
182
|
+
<VDrag pos="myElement">
|
|
183
|
+
Draggable content
|
|
184
|
+
</VDrag>
|
|
185
|
+
```
|
|
186
|
+
|
|
187
|
+
See [draggable](draggable.md) for details.
|
|
188
|
+
|
|
189
|
+
## Component Auto-Import
|
|
190
|
+
|
|
191
|
+
Components from these sources are auto-imported:
|
|
192
|
+
1. Built-in components
|
|
193
|
+
2. Theme components
|
|
194
|
+
3. Addon components
|
|
195
|
+
4. `./components/` directory
|
|
196
|
+
|
|
197
|
+
No import statements needed.
|
|
@@ -0,0 +1,148 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: exporting
|
|
3
|
+
description: Export presentations to PDF, PPTX, PNG, or Markdown
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Exporting Slides
|
|
7
|
+
|
|
8
|
+
Export presentations to PDF, PPTX, PNG, or Markdown.
|
|
9
|
+
|
|
10
|
+
## Browser Exporter
|
|
11
|
+
|
|
12
|
+
Access at `http://localhost:3030/export`:
|
|
13
|
+
- Select format and options
|
|
14
|
+
- Preview and download
|
|
15
|
+
|
|
16
|
+
## CLI Export
|
|
17
|
+
|
|
18
|
+
Requires playwright:
|
|
19
|
+
```bash
|
|
20
|
+
pnpm add -D playwright-chromium
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
### PDF Export
|
|
24
|
+
|
|
25
|
+
```bash
|
|
26
|
+
slidev export
|
|
27
|
+
slidev export --output my-slides.pdf
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
### PowerPoint Export
|
|
31
|
+
|
|
32
|
+
```bash
|
|
33
|
+
slidev export --format pptx
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
### PNG Export
|
|
37
|
+
|
|
38
|
+
```bash
|
|
39
|
+
slidev export --format png
|
|
40
|
+
slidev export --format png --range 1-5
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
### Markdown Export
|
|
44
|
+
|
|
45
|
+
```bash
|
|
46
|
+
slidev export --format md
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
## Export Options
|
|
50
|
+
|
|
51
|
+
### With Click Steps
|
|
52
|
+
|
|
53
|
+
Export each click as separate page:
|
|
54
|
+
```bash
|
|
55
|
+
slidev export --with-clicks
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
### Dark Mode
|
|
59
|
+
|
|
60
|
+
```bash
|
|
61
|
+
slidev export --dark
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
### Slide Range
|
|
65
|
+
|
|
66
|
+
```bash
|
|
67
|
+
slidev export --range 1,4-7,10
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
### Table of Contents
|
|
71
|
+
|
|
72
|
+
PDF with clickable outline:
|
|
73
|
+
```bash
|
|
74
|
+
slidev export --with-toc
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
### Timeout
|
|
78
|
+
|
|
79
|
+
For slow-rendering slides:
|
|
80
|
+
```bash
|
|
81
|
+
slidev export --timeout 60000
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
### Wait
|
|
85
|
+
|
|
86
|
+
Wait before capture:
|
|
87
|
+
```bash
|
|
88
|
+
slidev export --wait 2000
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
### Wait Until
|
|
92
|
+
|
|
93
|
+
Wait condition:
|
|
94
|
+
```bash
|
|
95
|
+
slidev export --wait-until networkidle # Default
|
|
96
|
+
slidev export --wait-until domcontentloaded
|
|
97
|
+
slidev export --wait-until load
|
|
98
|
+
slidev export --wait-until none
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
### Transparent Background
|
|
102
|
+
|
|
103
|
+
```bash
|
|
104
|
+
slidev export --omit-background
|
|
105
|
+
```
|
|
106
|
+
|
|
107
|
+
### Custom Browser
|
|
108
|
+
|
|
109
|
+
```bash
|
|
110
|
+
slidev export --executable-path /path/to/chrome
|
|
111
|
+
```
|
|
112
|
+
|
|
113
|
+
## Headmatter Options
|
|
114
|
+
|
|
115
|
+
```yaml
|
|
116
|
+
---
|
|
117
|
+
exportFilename: my-presentation
|
|
118
|
+
download: true # Add download button in build
|
|
119
|
+
export:
|
|
120
|
+
format: pdf
|
|
121
|
+
timeout: 30000
|
|
122
|
+
withClicks: false
|
|
123
|
+
---
|
|
124
|
+
```
|
|
125
|
+
|
|
126
|
+
## Troubleshooting
|
|
127
|
+
|
|
128
|
+
### Missing Content
|
|
129
|
+
|
|
130
|
+
Increase wait time:
|
|
131
|
+
```bash
|
|
132
|
+
slidev export --wait 3000 --timeout 60000
|
|
133
|
+
```
|
|
134
|
+
|
|
135
|
+
### Wrong Global Layer State
|
|
136
|
+
|
|
137
|
+
Use `--per-slide` or use `slide-top.vue` instead of `global-top.vue`.
|
|
138
|
+
|
|
139
|
+
### Broken Emojis
|
|
140
|
+
|
|
141
|
+
Use system fonts or install emoji font on server.
|
|
142
|
+
|
|
143
|
+
### CI/CD Export
|
|
144
|
+
|
|
145
|
+
Install playwright browsers:
|
|
146
|
+
```bash
|
|
147
|
+
npx playwright install chromium
|
|
148
|
+
```
|
|
@@ -0,0 +1,195 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: frontmatter
|
|
3
|
+
description: Configuration options for individual slides
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Per-Slide Frontmatter
|
|
7
|
+
|
|
8
|
+
Configuration options for individual slides.
|
|
9
|
+
|
|
10
|
+
## Layout
|
|
11
|
+
|
|
12
|
+
```yaml
|
|
13
|
+
---
|
|
14
|
+
layout: center
|
|
15
|
+
---
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
Available layouts: `default`, `cover`, `center`, `two-cols`, `two-cols-header`, `image`, `image-left`, `image-right`, `iframe`, `iframe-left`, `iframe-right`, `quote`, `section`, `statement`, `fact`, `full`, `intro`, `end`, `none`
|
|
19
|
+
|
|
20
|
+
## Background
|
|
21
|
+
|
|
22
|
+
```yaml
|
|
23
|
+
---
|
|
24
|
+
background: /image.jpg
|
|
25
|
+
backgroundSize: cover
|
|
26
|
+
class: text-white
|
|
27
|
+
---
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
## Click Count
|
|
31
|
+
|
|
32
|
+
```yaml
|
|
33
|
+
---
|
|
34
|
+
clicks: 5 # Total clicks for this slide
|
|
35
|
+
clicksStart: 0 # Starting click number
|
|
36
|
+
---
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
## Transitions
|
|
40
|
+
|
|
41
|
+
```yaml
|
|
42
|
+
---
|
|
43
|
+
transition: fade # Slide transition
|
|
44
|
+
---
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
Or different for forward/backward:
|
|
48
|
+
|
|
49
|
+
```yaml
|
|
50
|
+
---
|
|
51
|
+
transition: slide-left | slide-right
|
|
52
|
+
---
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
## Zoom
|
|
56
|
+
|
|
57
|
+
```yaml
|
|
58
|
+
---
|
|
59
|
+
zoom: 0.8 # Scale content (0.8 = 80%)
|
|
60
|
+
---
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
## Hide Slide
|
|
64
|
+
|
|
65
|
+
```yaml
|
|
66
|
+
---
|
|
67
|
+
disabled: true # Hide this slide
|
|
68
|
+
# or
|
|
69
|
+
hide: true
|
|
70
|
+
---
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
## Table of Contents
|
|
74
|
+
|
|
75
|
+
```yaml
|
|
76
|
+
---
|
|
77
|
+
hideInToc: true # Hide from Toc component
|
|
78
|
+
level: 2 # Override heading level
|
|
79
|
+
title: Custom Title # Override slide title
|
|
80
|
+
---
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
## Import External File
|
|
84
|
+
|
|
85
|
+
```yaml
|
|
86
|
+
---
|
|
87
|
+
src: ./slides/intro.md # Import markdown file
|
|
88
|
+
---
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
With specific slides:
|
|
92
|
+
|
|
93
|
+
```yaml
|
|
94
|
+
---
|
|
95
|
+
src: ./other.md#2,5-7 # Import slides 2, 5, 6, 7
|
|
96
|
+
---
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
## Route Alias
|
|
100
|
+
|
|
101
|
+
```yaml
|
|
102
|
+
---
|
|
103
|
+
routeAlias: intro # URL: /intro instead of /1
|
|
104
|
+
---
|
|
105
|
+
```
|
|
106
|
+
|
|
107
|
+
## Preload
|
|
108
|
+
|
|
109
|
+
```yaml
|
|
110
|
+
---
|
|
111
|
+
preload: false # Don't mount until entering
|
|
112
|
+
---
|
|
113
|
+
```
|
|
114
|
+
|
|
115
|
+
## Draggable Positions
|
|
116
|
+
|
|
117
|
+
```yaml
|
|
118
|
+
---
|
|
119
|
+
dragPos:
|
|
120
|
+
logo: 100,50,200,100,0 # Left,Top,Width,Height,Rotate
|
|
121
|
+
arrow: 300,200,50,50,45
|
|
122
|
+
---
|
|
123
|
+
```
|
|
124
|
+
|
|
125
|
+
## Image Layouts
|
|
126
|
+
|
|
127
|
+
```yaml
|
|
128
|
+
---
|
|
129
|
+
layout: image-left
|
|
130
|
+
image: /photo.jpg
|
|
131
|
+
backgroundSize: contain
|
|
132
|
+
class: my-custom-class
|
|
133
|
+
---
|
|
134
|
+
```
|
|
135
|
+
|
|
136
|
+
## Iframe Layouts
|
|
137
|
+
|
|
138
|
+
```yaml
|
|
139
|
+
---
|
|
140
|
+
layout: iframe
|
|
141
|
+
url: https://example.com
|
|
142
|
+
---
|
|
143
|
+
```
|
|
144
|
+
|
|
145
|
+
## Two Columns
|
|
146
|
+
|
|
147
|
+
```yaml
|
|
148
|
+
---
|
|
149
|
+
layout: two-cols
|
|
150
|
+
---
|
|
151
|
+
|
|
152
|
+
# Left Side
|
|
153
|
+
|
|
154
|
+
Content
|
|
155
|
+
|
|
156
|
+
::right::
|
|
157
|
+
|
|
158
|
+
# Right Side
|
|
159
|
+
|
|
160
|
+
Content
|
|
161
|
+
```
|
|
162
|
+
|
|
163
|
+
## Two Columns with Header
|
|
164
|
+
|
|
165
|
+
```yaml
|
|
166
|
+
---
|
|
167
|
+
layout: two-cols-header
|
|
168
|
+
---
|
|
169
|
+
|
|
170
|
+
# Header
|
|
171
|
+
|
|
172
|
+
::left::
|
|
173
|
+
|
|
174
|
+
Left content
|
|
175
|
+
|
|
176
|
+
::right::
|
|
177
|
+
|
|
178
|
+
Right content
|
|
179
|
+
```
|
|
180
|
+
|
|
181
|
+
## Full Example
|
|
182
|
+
|
|
183
|
+
```yaml
|
|
184
|
+
---
|
|
185
|
+
layout: center
|
|
186
|
+
background: /bg.jpg
|
|
187
|
+
class: text-white text-center
|
|
188
|
+
transition: fade
|
|
189
|
+
clicks: 3
|
|
190
|
+
zoom: 0.9
|
|
191
|
+
hideInToc: false
|
|
192
|
+
---
|
|
193
|
+
|
|
194
|
+
# Slide Content
|
|
195
|
+
```
|
|
@@ -0,0 +1,155 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: global-context
|
|
3
|
+
description: Access navigation, slide info, and configuration programmatically
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Global Context & API
|
|
7
|
+
|
|
8
|
+
Access navigation, slide info, and configuration programmatically.
|
|
9
|
+
|
|
10
|
+
## Template Variables
|
|
11
|
+
|
|
12
|
+
Available in slides and components:
|
|
13
|
+
|
|
14
|
+
```md
|
|
15
|
+
Page {{ $page }} of {{ $nav.total }}
|
|
16
|
+
Title: {{ $slidev.configs.title }}
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
### $nav
|
|
20
|
+
|
|
21
|
+
Navigation state and controls:
|
|
22
|
+
|
|
23
|
+
| Property | Type | Description |
|
|
24
|
+
|----------|------|-------------|
|
|
25
|
+
| `$nav.currentPage` | number | Current page (1-indexed) |
|
|
26
|
+
| `$nav.currentLayout` | string | Current layout name |
|
|
27
|
+
| `$nav.total` | number | Total slides |
|
|
28
|
+
| `$nav.isPresenter` | boolean | In presenter mode |
|
|
29
|
+
| `$nav.next()` | function | Next click/slide |
|
|
30
|
+
| `$nav.prev()` | function | Previous click/slide |
|
|
31
|
+
| `$nav.nextSlide()` | function | Next slide |
|
|
32
|
+
| `$nav.prevSlide()` | function | Previous slide |
|
|
33
|
+
| `$nav.go(n)` | function | Go to slide n |
|
|
34
|
+
|
|
35
|
+
### $slidev
|
|
36
|
+
|
|
37
|
+
Global context:
|
|
38
|
+
|
|
39
|
+
| Property | Description |
|
|
40
|
+
|----------|-------------|
|
|
41
|
+
| `$slidev.configs` | Project config (title, etc.) |
|
|
42
|
+
| `$slidev.themeConfigs` | Theme config |
|
|
43
|
+
|
|
44
|
+
### $frontmatter
|
|
45
|
+
|
|
46
|
+
Current slide frontmatter:
|
|
47
|
+
|
|
48
|
+
```md
|
|
49
|
+
Layout: {{ $frontmatter.layout }}
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
### $clicks
|
|
53
|
+
|
|
54
|
+
Current click count on slide.
|
|
55
|
+
|
|
56
|
+
### $page
|
|
57
|
+
|
|
58
|
+
Current page number (1-indexed).
|
|
59
|
+
|
|
60
|
+
### $renderContext
|
|
61
|
+
|
|
62
|
+
Current render context:
|
|
63
|
+
- `'slide'` - Normal slide view
|
|
64
|
+
- `'overview'` - Overview mode
|
|
65
|
+
- `'presenter'` - Presenter mode
|
|
66
|
+
- `'previewNext'` - Next slide preview
|
|
67
|
+
|
|
68
|
+
## Composables
|
|
69
|
+
|
|
70
|
+
Import from `@slidev/client`:
|
|
71
|
+
|
|
72
|
+
```ts
|
|
73
|
+
import {
|
|
74
|
+
useNav,
|
|
75
|
+
useDarkMode,
|
|
76
|
+
useIsSlideActive,
|
|
77
|
+
useSlideContext,
|
|
78
|
+
onSlideEnter,
|
|
79
|
+
onSlideLeave,
|
|
80
|
+
} from '@slidev/client'
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
### useNav
|
|
84
|
+
|
|
85
|
+
```ts
|
|
86
|
+
const nav = useNav()
|
|
87
|
+
nav.next()
|
|
88
|
+
nav.go(5)
|
|
89
|
+
console.log(nav.currentPage)
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
### useDarkMode
|
|
93
|
+
|
|
94
|
+
```ts
|
|
95
|
+
const { isDark, toggle } = useDarkMode()
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
### useIsSlideActive
|
|
99
|
+
|
|
100
|
+
```ts
|
|
101
|
+
const isActive = useIsSlideActive()
|
|
102
|
+
// Returns ref<boolean>
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
### useSlideContext
|
|
106
|
+
|
|
107
|
+
```ts
|
|
108
|
+
const { $page, $clicks, $frontmatter } = useSlideContext()
|
|
109
|
+
```
|
|
110
|
+
|
|
111
|
+
## Lifecycle Hooks
|
|
112
|
+
|
|
113
|
+
```ts
|
|
114
|
+
import { onSlideEnter, onSlideLeave } from '@slidev/client'
|
|
115
|
+
|
|
116
|
+
onSlideEnter(() => {
|
|
117
|
+
// Slide became active
|
|
118
|
+
startAnimation()
|
|
119
|
+
})
|
|
120
|
+
|
|
121
|
+
onSlideLeave(() => {
|
|
122
|
+
// Slide became inactive
|
|
123
|
+
cleanup()
|
|
124
|
+
})
|
|
125
|
+
```
|
|
126
|
+
|
|
127
|
+
**Important:** Don't use `onMounted`/`onUnmounted` in slides - component instance persists. Use `onSlideEnter`/`onSlideLeave` instead.
|
|
128
|
+
|
|
129
|
+
## Conditional Rendering Examples
|
|
130
|
+
|
|
131
|
+
```html
|
|
132
|
+
<!-- Show only in presenter mode -->
|
|
133
|
+
<div v-if="$nav.isPresenter">
|
|
134
|
+
Presenter notes
|
|
135
|
+
</div>
|
|
136
|
+
|
|
137
|
+
<!-- Hide on cover slide -->
|
|
138
|
+
<footer v-if="$nav.currentLayout !== 'cover'">
|
|
139
|
+
Page {{ $nav.currentPage }}
|
|
140
|
+
</footer>
|
|
141
|
+
|
|
142
|
+
<!-- Different content by context -->
|
|
143
|
+
<template v-if="$renderContext === 'slide'">
|
|
144
|
+
Normal view
|
|
145
|
+
</template>
|
|
146
|
+
<template v-else-if="$renderContext === 'presenter'">
|
|
147
|
+
Presenter view
|
|
148
|
+
</template>
|
|
149
|
+
```
|
|
150
|
+
|
|
151
|
+
## Type Imports
|
|
152
|
+
|
|
153
|
+
```ts
|
|
154
|
+
import type { TocItem } from '@slidev/types'
|
|
155
|
+
```
|