@slidev/docs 51.7.0 → 51.8.0

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.
@@ -10,7 +10,7 @@ Create `./setup/code-runners.ts` with the following content:
10
10
 
11
11
  <!-- eslint-disable import/first -->
12
12
 
13
- ```ts twoslash
13
+ ```ts twoslash [setup/code-runners.ts]
14
14
  declare const executePythonCodeRemotely: (code: string) => Promise<string>
15
15
  declare const sanitizeHtml: (html: string) => string
16
16
  // ---cut---
@@ -8,7 +8,7 @@ Create `./setup/context-menu.ts` with the following content:
8
8
 
9
9
  <!-- eslint-disable import/first -->
10
10
 
11
- ```ts twoslash
11
+ ```ts twoslash [./setup/context-menu.ts]
12
12
  // ---cut---
13
13
  import { useNav } from '@slidev/client'
14
14
  import { defineContextMenuSetup } from '@slidev/types'
@@ -8,8 +8,7 @@ Slidev uses [Shiki](https://github.com/shikijs/shiki) as the code highlighter. I
8
8
 
9
9
  Create `./setup/shiki.ts` file with the following content:
10
10
 
11
- ```ts twoslash
12
- /* ./setup/shiki.ts */
11
+ ```ts twoslash [setup/shiki.ts]
13
12
  import { defineShikiSetup } from '@slidev/types'
14
13
 
15
14
  export default defineShikiSetup(() => {
@@ -29,8 +28,7 @@ If you want to add custom theme or language (TextMate grammar/themes in JSON), y
29
28
 
30
29
  <!-- eslint-disable import/first-->
31
30
 
32
- ```ts twoslash
33
- /* ./setup/shiki.ts */
31
+ ```ts twoslash [setup/shiki.ts]
34
32
  import { defineShikiSetup } from '@slidev/types'
35
33
  // ---cut-start---
36
34
  // @ts-expect-error missing types
@@ -4,7 +4,7 @@
4
4
 
5
5
  Create `./setup/katex.ts` with the following content:
6
6
 
7
- ```ts twoslash
7
+ ```ts twoslash [setup/katex.ts]
8
8
  import { defineKatexSetup } from '@slidev/types'
9
9
 
10
10
  export default defineKatexSetup(() => {
@@ -4,7 +4,7 @@
4
4
 
5
5
  Create `./setup/mermaid.ts` with the following content:
6
6
 
7
- ```ts twoslash
7
+ ```ts twoslash [setup/mermaid.ts]
8
8
  import { defineMermaidSetup } from '@slidev/types'
9
9
 
10
10
  export default defineMermaidSetup(() => {
@@ -4,7 +4,7 @@
4
4
 
5
5
  Create `./setup/monaco.ts` with the following content:
6
6
 
7
- ```ts twoslash
7
+ ```ts twoslash [./setup/monaco.ts]
8
8
  import { defineMonacoSetup } from '@slidev/types'
9
9
 
10
10
  export default defineMonacoSetup(async (monaco) => {
@@ -71,8 +71,7 @@ console.log('HelloWorld')
71
71
 
72
72
  Alternatively if you would like these options to be applied to every Monaco instance, you can return them in the `defineMonacoSetup` function
73
73
 
74
- ```ts twoslash
75
- // ./setup/monaco.ts
74
+ ```ts twoslash [./setup/monaco.ts]
76
75
  import { defineMonacoSetup } from '@slidev/types'
77
76
 
78
77
  export default defineMonacoSetup(() => {
@@ -26,7 +26,7 @@ The preparser (step 1 above) is highly extensible and allows you to implement cu
26
26
 
27
27
  To customize it, create a `./setup/preparser.ts` file with the following content:
28
28
 
29
- ```ts twoslash
29
+ ```ts twoslash [./setup/preparser.ts]
30
30
  import { definePreparserSetup } from '@slidev/types'
31
31
 
32
32
  export default definePreparserSetup(({ filepath, headmatter, mode }) => {
@@ -76,7 +76,7 @@ see you next time
76
76
 
77
77
  To allow these `@src:` and `@cover:` syntaxes, create a `./setup/preparser.ts` file with the following content:
78
78
 
79
- ```ts twoslash
79
+ ```ts twoslash [./setup/preparser.ts]
80
80
  import { definePreparserSetup } from '@slidev/types'
81
81
 
82
82
  export default definePreparserSetup(() => {
@@ -157,7 +157,7 @@ Here we used an underscore in `_scale` to avoid possible conflicts with existing
157
157
 
158
158
  To handle this `_scale: ...` syntax in the frontmatter, create a `./setup/preparser.ts` file with the following content:
159
159
 
160
- ```ts twoslash
160
+ ```ts twoslash [./setup/preparser.ts]
161
161
  import { definePreparserSetup } from '@slidev/types'
162
162
 
163
163
  export default definePreparserSetup(() => {
@@ -207,7 +207,7 @@ Here we used an underscore in `_note` to avoid possible conflicts with existing
207
207
 
208
208
  To handle this `_note: ...` syntax in the frontmatter, create a `./setup/preparser.ts` file with the following content:
209
209
 
210
- ```ts twoslash
210
+ ```ts twoslash [./setup/preparser.ts]
211
211
  import fs, { promises as fsp } from 'node:fs'
212
212
  import { definePreparserSetup } from '@slidev/types'
213
213
 
@@ -8,7 +8,7 @@ Add custom pages to the Slidev app.
8
8
 
9
9
  Create `./setup/routes.ts` with the following content:
10
10
 
11
- ```ts twoslash
11
+ ```ts twoslash [./setup/routes.ts]
12
12
  import { defineRoutesSetup } from '@slidev/types'
13
13
 
14
14
  export default defineRoutesSetup((routes) => {
@@ -6,7 +6,7 @@
6
6
 
7
7
  Create `./setup/shortcuts.ts` with the following content:
8
8
 
9
- ```ts twoslash
9
+ ```ts twoslash [./setup/shortcuts.ts]
10
10
  import type { NavOperations, ShortcutOptions } from '@slidev/types'
11
11
  import { defineShortcutsSetup } from '@slidev/types'
12
12
 
@@ -4,7 +4,7 @@
4
4
 
5
5
  This setup function allows you to define custom transformers for the markdown content of **each slide**. This is useful when you want to add custom Markdown syntax and render custom code blocks. To start, create a `./setup/transformers.ts` file with the following content:
6
6
 
7
- ````ts twoslash
7
+ ````ts twoslash [setup/transformers.ts]
8
8
  import type { MarkdownTransformContext } from '@slidev/types'
9
9
  import { defineTransformersSetup } from '@slidev/types'
10
10
 
@@ -31,7 +31,7 @@ You can therefore style your content the way you want. For example:
31
31
 
32
32
  You can create `uno.config.ts` under the root of your project to extend the builtin configurations
33
33
 
34
- ```ts twoslash
34
+ ```ts twoslash [uno.config.ts]
35
35
  import { defineConfig } from 'unocss'
36
36
 
37
37
  export default defineConfig({
@@ -21,7 +21,7 @@ To configure the built-in plugins listed above, create a `vite.config.ts` with t
21
21
 
22
22
  <!-- eslint-disable import/first -->
23
23
 
24
- ```ts twoslash
24
+ ```ts twoslash [vite.config.ts]
25
25
  /// <reference types="@slidev/types" />
26
26
  import type MarkdownIt from 'markdown-it'
27
27
  declare const MyPlugin: (md: any) => void
@@ -8,7 +8,7 @@ Create `./setup/main.ts` with the following content:
8
8
 
9
9
  <!-- eslint-disable import/first -->
10
10
 
11
- ```ts twoslash
11
+ ```ts twoslash [setup/main.ts]
12
12
  import type { Plugin } from 'vue'
13
13
  declare const YourPlugin: Plugin
14
14
  // ---cut---
@@ -93,8 +93,7 @@ The `index.html` provides the ability to inject meta tags and/or scripts to the
93
93
 
94
94
  For example, for the following custom `index.html`:
95
95
 
96
- ```html
97
- <!-- ./index.html -->
96
+ ```html [index.html]
98
97
  <head>
99
98
  <link rel="preconnect" href="https://fonts.gstatic.com">
100
99
  <link href="https://fonts.googleapis.com/css2?family=Fira+Code:wght@400;600&family=Nunito+Sans:wght@200;400;600&display=swap" rel="stylesheet">
@@ -0,0 +1,128 @@
1
+ ---
2
+ depends:
3
+ - guide/syntax#code-block
4
+ tags: [codeblock]
5
+ description: |
6
+ Group multiple code blocks and automatically match icon by the title name.
7
+ ---
8
+
9
+ # Code Groups
10
+
11
+ > [!NOTE]
12
+ > This feature requires [MDC Syntax](/features/mdc#mdc-syntax). Enable `mdc: true` to use it.
13
+
14
+ You can group multiple code blocks like this:
15
+
16
+ ````md
17
+ ::code-group
18
+
19
+ ```sh [npm]
20
+ npm i @slidev/cli
21
+ ```
22
+
23
+ ```sh [yarn]
24
+ yarn add @slidev/cli
25
+ ```
26
+
27
+ ```sh [pnpm]
28
+ pnpm add @slidev/cli
29
+ ```
30
+
31
+ ::
32
+ ````
33
+
34
+ ## Title Icon Matching
35
+
36
+ `code groups` and `code block` also supports the automatically icon matching by the title name:
37
+
38
+ ![code-groups-demo](/assets/code-groups-demo.png)
39
+
40
+ ::: details All builtin icons
41
+
42
+ ```js
43
+ const builtinIcons = {
44
+ // package managers
45
+ 'pnpm': 'i-vscode-icons:file-type-light-pnpm',
46
+ 'npm': 'i-vscode-icons:file-type-npm',
47
+ 'yarn': 'i-vscode-icons:file-type-yarn',
48
+ 'bun': 'i-vscode-icons:file-type-bun',
49
+ 'deno': 'i-vscode-icons:file-type-deno',
50
+ // frameworks
51
+ 'vue': 'i-vscode-icons:file-type-vue',
52
+ 'svelte': 'i-vscode-icons:file-type-svelte',
53
+ 'angular': 'i-vscode-icons:file-type-angular',
54
+ 'react': 'i-vscode-icons:file-type-reactjs',
55
+ 'next': 'i-vscode-icons:file-type-light-next',
56
+ 'nuxt': 'i-vscode-icons:file-type-nuxt',
57
+ 'solid': 'logos:solidjs-icon',
58
+ 'astro': 'i-vscode-icons:file-type-light-astro',
59
+ // bundlers
60
+ 'rollup': 'i-vscode-icons:file-type-rollup',
61
+ 'webpack': 'i-vscode-icons:file-type-webpack',
62
+ 'vite': 'i-vscode-icons:file-type-vite',
63
+ 'esbuild': 'i-vscode-icons:file-type-esbuild',
64
+ // configuration files
65
+ 'package.json': 'i-vscode-icons:file-type-node',
66
+ 'tsconfig.json': 'i-vscode-icons:file-type-tsconfig',
67
+ '.npmrc': 'i-vscode-icons:file-type-npm',
68
+ '.editorconfig': 'i-vscode-icons:file-type-editorconfig',
69
+ '.eslintrc': 'i-vscode-icons:file-type-eslint',
70
+ '.eslintignore': 'i-vscode-icons:file-type-eslint',
71
+ 'eslint.config': 'i-vscode-icons:file-type-eslint',
72
+ '.gitignore': 'i-vscode-icons:file-type-git',
73
+ '.gitattributes': 'i-vscode-icons:file-type-git',
74
+ '.env': 'i-vscode-icons:file-type-dotenv',
75
+ '.env.example': 'i-vscode-icons:file-type-dotenv',
76
+ '.vscode': 'i-vscode-icons:file-type-vscode',
77
+ 'tailwind.config': 'vscode-icons:file-type-tailwind',
78
+ 'uno.config': 'i-vscode-icons:file-type-unocss',
79
+ 'unocss.config': 'i-vscode-icons:file-type-unocss',
80
+ '.oxlintrc': 'i-vscode-icons:file-type-oxlint',
81
+ 'vue.config': 'i-vscode-icons:file-type-vueconfig',
82
+ // filename extensions
83
+ '.mts': 'i-vscode-icons:file-type-typescript',
84
+ '.cts': 'i-vscode-icons:file-type-typescript',
85
+ '.ts': 'i-vscode-icons:file-type-typescript',
86
+ '.tsx': 'i-vscode-icons:file-type-typescript',
87
+ '.mjs': 'i-vscode-icons:file-type-js',
88
+ '.cjs': 'i-vscode-icons:file-type-js',
89
+ '.json': 'i-vscode-icons:file-type-json',
90
+ '.js': 'i-vscode-icons:file-type-js',
91
+ '.jsx': 'i-vscode-icons:file-type-js',
92
+ '.md': 'i-vscode-icons:file-type-markdown',
93
+ '.py': 'i-vscode-icons:file-type-python',
94
+ '.ico': 'i-vscode-icons:file-type-favicon',
95
+ '.html': 'i-vscode-icons:file-type-html',
96
+ '.css': 'i-vscode-icons:file-type-css',
97
+ '.scss': 'i-vscode-icons:file-type-scss',
98
+ '.yml': 'i-vscode-icons:file-type-light-yaml',
99
+ '.yaml': 'i-vscode-icons:file-type-light-yaml',
100
+ '.php': 'i-vscode-icons:file-type-php',
101
+ }
102
+ ```
103
+
104
+ :::
105
+
106
+ ## Custom Icon
107
+
108
+ You can also specify the icon manually by the following steps:
109
+
110
+ 1. Add the icon to the `uno.config.ts` file:
111
+
112
+ ```ts [uno.config.ts] {3-5}
113
+ import { defineConfig } from 'unocss'
114
+
115
+ export default defineConfig({
116
+ safelist: [
117
+ 'i-vscode-icons:file-type-coverage',
118
+ ],
119
+ })
120
+ ```
121
+
122
+ 2. Use the icon in the code block with the `~icon~` syntax:
123
+
124
+ ````md
125
+ ```sh [npm ~i-vscode-icons:file-type-coverage~]
126
+ npm i @slidev/cli
127
+ ```
128
+ ````
@@ -6,17 +6,13 @@ Slidev injects several global context values for advanced navigation controls.
6
6
 
7
7
  You can access them directly in your slides or components:
8
8
 
9
- ```md
10
- <!-- slides.md -->
11
-
9
+ ```md [slides.md]
12
10
  # Page 1
13
11
 
14
12
  Current page is: {{ $nav.currentPage }}
15
13
  ```
16
14
 
17
- ```vue
18
- <!-- Foo.vue -->
19
-
15
+ ```vue [Foo.vue]
20
16
  <template>
21
17
  <div>Title: {{ $slidev.configs.title }}</div>
22
18
  <button @click="$nav.next">
package/guide/index.md CHANGED
@@ -117,7 +117,7 @@ Slidev provides a set of commands in its CLI. Here are some common ones:
117
117
 
118
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
119
 
120
- ```json
120
+ ```json [package.json]
121
121
  {
122
122
  "scripts": {
123
123
  "dev": "slidev --open",
package/guide/syntax.md CHANGED
@@ -148,6 +148,7 @@ More about code blocks:
148
148
  <LinkCard link="features/shiki-magic-move" />
149
149
  <LinkCard link="features/twoslash" />
150
150
  <LinkCard link="features/import-snippet" />
151
+ <LinkCard link="features/code-groups" />
151
152
 
152
153
  ## LaTeX Blocks {#latex-block}
153
154
 
@@ -29,7 +29,7 @@ An addon can also specify its required Slidev version in the same way as themes.
29
29
 
30
30
  The same as themes, you can preview your addon via a `./slides.md` like this:
31
31
 
32
- ```md
32
+ ```md [slides.md]
33
33
  ---
34
34
  addons:
35
35
  - ./
@@ -17,8 +17,7 @@ Layouts are Vue components, so you can use all the features of Vue in them.
17
17
 
18
18
  In the layout component, use `<slot/>` (the default slot) for the slide content:
19
19
 
20
- ```vue
21
- <!-- default.vue -->
20
+ ```vue [default.vue]
22
21
  <template>
23
22
  <div class="slidev-layout default">
24
23
  <slot />
@@ -28,8 +27,7 @@ In the layout component, use `<slot/>` (the default slot) for the slide content:
28
27
 
29
28
  You can also have [named slots](https://vuejs.org/guide/components/slots.html) for more complex layouts:
30
29
 
31
- ```vue
32
- <!-- split.vue -->
30
+ ```vue [split.vue]
33
31
  <template>
34
32
  <div class="slidev-layout split">
35
33
  <div class="left">
@@ -48,7 +48,7 @@ Basically, the way to provide global styles, layouts, components and configure t
48
48
 
49
49
  To provide default Slidev configurations, you can add a `slidev.defaults` field in the `package.json` file, which will be merged with the user's configurations:
50
50
 
51
- ```json
51
+ ```json [package.json]
52
52
  {
53
53
  "slidev": {
54
54
  "defaults": {
@@ -77,7 +77,7 @@ An error message will be shown when the an incompatible version is used.
77
77
 
78
78
  By default, Slidev assumes themes support both light mode and dark mode. If you only want your theme to be presented in a specific color schema, you need to specify it explicitly in the `package.json`:
79
79
 
80
- ```json
80
+ ```json [package.json]
81
81
  {
82
82
  "slidev": {
83
83
  "colorSchema": "light" // or "dark" or "both"
@@ -89,7 +89,7 @@ By default, Slidev assumes themes support both light mode and dark mode. If you
89
89
 
90
90
  You can preview your theme when developing by using a demo slide deck. To do so, create a `./slides.md` file with the following headmatter:
91
91
 
92
- ```md
92
+ ```md [slides.md]
93
93
  ---
94
94
  theme: ./ # Use the theme in the current directory
95
95
  ---
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@slidev/docs",
3
3
  "type": "module",
4
- "version": "51.7.0",
4
+ "version": "51.8.0",
5
5
  "license": "MIT",
6
6
  "funding": "https://github.com/sponsors/antfu",
7
7
  "homepage": "https://sli.dev",
@@ -17,9 +17,9 @@
17
17
  ],
18
18
  "devDependencies": {
19
19
  "@antfu/utils": "^9.2.0",
20
- "@iconify/json": "^2.2.339",
20
+ "@iconify/json": "^2.2.341",
21
21
  "@shikijs/vitepress-twoslash": "^3.4.2",
22
- "@types/node": "^22.15.18",
22
+ "@types/node": "^22.15.21",
23
23
  "@unocss/reset": "^66.1.2",
24
24
  "@vueuse/core": "^13.2.0",
25
25
  "fast-glob": "^3.3.3",
@@ -31,13 +31,14 @@
31
31
  "unocss": "^66.1.2",
32
32
  "unplugin-icons": "^22.1.0",
33
33
  "unplugin-vue-components": "^28.5.0",
34
- "vite-plugin-inspect": "^11.0.1",
34
+ "vite-plugin-inspect": "^11.1.0",
35
35
  "vitepress": "^2.0.0-alpha.5",
36
- "vitepress-plugin-llms": "^1.2.0",
36
+ "vitepress-plugin-group-icons": "^1.5.5",
37
+ "vitepress-plugin-llms": "^1.3.3",
37
38
  "vue": "^3.5.14",
38
- "@slidev/client": "51.7.0",
39
- "@slidev/types": "51.7.0",
40
- "@slidev/parser": "51.7.0"
39
+ "@slidev/parser": "51.8.0",
40
+ "@slidev/client": "51.8.0",
41
+ "@slidev/types": "51.8.0"
41
42
  },
42
43
  "scripts": {
43
44
  "dev": "vitepress",