@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,49 @@
|
|
|
1
|
+
---
|
|
2
|
+
depends:
|
|
3
|
+
- guide/syntax#importing-slides
|
|
4
|
+
- features/importing-slides
|
|
5
|
+
tags: [syntax]
|
|
6
|
+
description: |
|
|
7
|
+
Merge frontmatter from multiple markdown files.
|
|
8
|
+
---
|
|
9
|
+
|
|
10
|
+
# Frontmatter Merging
|
|
11
|
+
|
|
12
|
+
You can provide frontmatter instructions from both your main entry and external markdown pages. If there are duplicate keys in them, the ones from the **main entry have the higher priority**. For example:
|
|
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
|
+
# Cover
|
|
31
|
+
|
|
32
|
+
Cover Page
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
:::
|
|
36
|
+
|
|
37
|
+
They will end up being equivalent to the following page:
|
|
38
|
+
|
|
39
|
+
```md
|
|
40
|
+
---
|
|
41
|
+
layout: cover
|
|
42
|
+
background: https://sli.dev/bar.png // [!code highlight]
|
|
43
|
+
class: text-center
|
|
44
|
+
---
|
|
45
|
+
|
|
46
|
+
# Cover
|
|
47
|
+
|
|
48
|
+
Cover Page
|
|
49
|
+
```
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
---
|
|
2
|
+
tags: [navigation, layout]
|
|
3
|
+
description: |
|
|
4
|
+
Create custom components that persist across slides.
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
# Global Layers
|
|
8
|
+
|
|
9
|
+
Global layers allow you to have custom components that **persist** across slides. This could be useful for having footers, cross-slide animations, global effects, etc.
|
|
10
|
+
|
|
11
|
+
Slidev provides three layers for this usage, create `global-top.vue`, `global-bottom.vue`, or `custom-nav-controls.vue` under your project root and it will pick up automatically.
|
|
12
|
+
|
|
13
|
+
There are also layers for **each** slide: `slide-top.vue` and `slide-bottom.vue`. The usage is similar to the global layers, but they are applied to every slide, so there may be more than one instance of them.
|
|
14
|
+
|
|
15
|
+
::: tip
|
|
16
|
+
If you are using `global-top.vue` or `global-bottom.vue` depending on the current navigation state, when exporting, the `--per-slide` option should be used to ensure the correct state is applied to each slide. Or you can use `slide-top.vue` and `slide-bottom.vue` instead.
|
|
17
|
+
:::
|
|
18
|
+
|
|
19
|
+
## Layers relationship
|
|
20
|
+
|
|
21
|
+
At z-axis, from top to bottom:
|
|
22
|
+
|
|
23
|
+
- NavControls
|
|
24
|
+
- Customized Navigation Controls (`custom-nav-controls.vue`)
|
|
25
|
+
- Global Top (`global-top.vue`) - single instance
|
|
26
|
+
- Slide Top (`slide-top.vue`) - instance per slide
|
|
27
|
+
- Slide Content
|
|
28
|
+
- Slide Bottom (`slide-bottom.vue`) - instance per slide
|
|
29
|
+
- Global Bottom (`global-bottom.vue`) - single instance
|
|
30
|
+
|
|
31
|
+
## Example
|
|
32
|
+
|
|
33
|
+
```html
|
|
34
|
+
<!-- global-bottom.vue -->
|
|
35
|
+
<template>
|
|
36
|
+
<footer class="absolute bottom-0 left-0 right-0 p-2">Your Name</footer>
|
|
37
|
+
</template>
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
The text `Your Name` will appear on all your slides.
|
|
41
|
+
|
|
42
|
+
```html
|
|
43
|
+
<!-- custom-nav-controls -->
|
|
44
|
+
<template>
|
|
45
|
+
<button class="icon-btn" title="Next" @click="$nav.next">
|
|
46
|
+
<div class="i-carbon:arrow-right" />
|
|
47
|
+
</button>
|
|
48
|
+
</template>
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
The button `Next` will appear in NavControls.
|
|
52
|
+
|
|
53
|
+
To enable it conditionally, you can use the <LinkInline link="guide/global-context" />
|
|
54
|
+
|
|
55
|
+
```html
|
|
56
|
+
<!-- hide the footer from Page 4 -->
|
|
57
|
+
<template>
|
|
58
|
+
<footer
|
|
59
|
+
v-if="$nav.currentPage !== 4"
|
|
60
|
+
class="absolute bottom-0 left-0 right-0 p-2"
|
|
61
|
+
>
|
|
62
|
+
Your Name
|
|
63
|
+
</footer>
|
|
64
|
+
</template>
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
```html
|
|
68
|
+
<!-- hide the footer from "cover" layout -->
|
|
69
|
+
<template>
|
|
70
|
+
<footer
|
|
71
|
+
v-if="$nav.currentLayout !== 'cover'"
|
|
72
|
+
class="absolute bottom-0 left-0 right-0 p-2"
|
|
73
|
+
>
|
|
74
|
+
Your Name
|
|
75
|
+
</footer>
|
|
76
|
+
</template>
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
```html
|
|
80
|
+
<!-- an example footer for pages -->
|
|
81
|
+
<template>
|
|
82
|
+
<footer
|
|
83
|
+
v-if="$nav.currentLayout !== 'cover'"
|
|
84
|
+
class="absolute bottom-0 left-0 right-0 p-2"
|
|
85
|
+
>
|
|
86
|
+
{{ $nav.currentPage }} / {{ $nav.total }}
|
|
87
|
+
</footer>
|
|
88
|
+
</template>
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
```html
|
|
92
|
+
<!-- custom-nav-controls -->
|
|
93
|
+
<!-- hide the button in Presenter model -->
|
|
94
|
+
<template>
|
|
95
|
+
<button v-if="!$nav.isPresenter" class="icon-btn" title="Next" @click="$nav.next">
|
|
96
|
+
<div class="i-carbon:arrow-right" />
|
|
97
|
+
</button>
|
|
98
|
+
</template>
|
|
99
|
+
```
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
---
|
|
2
|
+
relates:
|
|
3
|
+
- Iconify: https://iconify.design/
|
|
4
|
+
- Icones: https://icones.js.org/
|
|
5
|
+
- unplugin-icons: https://github.com/antfu/unplugin-icons
|
|
6
|
+
tags: [components]
|
|
7
|
+
description: |
|
|
8
|
+
Use icons from virtually all open-source icon sets directly in your markdown.
|
|
9
|
+
---
|
|
10
|
+
|
|
11
|
+
# Icons
|
|
12
|
+
|
|
13
|
+
Slidev allows you to have access to virtually all open-source icon sets **directly** in your markdown after installing the corresponding package. Powered by [`unplugin-icons`](https://github.com/antfu/unplugin-icons) and [Iconify](https://iconify.design/).
|
|
14
|
+
|
|
15
|
+
The naming follows [Iconify](https://iconify.design/)'s convention of `{collection-name}-{icon-name}`. For example:
|
|
16
|
+
|
|
17
|
+
- `<mdi-account-circle />` - <mdi-account-circle /> from [Material Design Icons](https://github.com/Templarian/MaterialDesign) - [`@iconify-json/mdi`](https://npmjs.com/package/@iconify-json/mdi)
|
|
18
|
+
- `<carbon-badge />` - <carbon-badge /> from [Carbon](https://github.com/carbon-design-system/carbon/tree/main/packages/icons) - [`@iconify-json/carbon`](https://npmjs.com/package/@iconify-json/carbon)
|
|
19
|
+
- `<uim-rocket />` - <uim-rocket /> from [Unicons Monochrome](https://github.com/Iconscout/unicons) - [`@iconify-json/uim`](https://npmjs.com/package/@iconify-json/uim)
|
|
20
|
+
- `<twemoji-cat-with-tears-of-joy />` - <twemoji-cat-with-tears-of-joy /> from [Twemoji](https://github.com/twitter/twemoji) - [`@iconify-json/twemoji`](https://npmjs.com/package/@iconify-json/twemoji)
|
|
21
|
+
- `<logos-vue />` - <logos-vue /> from [SVG Logos](https://github.com/gilbarbara/logos) - [`@iconify-json/logos`](https://npmjs.com/package/@iconify-json/logos)
|
|
22
|
+
- And much more...
|
|
23
|
+
|
|
24
|
+
::: code-group
|
|
25
|
+
|
|
26
|
+
```bash [pnpm]
|
|
27
|
+
pnpm add @iconify-json/[the-collection-you-want]
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
```bash [npm]
|
|
31
|
+
npm install @iconify-json/[the-collection-you-want]
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
```bash [yarn]
|
|
35
|
+
yarn add @iconify-json/[the-collection-you-want]
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
```bash [bun]
|
|
39
|
+
bun add @iconify-json/[the-collection-you-want]
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
:::
|
|
43
|
+
|
|
44
|
+
We use [Iconify](https://iconify.design) as our data source of icons. You need to install the corresponding icon-set in `dependencies` by following the `@iconify-json/*` pattern. For example, `@iconify-json/mdi` for [Material Design Icons](https://materialdesignicons.com/), `@iconify-json/tabler` for [Tabler](https://tabler-icons.io/). You can refer to [Icônes](https://icones.js.org/) or [Iconify](https://icon-sets.iconify.design/) for all the collections available.
|
|
45
|
+
|
|
46
|
+
### Styling Icons
|
|
47
|
+
|
|
48
|
+
You can style the icons just like other HTML elements. For example:
|
|
49
|
+
|
|
50
|
+
```html
|
|
51
|
+
<uim-rocket />
|
|
52
|
+
<uim-rocket class="text-3xl text-red-400 mx-2" />
|
|
53
|
+
<uim-rocket class="text-3xl text-orange-400 animate-ping" />
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
<uim-rocket />
|
|
57
|
+
<uim-rocket class="text-3xl text-red-400 mx-2" />
|
|
58
|
+
<uim-rocket class="text-3xl text-orange-400 animate-ping ml-2" />
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
---
|
|
2
|
+
relates:
|
|
3
|
+
- features/monaco-write
|
|
4
|
+
- features/monaco-editor
|
|
5
|
+
since: v0.47.0
|
|
6
|
+
tags: [codeblock, syntax]
|
|
7
|
+
description: |
|
|
8
|
+
Import code snippets from existing files into your slides.
|
|
9
|
+
---
|
|
10
|
+
|
|
11
|
+
# Import Code Snippets
|
|
12
|
+
|
|
13
|
+
You can import code snippets from existing files via the following syntax:
|
|
14
|
+
|
|
15
|
+
```md
|
|
16
|
+
<<< @/snippets/snippet.js
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
::: tip
|
|
20
|
+
The value of `@` corresponds to your package's root directory. It's recommended to put snippets in `@/snippets` in order to be compatible with the Monaco editor. Alternatively, you can also import from relative paths.
|
|
21
|
+
:::
|
|
22
|
+
|
|
23
|
+
You can also use a [VS Code region](https://code.visualstudio.com/docs/editor/codebasics#_folding) to only include the corresponding part of the code file:
|
|
24
|
+
|
|
25
|
+
```md
|
|
26
|
+
<<< @/snippets/snippet.js#region-name
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
To explicitly specify the language of the imported code, you can add a language identifier after:
|
|
30
|
+
|
|
31
|
+
```md
|
|
32
|
+
<<< @/snippets/snippet.js ts
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
Any code block features like [line highlighting](#line-highlighting) and [Monaco editor](#monaco-editor) are also supported:
|
|
36
|
+
|
|
37
|
+
```md
|
|
38
|
+
<<< @/snippets/snippet.js {2,3|5}{lines:true}
|
|
39
|
+
<<< @/snippets/snippet.js ts {monaco}{height:200px}
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
Note that you can use `{*}` as a placeholder of <LinkInline link="features/line-highlighting" />:
|
|
43
|
+
|
|
44
|
+
<!-- eslint-skip -->
|
|
45
|
+
|
|
46
|
+
```md
|
|
47
|
+
<<< @/snippets/snippet.js {*}{lines:true}
|
|
48
|
+
```
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
---
|
|
2
|
+
relates:
|
|
3
|
+
- features/frontmatter-merging
|
|
4
|
+
tags: [syntax]
|
|
5
|
+
description: |
|
|
6
|
+
Split your `slides.md` into multiple files for better reusability and organization.
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
# Importing Slides
|
|
10
|
+
|
|
11
|
+
You can split your `slides.md` into multiple files for better reusability and organization. To do this, you can use the `src` frontmatter option to specify the path to the external markdown file. For example:
|
|
12
|
+
|
|
13
|
+
::: code-group
|
|
14
|
+
|
|
15
|
+
<!-- eslint-skip -->
|
|
16
|
+
|
|
17
|
+
```md [./slides.md]
|
|
18
|
+
# Title
|
|
19
|
+
|
|
20
|
+
This is a normal page
|
|
21
|
+
|
|
22
|
+
---
|
|
23
|
+
src: ./pages/toc.md // [!code highlight]
|
|
24
|
+
---
|
|
25
|
+
|
|
26
|
+
<!-- this page will be loaded from './pages/toc.md' -->
|
|
27
|
+
|
|
28
|
+
Contents here are ignored
|
|
29
|
+
|
|
30
|
+
---
|
|
31
|
+
|
|
32
|
+
# Page 4
|
|
33
|
+
|
|
34
|
+
Another normal page
|
|
35
|
+
|
|
36
|
+
---
|
|
37
|
+
src: ./pages/toc.md # Reuse the same file // [!code highlight]
|
|
38
|
+
---
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
```md [./pages/toc.md]
|
|
42
|
+
# Table of Contents
|
|
43
|
+
|
|
44
|
+
Part 1
|
|
45
|
+
|
|
46
|
+
---
|
|
47
|
+
|
|
48
|
+
# Table of Contents
|
|
49
|
+
|
|
50
|
+
Part 2
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
:::
|
|
54
|
+
|
|
55
|
+
## Importing Specific Slides
|
|
56
|
+
|
|
57
|
+
To reuse some of the slides inside another Markdown file, you can use the hash part of the import path:
|
|
58
|
+
|
|
59
|
+
```md
|
|
60
|
+
---
|
|
61
|
+
src: ./another-presentation.md#2,5-7
|
|
62
|
+
---
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
This will import the slides 2, 5, 6, and 7 from `./another-presentation.md`.
|
|
66
|
+
|
|
67
|
+
## Frontmatter Merging
|
|
68
|
+
|
|
69
|
+
<LinkCard link="features/frontmatter-merging" />
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
---
|
|
2
|
+
editLink: false
|
|
3
|
+
footer: false
|
|
4
|
+
aside: false
|
|
5
|
+
outline: false
|
|
6
|
+
sidebar: false
|
|
7
|
+
pageClass: all-features-page
|
|
8
|
+
---
|
|
9
|
+
|
|
10
|
+
<script setup lang="ts">
|
|
11
|
+
import { useUrlSearchParams } from '@vueuse/core'
|
|
12
|
+
import { computed, toRef, ref } from 'vue'
|
|
13
|
+
import { withBase } from 'vitepress'
|
|
14
|
+
import { data as features } from './index.data'
|
|
15
|
+
|
|
16
|
+
const query = useUrlSearchParams('hash-params', { removeFalsyValues: true })
|
|
17
|
+
const search = toRef(query, 'search') as Ref<string | null>
|
|
18
|
+
const tags = toRef(query, 'tags') as Ref<string | null>
|
|
19
|
+
const tagsArr = computed({
|
|
20
|
+
get: () => tags.value?.toLowerCase().split(',').map(t => t.trim()).filter(Boolean) ?? [],
|
|
21
|
+
set: (val: string[]) => query.tags = val.join(','),
|
|
22
|
+
})
|
|
23
|
+
|
|
24
|
+
const filteredFeatures = computed(() => {
|
|
25
|
+
const s = search.value?.toLowerCase().trim()
|
|
26
|
+
const t = tagsArr.value
|
|
27
|
+
return Object.values(features).filter(feature => {
|
|
28
|
+
return (!s || feature.title.toLowerCase().includes(s) || feature.description.toLowerCase().includes(s))
|
|
29
|
+
&& (!t?.length || t.every(tag => feature.tags?.includes(tag)))
|
|
30
|
+
})
|
|
31
|
+
})
|
|
32
|
+
|
|
33
|
+
function resetFilters() {
|
|
34
|
+
query.search = null
|
|
35
|
+
query.tags = null
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
function removeTag(tag: string) {
|
|
39
|
+
tagsArr.value = tagsArr.value.filter(t => t !== tag)
|
|
40
|
+
}
|
|
41
|
+
</script>
|
|
42
|
+
|
|
43
|
+
# Features
|
|
44
|
+
|
|
45
|
+
This is a list of all the individual features that Slidev provides. Each feature can be used independently and is optional.
|
|
46
|
+
|
|
47
|
+
You can also read <LinkInline link="guide/" /> to learn the features by topic.
|
|
48
|
+
|
|
49
|
+
<ClientOnly>
|
|
50
|
+
<div flex items-center mt-6 gap-6>
|
|
51
|
+
<div
|
|
52
|
+
flex items-center rounded-md
|
|
53
|
+
px3 py2 gap-2 border-2 border-solid border-transparent
|
|
54
|
+
class="bg-$vp-c-bg-alt focus-within:border-color-$vp-c-brand"
|
|
55
|
+
>
|
|
56
|
+
<div class="i-carbon:search" text-sm op-80 />
|
|
57
|
+
<input
|
|
58
|
+
v-model="search"
|
|
59
|
+
type="search" text-base
|
|
60
|
+
placeholder="Search features..."
|
|
61
|
+
/>
|
|
62
|
+
</div>
|
|
63
|
+
<div
|
|
64
|
+
v-if="tagsArr.length"
|
|
65
|
+
flex items-center gap-1
|
|
66
|
+
>
|
|
67
|
+
<div class="i-carbon:tag" text-sm mr-1 op-80 />
|
|
68
|
+
<FeatureTag v-for="tag in tagsArr" :key="tag" :tag removable @remove="removeTag(tag)"/>
|
|
69
|
+
</div>
|
|
70
|
+
</div>
|
|
71
|
+
|
|
72
|
+
<FeaturesOverview :features="filteredFeatures" />
|
|
73
|
+
|
|
74
|
+
<div v-if="filteredFeatures.length === 0" class="w-full mt-6 op-80 flex flex-col items-center">
|
|
75
|
+
No results found
|
|
76
|
+
<button class="block select-button flex-inline gap-1 items-center px-2 py-1 hover:bg-gray-400/10 rounded" @click="resetFilters()">
|
|
77
|
+
<div class="i-carbon:filter-remove" />
|
|
78
|
+
Clear Filters
|
|
79
|
+
</button>
|
|
80
|
+
</div>
|
|
81
|
+
</ClientOnly>
|
|
82
|
+
|
|
83
|
+
<style>
|
|
84
|
+
.all-features-page .VPDoc > .container > .content {
|
|
85
|
+
max-width: 72vw !important;
|
|
86
|
+
}
|
|
87
|
+
</style>
|
|
88
|
+
|
|
89
|
+
<style>
|
|
90
|
+
:root {
|
|
91
|
+
overflow-y: scroll;
|
|
92
|
+
}
|
|
93
|
+
</style>
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
---
|
|
2
|
+
relates:
|
|
3
|
+
- Demo: /demo/starter/11
|
|
4
|
+
- KaTeX: https://katex.org/
|
|
5
|
+
tags: [codeblock, syntax]
|
|
6
|
+
description: |
|
|
7
|
+
Slidev comes with LaTeX support out-of-box, powered by KaTeX.
|
|
8
|
+
---
|
|
9
|
+
|
|
10
|
+
# LaTeX
|
|
11
|
+
|
|
12
|
+
Slidev comes with LaTeX support out-of-box, powered by [KaTeX](https://katex.org/).
|
|
13
|
+
|
|
14
|
+
## Inline
|
|
15
|
+
|
|
16
|
+
Surround your LaTeX with a single `$` on each side for inline rendering.
|
|
17
|
+
|
|
18
|
+
```md
|
|
19
|
+
$\sqrt{3x-1}+(1+x)^2$
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
## Block
|
|
23
|
+
|
|
24
|
+
Use two (`$$`) for block rendering. This mode uses bigger symbols and centers
|
|
25
|
+
the result.
|
|
26
|
+
|
|
27
|
+
```latex
|
|
28
|
+
$$
|
|
29
|
+
\begin{aligned}
|
|
30
|
+
\nabla \cdot \vec{E} &= \frac{\rho}{\varepsilon_0} \\
|
|
31
|
+
\nabla \cdot \vec{B} &= 0 \\
|
|
32
|
+
\nabla \times \vec{E} &= -\frac{\partial\vec{B}}{\partial t} \\
|
|
33
|
+
\nabla \times \vec{B} &= \mu_0\vec{J} + \mu_0\varepsilon_0\frac{\partial\vec{E}}{\partial t}
|
|
34
|
+
\end{aligned}
|
|
35
|
+
$$
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
## Line Highlighting
|
|
39
|
+
|
|
40
|
+
To highlight specific lines, simply add line numbers within bracket `{}`. Line numbers start counting from 1 by default.
|
|
41
|
+
|
|
42
|
+
```latex
|
|
43
|
+
$$ {1|3|all}
|
|
44
|
+
\begin{aligned}
|
|
45
|
+
\nabla \cdot \vec{E} &= \frac{\rho}{\varepsilon_0} \\
|
|
46
|
+
\nabla \cdot \vec{B} &= 0 \\
|
|
47
|
+
\nabla \times \vec{E} &= -\frac{\partial\vec{B}}{\partial t} \\
|
|
48
|
+
\nabla \times \vec{B} &= \mu_0\vec{J} + \mu_0\varepsilon_0\frac{\partial\vec{E}}{\partial t}
|
|
49
|
+
\end{aligned}
|
|
50
|
+
$$
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
The `at` and `finally` options of [code blocks](#line-highlighting) are also available for LaTeX blocks.
|
|
54
|
+
|
|
55
|
+
## Chemical equations
|
|
56
|
+
|
|
57
|
+
To enable the rendering of chemical equations, the [mhchem](https://github.com/KaTeX/KaTeX/tree/main/contrib/mhchem)
|
|
58
|
+
KaTeX extension needs to be loaded.
|
|
59
|
+
|
|
60
|
+
Create `vite.config.ts` with the following content:
|
|
61
|
+
|
|
62
|
+
```ts
|
|
63
|
+
import 'katex/contrib/mhchem'
|
|
64
|
+
|
|
65
|
+
export default {}
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
Now chemical equations can be rendered properly.
|
|
69
|
+
|
|
70
|
+
```latex
|
|
71
|
+
$$
|
|
72
|
+
\displaystyle{\ce{B(OH)3 + H2O <--> B(OH)4^- + H+}}
|
|
73
|
+
$$
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
Learn more: [Syntax](https://mhchem.github.io/MathJax-mhchem)
|
|
77
|
+
|
|
78
|
+
---
|
|
79
|
+
|
|
80
|
+
<TheTweet id="1392246507793915904" />
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
---
|
|
2
|
+
depends:
|
|
3
|
+
- guide/syntax#code-block
|
|
4
|
+
- guide/animations
|
|
5
|
+
tags: [codeblock, animation]
|
|
6
|
+
description: |
|
|
7
|
+
Highlight specific lines in code blocks based on clicks.
|
|
8
|
+
---
|
|
9
|
+
|
|
10
|
+
# Line Highlighting
|
|
11
|
+
|
|
12
|
+
To highlight specific lines, simply add line numbers within brackets `{}`. Line numbers start counting from 1 by default.
|
|
13
|
+
|
|
14
|
+
````md
|
|
15
|
+
```ts {2,3}
|
|
16
|
+
function add(
|
|
17
|
+
a: Ref<number> | number,
|
|
18
|
+
b: Ref<number> | number
|
|
19
|
+
) {
|
|
20
|
+
return computed(() => unref(a) + unref(b))
|
|
21
|
+
}
|
|
22
|
+
```
|
|
23
|
+
````
|
|
24
|
+
|
|
25
|
+
## Dynamic Line Highlighting
|
|
26
|
+
|
|
27
|
+
To change what's highlighted with multiple clicks, you can use `|` to separate each stage:
|
|
28
|
+
|
|
29
|
+
````md
|
|
30
|
+
```ts {2-3|5|all}
|
|
31
|
+
function add(
|
|
32
|
+
a: Ref<number> | number,
|
|
33
|
+
b: Ref<number> | number
|
|
34
|
+
) {
|
|
35
|
+
return computed(() => unref(a) + unref(b))
|
|
36
|
+
}
|
|
37
|
+
```
|
|
38
|
+
````
|
|
39
|
+
|
|
40
|
+
This will first highlight `a: Ref<number> | number` and `b: Ref<number> | number`, and then `return computed(() => unref(a) + unref(b))` after one click, and lastly, the whole block.
|
|
41
|
+
|
|
42
|
+
You can set the line number to `hide` to hide the code block or `none` to not highlight any line:
|
|
43
|
+
|
|
44
|
+
````md
|
|
45
|
+
```ts {hide|none}
|
|
46
|
+
function add(
|
|
47
|
+
a: Ref<number> | number,
|
|
48
|
+
b: Ref<number> | number
|
|
49
|
+
) {
|
|
50
|
+
return computed(() => unref(a) + unref(b))
|
|
51
|
+
}
|
|
52
|
+
```
|
|
53
|
+
````
|
|
54
|
+
|
|
55
|
+
::: tip
|
|
56
|
+
Learn more in the [click animations guide](/guide/animations#positioning).
|
|
57
|
+
:::
|
package/features/mdc.md
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
---
|
|
2
|
+
relates:
|
|
3
|
+
- Nuxt's MDC Syntax: 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: [syntax, styling]
|
|
7
|
+
description: |
|
|
8
|
+
A powerful syntax to enhance your markdown content with components and styles.
|
|
9
|
+
---
|
|
10
|
+
|
|
11
|
+
# MDC Syntax
|
|
12
|
+
|
|
13
|
+
Slidev supports optional [MDC (Markdown Components) Syntax](https://content.nuxt.com/docs/files/markdown#mdc-syntax) powered by [`markdown-it-mdc`](https://github.com/antfu/markdown-it-mdc).
|
|
14
|
+
|
|
15
|
+
You can enable it by adding `mdc: true` to the frontmatter of your markdown file.
|
|
16
|
+
|
|
17
|
+
```mdc
|
|
18
|
+
---
|
|
19
|
+
mdc: true
|
|
20
|
+
---
|
|
21
|
+
|
|
22
|
+
This is a [red text]{style="color:red"} :inline-component{prop="value"}
|
|
23
|
+
|
|
24
|
+
{width=500px lazy}
|
|
25
|
+
|
|
26
|
+
::block-component{prop="value"}
|
|
27
|
+
The **default** slot
|
|
28
|
+
::
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
Learn more about [MDC Syntax](https://content.nuxt.com/docs/files/markdown#mdc-syntax).
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
---
|
|
2
|
+
relates:
|
|
3
|
+
- Mermaid: https://mermaid.js.org/
|
|
4
|
+
- Mermaid Live Editor: https://mermaid.live/
|
|
5
|
+
- Demo Slide: https://sli.dev/demo/starter/12
|
|
6
|
+
- features/plantuml
|
|
7
|
+
tags: [diagram]
|
|
8
|
+
description: |
|
|
9
|
+
Create diagrams/graphs from textual descriptions, powered by Mermaid.
|
|
10
|
+
---
|
|
11
|
+
|
|
12
|
+
# Mermaid Diagrams
|
|
13
|
+
|
|
14
|
+
You can also create diagrams/graphs from textual descriptions in your Markdown, powered by [Mermaid](https://mermaid.js.org/).
|
|
15
|
+
|
|
16
|
+
Code blocks marked as `mermaid` will be converted to diagrams, for example:
|
|
17
|
+
|
|
18
|
+
````md
|
|
19
|
+
```mermaid
|
|
20
|
+
sequenceDiagram
|
|
21
|
+
Alice->John: Hello John, how are you?
|
|
22
|
+
Note over Alice,John: A typical interaction
|
|
23
|
+
```
|
|
24
|
+
````
|
|
25
|
+
|
|
26
|
+
You can further pass an options object to it to specify the scaling and theming. The syntax of the object is a JavaScript object literal, you will need to add quotes (`'`) for strings and use comma (`,`) between keys.
|
|
27
|
+
|
|
28
|
+
````md
|
|
29
|
+
```mermaid {theme: 'neutral', scale: 0.8}
|
|
30
|
+
graph TD
|
|
31
|
+
B[Text] --> C{Decision}
|
|
32
|
+
C -->|One| D[Result 1]
|
|
33
|
+
C -->|Two| E[Result 2]
|
|
34
|
+
```
|
|
35
|
+
````
|
|
36
|
+
|
|
37
|
+
Visit the [Mermaid Website](https://mermaid.js.org/) for more information.
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
---
|
|
2
|
+
depends:
|
|
3
|
+
- guide/syntax#code-block
|
|
4
|
+
relates:
|
|
5
|
+
- Monaco Editor: https://microsoft.github.io/monaco-editor/
|
|
6
|
+
- Configure Monaco Editor: /custom/config-monaco
|
|
7
|
+
tags: [codeblock, editor]
|
|
8
|
+
description: |
|
|
9
|
+
Turn code blocks into fully-featured editors, or generate a diff between two code blocks.
|
|
10
|
+
---
|
|
11
|
+
|
|
12
|
+
# Monaco Editor
|
|
13
|
+
|
|
14
|
+
<video src="https://github.com/slidevjs/slidev/assets/11247099/0c6ce681-80d3-4555-93bf-9288ee533462" controls rounded shadow w-full></video>
|
|
15
|
+
|
|
16
|
+
Whenever you want to do some modification in the presentation, simply add `{monaco}` after the language id — it turns the block into a fully-featured Monaco editor!
|
|
17
|
+
|
|
18
|
+
````md
|
|
19
|
+
```ts {monaco}
|
|
20
|
+
console.log('HelloWorld')
|
|
21
|
+
```
|
|
22
|
+
````
|
|
23
|
+
|
|
24
|
+
Learn more about [Configuring Monaco](/custom/config-monaco).
|
|
25
|
+
|
|
26
|
+
## Diff Editor
|
|
27
|
+
|
|
28
|
+
Monaco can also generate a diff between two code blocks. Use `{monaco-diff}` to turn the block into a [Monaco diff editor](https://microsoft.github.io/monaco-editor/playground.html?source=v0.36.1#example-creating-the-diffeditor-multi-line-example) and use `~~~` to separate the original and modified code!
|
|
29
|
+
|
|
30
|
+
````md
|
|
31
|
+
```ts {monaco-diff}
|
|
32
|
+
console.log('Original text')
|
|
33
|
+
~~~
|
|
34
|
+
console.log('Modified text')
|
|
35
|
+
```
|
|
36
|
+
````
|