29 | ```
30 |
--------------------------------------------------------------------------------
/netlify.toml:
--------------------------------------------------------------------------------
1 | [build]
2 | publish = ".vitepress/dist"
3 | command = "pnpm run build"
4 |
5 | [build.environment]
6 | NODE_VERSION = "20"
7 | PLAYWRIGHT_BROWSERS_PATH = "0"
8 |
9 | [[redirects]]
10 | from = "/new"
11 | to = "https://stackblitz.com/github/slidevjs/new?file=slides.md"
12 | status = 302
13 | force = true
14 |
15 | [[redirects]]
16 | from = "https://slidev.antfu.me/*"
17 | to = "https://sli.dev/:splat"
18 | status = 301
19 | force = true
20 |
21 | [[redirects]]
22 | from = "/demo/composable-vue/*"
23 | to = "https://demo.sli.dev/composable-vue"
24 | status = 301
25 | force = true
26 |
27 | [[redirects]]
28 | from = "/demo/starter/*"
29 | to = "https://demo.sli.dev/starter"
30 | status = 301
31 | force = true
32 |
33 | [[redirects]]
34 | from = "/*"
35 | to = "/index.html"
36 | status = 200
37 |
--------------------------------------------------------------------------------
/features/build-with-pdf.md:
--------------------------------------------------------------------------------
1 | ---
2 | depends:
3 | - guide/exporting
4 | - guide/hosting
5 | relates:
6 | - CLI export 命令: /builtin/cli#export
7 | - Headmatter: /custom/#headmatter
8 | tags: [导出, 构建]
9 | description: |
10 | 在构建时生成可供下载的 PDF。
11 | ---
12 |
13 | # 在构建时生成 PDF
14 |
15 | 你可以在 headmatter 中使用以下配置,在已构建的幻灯片中提供一个可下载的 PDF:
16 |
17 | ```md
18 | ---
19 | download: true
20 | ---
21 | ```
22 |
23 | Slidev 将在构建时生成一个 PDF 文件,并在构建的输出中显示一个下载按钮。
24 |
25 | 你也可以提供一个 PDF 的链接,这样 Slidev 将跳过渲染过程。
26 |
27 | ```md
28 | ---
29 | download: 'https://myslide.com/my-talk.pdf'
30 | ---
31 | ```
32 |
33 | 这也可以通过 CLI 选项 `--download` (只接受 `boolean`值)来完成。
34 |
35 | ```bash
36 | $ slidev build --download
37 | ```
38 |
39 | 启用下载选项时,你还可以通过以下方式提供导出选项:
40 |
41 | - [CLI 导出选项](/builtin/cli#export)
42 | - [Headmatter 导出选项](/custom/#frontmatter-configures)
43 |
--------------------------------------------------------------------------------
/features/mdc.md:
--------------------------------------------------------------------------------
1 | ---
2 | relates:
3 | - Nuxt 的 MDC 语法指南: https://content.nuxt.com/docs/files/markdown#mdc-syntax
4 | - markdown-it-mdc: https://github.com/antfu/markdown-it-mdc
5 | since: v0.43.0
6 | tags: [语法, 样式]
7 | description: |
8 | 一种强大的语法,用组件和样式增强 markdown 内容。
9 | ---
10 |
11 | # MDC 语法
12 |
13 | Slidev 支持可选的 [MDC (Markdown Components) 语法](https://content.nuxt.com/docs/files/markdown#mdc-syntax),由 [`markdown-it-mdc`](https://github.com/antfu/markdown-it-mdc) 驱动。
14 |
15 | 你可以通过在 markdown 文件的 frontmatter 中添加 `mdc:true` 来启用它。
16 |
17 | ```mdc
18 | ---
19 | mdc: true
20 | ---
21 |
22 | 这是一个 [红色的文本]{style="color:red"} :inline-component{prop="value"}
23 |
24 | {width=500px lazy}
25 |
26 | ::block-component{prop="value"}
27 | **default** 插槽的内容
28 | ::
29 | ```
30 |
31 | 请参阅 [MDC Syntax](https://content.nuxt.com/docs/files/markdown#mdc-syntax) 了解更多。
32 |
--------------------------------------------------------------------------------
/features/frontmatter-merging.md:
--------------------------------------------------------------------------------
1 | ---
2 | depends:
3 | - guide/syntax#importing-slides
4 | - features/importing-slides
5 | tags: [语法]
6 | description: |
7 | 从不同的 Markdown 文件中合并 frontmatter。
8 | ---
9 |
10 | # 合并 Frontmatter
11 |
12 | 你可以为主入口点和外部 Markdown 页面提供 frontmatter。如果其中有相同的 key,**主入口点的 key 拥有更高的优先级**。例如:
13 |
14 | ::: code-group
15 |
16 | ```md [./slides.md]
17 | ---
18 | src: ./cover.md
19 | background: https://sli.dev/bar.png // [!code highlight]
20 | class: text-center
21 | ---
22 | ```
23 |
24 | ```md [./cover.md]
25 | ---
26 | layout: cover
27 | background: https://sli.dev/foo.png // [!code highlight]
28 | ---
29 |
30 | # 封面
31 |
32 | 这是一个封面页
33 | ```
34 |
35 | :::
36 |
37 | 其效果最终与下述页面相同:
38 | ```md
39 | ---
40 | layout: cover
41 | background: https://sli.dev/bar.png // [!code highlight]
42 | class: text-center
43 | ---
44 |
45 | # 封面
46 |
47 | 这是一个封面页
48 | ```
49 |
--------------------------------------------------------------------------------
/guide/component.md:
--------------------------------------------------------------------------------
1 | # 组件指南
2 |
3 | Slidev 的一个最强大的功能是可以直接在幻灯片中使用 Vue 组件。这使得你可以轻松地创建交互式和动态内容。
4 |
5 | ## 使用组件 {#use}
6 |
7 | 基于 [`unplugin-vue-components`](https://github.com/unplugin/unplugin-vue-components),Slidev 允许你在幻灯片中直接使用 Vue 组件,而无需手动导入:
8 |
9 | ```md
10 | # My Slide
11 |
12 | 这会在左边显示
40 |这会在右边显示
44 |````md magic-move 包裹代表每个步骤的代码块(注意是**四个反引号**)。这将被转换为一个根据动画步骤变化的代码快。
20 |
21 | `````md
22 | ````md magic-move
23 | ```js
24 | console.log(`Step ${1}`)
25 | ```
26 | ```js
27 | console.log(`Step ${1 + 1}`)
28 | ```
29 | ```ts
30 | console.log(`Step ${3}` as string)
31 | ```
32 | ````
33 | `````
34 |
35 | 也可以将 Magic Move 和
22 | ```
23 |
24 | ### 在指令值中设定
25 |
26 | ::: warning
27 | Slidev 使用正则表达式来更新幻灯片内容中的位置值。如果你遇到问题,请使用 frontmatter 来定义值。
28 | :::
29 |
30 | ```md
31 |
32 | ```
33 |
34 | ## 组件式用法
35 |
36 | ### 在 frontmatter 中设定
37 |
38 | ```md
39 | ---
40 | dragPos:
41 | foo: Left,Top,Width,Height,Rotate
42 | ---
43 |
44 | 23 | 您正在访问新版文档。 24 |
25 |
14 |
15 |
16 |
17 |
16 | ```
17 |
18 | 在上例中,URL 将在构建时被解析为 `/BASE_URL/assets/image.png`。
19 |
20 | 但是,frontmatter 和其他组件中的相对路径在构建后将会失效:
21 |
22 | ```md
23 | ---
24 | background: ./image.png # 构建后可能会失效
25 | ---
26 |
27 |