@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
package/guide/hosting.md
ADDED
|
@@ -0,0 +1,220 @@
|
|
|
1
|
+
---
|
|
2
|
+
outline: deep
|
|
3
|
+
---
|
|
4
|
+
|
|
5
|
+
# Building and Hosting
|
|
6
|
+
|
|
7
|
+
Slidev is designed to run as a web server when you are editing or presenting your slides. However, after the presentation, you may still want to share your **interactive** slides with others. This guide will show you how to build and host your slides.
|
|
8
|
+
|
|
9
|
+
## Build as a SPA {#spa}
|
|
10
|
+
|
|
11
|
+
You can build the slides into a static [Single-page application (SPA)](https://developer.mozilla.org/en-US/docs/Glossary/SPA) via the following command:
|
|
12
|
+
|
|
13
|
+
```bash
|
|
14
|
+
$ slidev build
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
By default, the generated files are placed in the `dist` folder. You can test the built version of you slides by running: `npx vite preview` or any other static server.
|
|
18
|
+
|
|
19
|
+
### Base Path {#base}
|
|
20
|
+
|
|
21
|
+
To deploy your slides under sub-routes, you need to pass the `--base` option. The `--base` path **must begin and end with a slash `/`**. For example:
|
|
22
|
+
|
|
23
|
+
```bash
|
|
24
|
+
$ slidev build --base /talks/my-cool-talk/
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
Refer to [Vite's documentation](https://vitejs.dev/guide/build.html#public-base-path) for more details.
|
|
28
|
+
|
|
29
|
+
### Output directory {#output-directory}
|
|
30
|
+
|
|
31
|
+
You can change the output directory using `--out`.
|
|
32
|
+
|
|
33
|
+
```bash
|
|
34
|
+
$ slidev build --out my-build-folder
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
### Multiple Builds {#multiple-builds}
|
|
38
|
+
|
|
39
|
+
You can build multiple slide decks in one go by passing multiple markdown files as arguments:
|
|
40
|
+
|
|
41
|
+
```bash
|
|
42
|
+
$ slidev build slides1.md slides2.md
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
Or if your shell supports it, you can use a glob pattern:
|
|
46
|
+
|
|
47
|
+
```bash
|
|
48
|
+
$ slidev build *.md
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
In this case, each input file will generate a folder containing the build in the output directory.
|
|
52
|
+
|
|
53
|
+
### Examples {#examples}
|
|
54
|
+
|
|
55
|
+
Here are a few examples of the exported SPA:
|
|
56
|
+
|
|
57
|
+
- [Demo Slides](https://sli.dev/demo/starter)
|
|
58
|
+
- [Composable Vue](https://talks.antfu.me/2021/composable-vue) by [Anthony Fu](https://github.com/antfu)
|
|
59
|
+
- More in [Showcases](../resources/showcases)
|
|
60
|
+
|
|
61
|
+
### Options {#options}
|
|
62
|
+
|
|
63
|
+
<LinkCard link="features/build-with-pdf" />
|
|
64
|
+
<LinkCard link="features/bundle-remote-assets" />
|
|
65
|
+
|
|
66
|
+
## Hosting {#hosting}
|
|
67
|
+
|
|
68
|
+
We recommend using `npm init slidev@latest` to scaffold your project, which contains the necessary configuration files for hosting services out-of-the-box.
|
|
69
|
+
|
|
70
|
+
### GitHub Pages {#github-pages}
|
|
71
|
+
|
|
72
|
+
To deploy your slides on [GitHub Pages](https://pages.github.com/) via GitHub Actions, follow these steps:
|
|
73
|
+
|
|
74
|
+
1. In your repository, go to `Settings` > `Pages`. Under `Build and deployment`, select `GitHub Actions`. (Do not choose `Deploy from a branch` and upload the `dist` directory, which is not recommended.)
|
|
75
|
+
2. Create `.github/workflows/deploy.yml` with the following content to deploy your slides to GitHub Pages via GitHub Actions.
|
|
76
|
+
|
|
77
|
+
::: details deploy.yml
|
|
78
|
+
|
|
79
|
+
```yaml
|
|
80
|
+
name: Deploy pages
|
|
81
|
+
|
|
82
|
+
on:
|
|
83
|
+
workflow_dispatch:
|
|
84
|
+
push:
|
|
85
|
+
branches: [main]
|
|
86
|
+
|
|
87
|
+
permissions:
|
|
88
|
+
contents: read
|
|
89
|
+
pages: write
|
|
90
|
+
id-token: write
|
|
91
|
+
|
|
92
|
+
concurrency:
|
|
93
|
+
group: pages
|
|
94
|
+
cancel-in-progress: false
|
|
95
|
+
|
|
96
|
+
jobs:
|
|
97
|
+
build:
|
|
98
|
+
runs-on: ubuntu-latest
|
|
99
|
+
|
|
100
|
+
steps:
|
|
101
|
+
- uses: actions/checkout@v4
|
|
102
|
+
|
|
103
|
+
- uses: actions/setup-node@v4
|
|
104
|
+
with:
|
|
105
|
+
node-version: 'lts/*'
|
|
106
|
+
|
|
107
|
+
- name: Setup @antfu/ni
|
|
108
|
+
run: npm i -g @antfu/ni
|
|
109
|
+
|
|
110
|
+
- name: Install dependencies
|
|
111
|
+
run: nci
|
|
112
|
+
|
|
113
|
+
- name: Build
|
|
114
|
+
run: nr build --base /${{github.event.repository.name}}/
|
|
115
|
+
|
|
116
|
+
- name: Setup Pages
|
|
117
|
+
uses: actions/configure-pages@v4
|
|
118
|
+
|
|
119
|
+
- uses: actions/upload-pages-artifact@v3
|
|
120
|
+
with:
|
|
121
|
+
path: dist
|
|
122
|
+
|
|
123
|
+
deploy:
|
|
124
|
+
environment:
|
|
125
|
+
name: github-pages
|
|
126
|
+
url: ${{ steps.deployment.outputs.page_url }}
|
|
127
|
+
needs: build
|
|
128
|
+
runs-on: ubuntu-latest
|
|
129
|
+
name: Deploy
|
|
130
|
+
steps:
|
|
131
|
+
- name: Deploy to GitHub Pages
|
|
132
|
+
id: deployment
|
|
133
|
+
uses: actions/deploy-pages@v4
|
|
134
|
+
```
|
|
135
|
+
|
|
136
|
+
:::
|
|
137
|
+
|
|
138
|
+
3. Commit and push the changes to your repository. The GitHub Actions workflow will automatically deploy your slides to GitHub Pages every time you push to the `main` branch.
|
|
139
|
+
4. You can access your slides at `https://<username>.github.io/<repository-name>/`.
|
|
140
|
+
|
|
141
|
+
### Netlify
|
|
142
|
+
|
|
143
|
+
Create `netlify.toml` in your project root with the following content:
|
|
144
|
+
|
|
145
|
+
::: details netlify.toml
|
|
146
|
+
|
|
147
|
+
```toml
|
|
148
|
+
[build]
|
|
149
|
+
publish = 'dist'
|
|
150
|
+
command = 'npm run build'
|
|
151
|
+
|
|
152
|
+
[build.environment]
|
|
153
|
+
NODE_VERSION = '20'
|
|
154
|
+
|
|
155
|
+
[[redirects]]
|
|
156
|
+
from = '/*'
|
|
157
|
+
to = '/index.html'
|
|
158
|
+
status = 200
|
|
159
|
+
```
|
|
160
|
+
|
|
161
|
+
:::
|
|
162
|
+
|
|
163
|
+
Then go to your [Netlify dashboard](https://netlify.com/) and create a new site with the repository.
|
|
164
|
+
|
|
165
|
+
### Vercel
|
|
166
|
+
|
|
167
|
+
Create `vercel.json` in your project root with the following content:
|
|
168
|
+
|
|
169
|
+
::: details vercel.json
|
|
170
|
+
|
|
171
|
+
```json
|
|
172
|
+
{
|
|
173
|
+
"rewrites": [
|
|
174
|
+
{ "source": "/(.*)", "destination": "/index.html" }
|
|
175
|
+
]
|
|
176
|
+
}
|
|
177
|
+
```
|
|
178
|
+
|
|
179
|
+
:::
|
|
180
|
+
|
|
181
|
+
Then go to your [Vercel dashboard](https://vercel.com/) and create a new site with the repository.
|
|
182
|
+
|
|
183
|
+
### Host on Docker {#docker}
|
|
184
|
+
|
|
185
|
+
If you need a rapid way to run a presentation with containers, you can use the prebuilt [docker image](https://hub.docker.com/r/tangramor/slidev) maintained by [tangramor](https://github.com/tangramor), or build your own.
|
|
186
|
+
|
|
187
|
+
::: details Use the Docker Image
|
|
188
|
+
|
|
189
|
+
Just run the following command in your work folder:
|
|
190
|
+
|
|
191
|
+
```bash
|
|
192
|
+
docker run --name slidev --rm -it \
|
|
193
|
+
--user node \
|
|
194
|
+
-v ${PWD}:/slidev \
|
|
195
|
+
-p 3030:3030 \
|
|
196
|
+
-e NPM_MIRROR="https://registry.npmmirror.com" \
|
|
197
|
+
tangramor/slidev:latest
|
|
198
|
+
```
|
|
199
|
+
|
|
200
|
+
**_Note_**: You can use `NPM_MIRROR` to specify a npm mirror to speed up the installation process.
|
|
201
|
+
|
|
202
|
+
If your work folder is empty, it will generate a template `slides.md` and other related files under your work folder, and launch the server on port `3030`.
|
|
203
|
+
|
|
204
|
+
You can access your slides from `http://localhost:3030/`
|
|
205
|
+
|
|
206
|
+
To create an Docker Image for your slides, you can use the following Dockerfile:
|
|
207
|
+
|
|
208
|
+
```Dockerfile
|
|
209
|
+
FROM tangramor/slidev:latest
|
|
210
|
+
|
|
211
|
+
ADD . /slidev
|
|
212
|
+
```
|
|
213
|
+
|
|
214
|
+
Create the docker image: `docker build -t myslides .`
|
|
215
|
+
|
|
216
|
+
And run the container: `docker run --name myslides --rm --user node -p 3030:3030 myslides`
|
|
217
|
+
|
|
218
|
+
You can visit your slides at `http://localhost:3030/`
|
|
219
|
+
|
|
220
|
+
:::
|
package/guide/index.md
ADDED
|
@@ -0,0 +1,161 @@
|
|
|
1
|
+
---
|
|
2
|
+
outline: deep
|
|
3
|
+
---
|
|
4
|
+
|
|
5
|
+
# Getting Started
|
|
6
|
+
|
|
7
|
+
Slidev <sup>(slide + dev, **/slaɪdɪv/**)</sup> is a web-based slides maker and presenter. It's designed for developers to focus on writing content in Markdown. With the power of web technologies like Vue, you are able to deliver pixel-perfect designs with interactive demos to your presentation.
|
|
8
|
+
|
|
9
|
+
::: tip
|
|
10
|
+
|
|
11
|
+
You can learn more about the rationale behind this project in <LinkInline link="guide/why" />.
|
|
12
|
+
|
|
13
|
+
:::
|
|
14
|
+
|
|
15
|
+
<!--
|
|
16
|
+
- 📝 [**Markdown-based**](/guide/syntax) - focus on content and use your favorite editor
|
|
17
|
+
- 🧑💻 [**Developer Friendly**](/guide/syntax#code-blocks) - built-in code highlighting, live coding, etc.
|
|
18
|
+
- 🎨 [**Themable**](/resources/theme-gallery) - theme can be shared and used with npm packages
|
|
19
|
+
- 🌈 [**Stylish**](/guide/syntax#embedded-styles) - on-demand utilities via [UnoCSS](https://github.com/unocss/unocss).
|
|
20
|
+
- 🤹 [**Interactive**](/custom/directory-structure#components) - embedding Vue components seamlessly
|
|
21
|
+
- 🎙 [**Presenter Mode**](/guide/ui#presenter-mode) - use another window, or even your phone to control your slides
|
|
22
|
+
- 🎨 [**Drawing**](/features/drawing) - draw and annotate on your slides
|
|
23
|
+
- 🧮 [**LaTeX**](/guide/syntax#latex) - built-in LaTeX math equations support
|
|
24
|
+
- 📰 [**Diagrams**](/guide/syntax#diagrams) - creates diagrams using textual descriptions with [Mermaid.js](https://mermaid.js.org/)
|
|
25
|
+
- 🌟 [**Icons**](/guide/syntax#icons) - access to icons from any icon set directly
|
|
26
|
+
- 💻 [**Editor**](/guide/index#editor) - integrated editor, or the [VSCode extension](/features/vscode-extension)
|
|
27
|
+
- 🎥 [**Recording**](/features/recording) - built-in recording and camera view
|
|
28
|
+
- 📤 [**Portable**](/guide/exporting) - export into PDF, PNGs, or PPTX
|
|
29
|
+
- ⚡️ [**Fast**](https://vitejs.dev) - instant reloading powered by [Vite](https://vitejs.dev)
|
|
30
|
+
- 🛠 [**Hackable**](/custom/) - using Vite plugins, Vue components, or any npm packages
|
|
31
|
+
-->
|
|
32
|
+
|
|
33
|
+
<!-- <FeaturesAnimation /> -->
|
|
34
|
+
|
|
35
|
+
## Create Slides
|
|
36
|
+
|
|
37
|
+
### Try it Online
|
|
38
|
+
|
|
39
|
+
Start Slidev right in your browser with StackBlitz: [sli.dev/new](https://sli.dev/new)
|
|
40
|
+
|
|
41
|
+
### Create Locally
|
|
42
|
+
|
|
43
|
+
> Requires [Node.js](https://nodejs.org) >= 18.0 installed.
|
|
44
|
+
|
|
45
|
+
Run the following command to create a new Slidev project locally:
|
|
46
|
+
|
|
47
|
+
::: code-group
|
|
48
|
+
|
|
49
|
+
```bash [pnpm]
|
|
50
|
+
# If you haven't installed pnpm
|
|
51
|
+
npm i -g pnpm
|
|
52
|
+
|
|
53
|
+
pnpm create slidev
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
```bash [npm]
|
|
57
|
+
# Not recommended -
|
|
58
|
+
# NPM will download the packages each time you create a new project,
|
|
59
|
+
# which is slow and takes up a lot of space
|
|
60
|
+
|
|
61
|
+
npm init slidev@latest
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
```bash [yarn]
|
|
65
|
+
yarn create slidev
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
```bash [bun]
|
|
69
|
+
bun create slidev
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
:::
|
|
73
|
+
|
|
74
|
+
Follow the prompts to start your slides project. The slides content is in `slides.md`, which initially includes demos of most the Slidev features. For more information about the Markdown syntax, please check <LinkInline link="guide/syntax" />.
|
|
75
|
+
|
|
76
|
+
:::: details Single file usage (not recommended)
|
|
77
|
+
|
|
78
|
+
If you prefer to have a single Markdown file as your slides, you can install the Slidev CLI globally:
|
|
79
|
+
|
|
80
|
+
::: code-group
|
|
81
|
+
|
|
82
|
+
```bash [pnpm]
|
|
83
|
+
pnpm i -g @slidev/cli
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
```bash [npm]
|
|
87
|
+
npm i -g @slidev/cli
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
```bash [yarn]
|
|
91
|
+
yarn global add @slidev/cli
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
```bash [bun]
|
|
95
|
+
bun i -g @slidev/cli
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
:::
|
|
99
|
+
|
|
100
|
+
Then, you can create and start a single file slides via:
|
|
101
|
+
|
|
102
|
+
```bash
|
|
103
|
+
slidev slides.md
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
::::
|
|
107
|
+
|
|
108
|
+
## Basic Commands
|
|
109
|
+
|
|
110
|
+
Slidev provides a set of commands in its CLI. Here are some common ones:
|
|
111
|
+
|
|
112
|
+
- `slidev` - Start the dev server. See [the dev command](../builtin/cli#dev).
|
|
113
|
+
- `slidev export` - Export the slides to PDF, PPTX, or PNGs. See <LinkInline link="guide/exporting" />.
|
|
114
|
+
- `slidev build` - Build the slides as a static web application. See <LinkInline link="guide/hosting" />.
|
|
115
|
+
- `slidev format` - Format the slides. See [the format command](../builtin/cli#format).
|
|
116
|
+
- `slidev --help` - Show the help message
|
|
117
|
+
|
|
118
|
+
To run these commands, you can add them to your `package.json` scripts (which has been done for you if the project was created via `npm init slidev`):
|
|
119
|
+
|
|
120
|
+
```json
|
|
121
|
+
{
|
|
122
|
+
"scripts": {
|
|
123
|
+
"dev": "slidev --open",
|
|
124
|
+
"build": "slidev build",
|
|
125
|
+
"export": "slidev export"
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
```
|
|
129
|
+
|
|
130
|
+
Then, you can simply run `npm run dev`, `npm run build`, and `npm run export`.
|
|
131
|
+
|
|
132
|
+
For more information about the CLI, please check the [CLI guide](../builtin/cli).
|
|
133
|
+
|
|
134
|
+
## Setup Your Editor {#editor}
|
|
135
|
+
|
|
136
|
+
Since Slidev uses Markdown as the source entry, you can use any editor you prefer to create your slides. We also provide tools to help you edit you slides more conveniently:
|
|
137
|
+
|
|
138
|
+
<LinkCard link="features/vscode-extension" />
|
|
139
|
+
<LinkCard link="features/side-editor" />
|
|
140
|
+
<LinkCard link="features/prettier-plugin" />
|
|
141
|
+
|
|
142
|
+
## Join the Community
|
|
143
|
+
|
|
144
|
+
It's recommended to join our official [Discord Server](https://chat.sli.dev/) to get help, share your slides, or discuss anything about Slidev.
|
|
145
|
+
|
|
146
|
+
If you're encountering bugs, feel free to open an issue on [GitHub](https://github.com/slidevjs/slidev/issues/new/choose).
|
|
147
|
+
|
|
148
|
+
## Tech Stack
|
|
149
|
+
|
|
150
|
+
Slidev is made possible by combining these tools and technologies.
|
|
151
|
+
|
|
152
|
+
- [Vite](https://vitejs.dev) - An extremely fast frontend tooling
|
|
153
|
+
- [Vue 3](https://v3.vuejs.org/) powered [Markdown](https://daringfireball.net/projects/markdown/syntax) - Focus on the content while having the power of HTML and Vue components whenever needed
|
|
154
|
+
- [UnoCSS](https://github.com/unocss/unocss) - On-demand utility-first CSS framework, style your slides at ease
|
|
155
|
+
- [Shiki](https://github.com/shikijs/shiki), [Monaco Editor](https://github.com/Microsoft/monaco-editor) - First-class code snippets support with live coding capability
|
|
156
|
+
- [RecordRTC](https://recordrtc.org) - Built-in recording and camera view
|
|
157
|
+
- [VueUse](https://vueuse.org) family - [`@vueuse/core`](https://github.com/vueuse/vueuse), [`@vueuse/head`](https://github.com/vueuse/head), [`@vueuse/motion`](https://github.com/vueuse/motion), etc.
|
|
158
|
+
- [Iconify](https://iconify.design/) - Iconsets collection.
|
|
159
|
+
- [Drauu](https://github.com/antfu/drauu) - Drawing and annotations support
|
|
160
|
+
- [KaTeX](https://katex.org/) - LaTeX math rendering.
|
|
161
|
+
- [Mermaid](https://mermaid-js.github.io/mermaid) - Textual Diagrams.
|
package/guide/layout.md
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
# Slide Layout
|
|
2
|
+
|
|
3
|
+
Layouts in Slidev are used to define the structure for each slides. They are Vue components that wrap the content of the slides.
|
|
4
|
+
|
|
5
|
+
## Using Layouts {#use}
|
|
6
|
+
|
|
7
|
+
To use a layout, you can specify it in the frontmatter of the slide:
|
|
8
|
+
|
|
9
|
+
```md
|
|
10
|
+
---
|
|
11
|
+
layout: quote
|
|
12
|
+
---
|
|
13
|
+
|
|
14
|
+
A quote from someone
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
By default, the layout of the first slide is `cover`, and the rest are `default`.
|
|
18
|
+
|
|
19
|
+
The layouts are loaded in the following order, and the last one loaded will override the previous ones:
|
|
20
|
+
|
|
21
|
+
1. default layouts. See [Built-in Layouts](../builtin/layouts).
|
|
22
|
+
2. layouts provided by the theme
|
|
23
|
+
3. layouts provided by the addons
|
|
24
|
+
4. custom layouts in the `layouts` directory
|
|
25
|
+
|
|
26
|
+
<SeeAlso :links="[
|
|
27
|
+
'features/slot-sugar',
|
|
28
|
+
]" />
|
|
29
|
+
|
|
30
|
+
## Writing Layouts {#write}
|
|
31
|
+
|
|
32
|
+
<LinkCard link="guide/write-layout" />
|
package/guide/syntax.md
ADDED
|
@@ -0,0 +1,179 @@
|
|
|
1
|
+
---
|
|
2
|
+
outline: deep
|
|
3
|
+
---
|
|
4
|
+
|
|
5
|
+
# Syntax Guide
|
|
6
|
+
|
|
7
|
+
Slidev's slides are written as Markdown files, which are called **Slidev Markdown**s. A presentation has a Slidev Markdown as its entry, which is `./slides.md` by default, but you can change it by passing the file path as an argument to [the CLI commands](../builtin/cli).
|
|
8
|
+
|
|
9
|
+
In a Slidev Markdown, not only [the basic Markdown features](https://github.com/adam-p/markdown-here/wiki/Markdown-Cheatsheet) can be used as usual, Slidev also provides additional features to enhance your slides. This section covers the syntax introduced by Slidev. Please make sure you know the basic Markdown syntax before reading this guide.
|
|
10
|
+
|
|
11
|
+
## Slide Separators {#slide-separators}
|
|
12
|
+
|
|
13
|
+
Use `---` padded with a new line to separate your slides.
|
|
14
|
+
|
|
15
|
+
````md {5,15}
|
|
16
|
+
# Title
|
|
17
|
+
|
|
18
|
+
Hello, **Slidev**!
|
|
19
|
+
|
|
20
|
+
---
|
|
21
|
+
|
|
22
|
+
# Slide 2
|
|
23
|
+
|
|
24
|
+
Use code blocks for highlighting:
|
|
25
|
+
|
|
26
|
+
```ts
|
|
27
|
+
console.log('Hello, World!')
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
---
|
|
31
|
+
|
|
32
|
+
# Slide 3
|
|
33
|
+
|
|
34
|
+
Use UnoCSS classes and Vue components to style and enrich your slides:
|
|
35
|
+
|
|
36
|
+
<div class="p-3">
|
|
37
|
+
<Tweet id="..." />
|
|
38
|
+
</div>
|
|
39
|
+
````
|
|
40
|
+
|
|
41
|
+
## Frontmatter & Headmatter {#frontmatter}
|
|
42
|
+
|
|
43
|
+
At the beginning of each slide, you can add an optional [frontmatter](https://jekyllrb.com/docs/front-matter/) to configure the slide. The first frontmatter block is called **headmatter** and can configure the whole slide deck. The rest are **frontmatters** for individual slides. Texts in the headmatter or the frontmatter should be an object in [YAML](https://www.cloudbees.com/blog/yaml-tutorial-everything-you-need-get-started/) format. For example:
|
|
44
|
+
|
|
45
|
+
<!-- eslint-skip -->
|
|
46
|
+
|
|
47
|
+
```md {1-4,10-14,26-28}
|
|
48
|
+
---
|
|
49
|
+
theme: seriph
|
|
50
|
+
title: Welcome to Slidev
|
|
51
|
+
---
|
|
52
|
+
|
|
53
|
+
# Slide 1
|
|
54
|
+
|
|
55
|
+
The frontmatter of this slide is also the headmatter
|
|
56
|
+
|
|
57
|
+
---
|
|
58
|
+
layout: center
|
|
59
|
+
background: /background-1.png
|
|
60
|
+
class: text-white
|
|
61
|
+
---
|
|
62
|
+
|
|
63
|
+
# Slide 2
|
|
64
|
+
|
|
65
|
+
A page with the layout `center` and a background image
|
|
66
|
+
|
|
67
|
+
---
|
|
68
|
+
|
|
69
|
+
# Slide 3
|
|
70
|
+
|
|
71
|
+
A page without frontmatter
|
|
72
|
+
|
|
73
|
+
---
|
|
74
|
+
src: ./pages/4.md # This slide only contains a frontmatter
|
|
75
|
+
---
|
|
76
|
+
|
|
77
|
+
---
|
|
78
|
+
|
|
79
|
+
# Slide 5
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
Configurations you can set are described in the [Slides deck configurations](/custom/#headmatter) and [Per slide configurations](/custom/#frontmatter) sections.
|
|
83
|
+
|
|
84
|
+
To make the headmatter more readable, you can install the VSCode extension:
|
|
85
|
+
|
|
86
|
+
<LinkCard link="features/vscode-extension" />
|
|
87
|
+
|
|
88
|
+
Also, there is another possible frontmatter format:
|
|
89
|
+
|
|
90
|
+
<LinkCard link="features/block-frontmatter" />
|
|
91
|
+
|
|
92
|
+
## Notes {#notes}
|
|
93
|
+
|
|
94
|
+
You can also create presenter notes for each slide. They will show up in <LinkInline link="guide/ui#presenter-mode" /> for you to reference during presentations.
|
|
95
|
+
|
|
96
|
+
The comment blocks at the end of each slide are treated as the note of the slide:
|
|
97
|
+
|
|
98
|
+
```md {9,19-21}
|
|
99
|
+
---
|
|
100
|
+
layout: cover
|
|
101
|
+
---
|
|
102
|
+
|
|
103
|
+
# Slide 1
|
|
104
|
+
|
|
105
|
+
This is the cover page.
|
|
106
|
+
|
|
107
|
+
<!-- This is a **note** -->
|
|
108
|
+
|
|
109
|
+
---
|
|
110
|
+
|
|
111
|
+
# Slide 2
|
|
112
|
+
|
|
113
|
+
<!-- This is NOT a note because it is not at the end of the slide -->
|
|
114
|
+
|
|
115
|
+
The second page
|
|
116
|
+
|
|
117
|
+
<!--
|
|
118
|
+
This is _another_ note
|
|
119
|
+
-->
|
|
120
|
+
```
|
|
121
|
+
|
|
122
|
+
Basic Markdown and HTML are also supported in notes and will be rendered.
|
|
123
|
+
|
|
124
|
+
<SeeAlso :links="[
|
|
125
|
+
'features/click-marker',
|
|
126
|
+
]" />
|
|
127
|
+
|
|
128
|
+
## Code Blocks {#code-block}
|
|
129
|
+
|
|
130
|
+
One big reason that led to the creation of Slidev was the need to perfectly display code in slides. Consequently, you can use Markdown-flavored code blocks to highlight your code.
|
|
131
|
+
|
|
132
|
+
````md
|
|
133
|
+
```ts
|
|
134
|
+
console.log('Hello, World!')
|
|
135
|
+
```
|
|
136
|
+
````
|
|
137
|
+
|
|
138
|
+
Slidev has [Shiki](https://github.com/shikijs/shiki) built in as the syntax highlighter. Refer to [Configure Shiki](/custom/config-highlighter) for more details.
|
|
139
|
+
|
|
140
|
+
More about code blocks:
|
|
141
|
+
|
|
142
|
+
<LinkCard link="features/code-block-line-numbers" />
|
|
143
|
+
<LinkCard link="features/code-block-max-height" />
|
|
144
|
+
<LinkCard link="features/line-highlighting" />
|
|
145
|
+
<LinkCard link="features/monaco-editor" />
|
|
146
|
+
<LinkCard link="features/monaco-run" />
|
|
147
|
+
<LinkCard link="features/monaco-write" />
|
|
148
|
+
<LinkCard link="features/shiki-magic-move" />
|
|
149
|
+
<LinkCard link="features/twoslash" />
|
|
150
|
+
<LinkCard link="features/import-snippet" />
|
|
151
|
+
|
|
152
|
+
## LaTeX Blocks {#latex-block}
|
|
153
|
+
|
|
154
|
+
Slidev supports LaTeX blocks for mathematical and chemical formulas:
|
|
155
|
+
|
|
156
|
+
<LinkCard link="features/latex" />
|
|
157
|
+
|
|
158
|
+
## Diagrams {#diagrams}
|
|
159
|
+
|
|
160
|
+
Slidev supports [Mermaid](https://mermaid.js.org/) and [PlantUML](https://plantuml.com/) for creating diagrams from text:
|
|
161
|
+
|
|
162
|
+
<LinkCard link="features/mermaid" />
|
|
163
|
+
<LinkCard link="features/plantuml" />
|
|
164
|
+
|
|
165
|
+
## MDC Syntax {#mdc-syntax}
|
|
166
|
+
|
|
167
|
+
MDC Syntax is the easiest way to apply styles and classes to elements:
|
|
168
|
+
|
|
169
|
+
<LinkCard link="features/mdc" />
|
|
170
|
+
|
|
171
|
+
## Scoped CSS {#scoped-css}
|
|
172
|
+
|
|
173
|
+
You can use scoped CSS to style your slides:
|
|
174
|
+
|
|
175
|
+
<LinkCard link="features/slide-scope-style" />
|
|
176
|
+
|
|
177
|
+
## Importing Slides {#importing-slides}
|
|
178
|
+
|
|
179
|
+
<LinkCard link="features/importing-slides" />
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
# Theme and Addons
|
|
2
|
+
|
|
3
|
+
A slides project can have one theme and multiple addons. All of them can provide styles, components, layouts, and other configs to your slides project.
|
|
4
|
+
|
|
5
|
+
## Use a Theme {#use-theme}
|
|
6
|
+
|
|
7
|
+
Changing the theme in Slidev is surprisingly easy. All you need to do is to add the `theme` option in your [headmatter](../custom/index#headmatter):
|
|
8
|
+
|
|
9
|
+
```md
|
|
10
|
+
---
|
|
11
|
+
theme: seriph
|
|
12
|
+
---
|
|
13
|
+
|
|
14
|
+
# The first slide
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
You can find the list of official themes and community themes in the [Themes Gallery](../resources/theme-gallery).
|
|
18
|
+
|
|
19
|
+
::: info Theme name convention
|
|
20
|
+
|
|
21
|
+
- You can also pass a relative or absolute path to a local theme folder, like `../my-theme`
|
|
22
|
+
- You can always use the full package name as the theme name
|
|
23
|
+
- If the theme is [official](../resources/theme-gallery#official-themes) or is named like `slidev-theme-name`, you can omit the `slidev-theme-` prefix
|
|
24
|
+
- For scoped packages like `@org/slidev-theme-name`, the full package name is required
|
|
25
|
+
|
|
26
|
+
:::
|
|
27
|
+
|
|
28
|
+
You can start the server and will be prompted to install the theme after a confirmation.
|
|
29
|
+
|
|
30
|
+
<div class="language-md text-xs pl-6">
|
|
31
|
+
<pre style="overflow: hidden; text-wrap: pretty;">
|
|
32
|
+
<span class="token keyword">?</span> The theme <span class="token string">"@slidev/theme-seriph"</span> was not found in your project, do you want to install it now? › (Y/n)
|
|
33
|
+
</pre>
|
|
34
|
+
</div>
|
|
35
|
+
|
|
36
|
+
or install the theme manually via:
|
|
37
|
+
|
|
38
|
+
```bash
|
|
39
|
+
$ npm install @slidev/theme-seriph
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
And that's all, enjoy the new theme! For more details about the usage, you can refer to the theme's README.
|
|
43
|
+
|
|
44
|
+
<SeeAlso :links="[
|
|
45
|
+
'features/eject-theme',
|
|
46
|
+
]" />
|
|
47
|
+
|
|
48
|
+
## Use an Addon {#use-addon}
|
|
49
|
+
|
|
50
|
+
Addons are similar to themes, but they are more flexible and can be used to add extra features to your slides project. You can add multiple addons to your project, and they can be used to add extra features to your slides project.
|
|
51
|
+
|
|
52
|
+
To use an addon, you can add the `addons` option in your [headmatter](../custom/index#headmatter):
|
|
53
|
+
|
|
54
|
+
```md
|
|
55
|
+
---
|
|
56
|
+
addons:
|
|
57
|
+
- excalidraw
|
|
58
|
+
- '@slidev/plugin-notes'
|
|
59
|
+
---
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
You can find the list of official addons and community addons in the [Addons Gallery](../resources/addon-gallery).
|