返回 slidev
config.ts
根目录 / docs / .vitepress / config.ts
1 import type { DefaultTheme } from 'vitepress'
2 import { fileURLToPath } from 'node:url'
3 import { transformerTwoslash } from '@shikijs/vitepress-twoslash'
4 import { defineConfig } from 'vitepress'
5 import { groupIconMdPlugin } from 'vitepress-plugin-group-icons'
6 import { version } from '../package.json'
7 import Customizations from './customizations'
8 import { Advanced, BuiltIn, Guides, Resources } from './pages'
9 import { getSidebarObject } from './sidebar-gen'
10
11 export const slidebars: DefaultTheme.SidebarItem[] = [
12 {
13 text: 'Guide',
14 items: Guides,
15 },
16 {
17 text: 'Advanced',
18 items: Advanced,
19 },
20 {
21 text: 'Customizations',
22 items: Customizations,
23 },
24 {
25 text: 'Built-in',
26 items: BuiltIn,
27 },
28 {
29 text: 'Resources',
30 items: Resources,
31 },
32 ]
33
34 export default defineConfig({
35 title: 'Slidev',
36 description: 'Presentation slides for developers',
37 head: [
38 [
39 'link',
40 { rel: 'icon', type: 'image/png', href: '/favicon.png' },
41 ],
42 [
43 'meta',
44 { name: 'author', content: 'Anthony Fu' },
45 ],
46 [
47 'meta',
48 { property: 'og:title', content: 'Slidev' },
49 ],
50 [
51 'meta',
52 { property: 'og:image', content: 'https://sli.dev/og-image.png' },
53 ],
54 [
55 'meta',
56 { property: 'og:description', content: 'Presentation slides for developers' },
57 ],
58 [
59 'meta',
60 { name: 'twitter:card', content: 'summary_large_image' },
61 ],
62 [
63 'meta',
64 { name: 'twitter:creator', content: '@slidevjs' },
65 ],
66 [
67 'meta',
68 { name: 'twitter:image', content: 'https://sli.dev/og-image.png' },
69 ],
70 [
71 'link',
72 { rel: 'dns-prefetch', href: 'https://fonts.gstatic.com' },
73 ],
74 [
75 'link',
76 { rel: 'preconnect', crossorigin: 'anonymous', href: 'https://fonts.gstatic.com' },
77 ],
78 [
79 'link',
80 { href: 'https://fonts.googleapis.com/css2?family=IBM+Plex+Mono:wght@200;400;500&family=Inter:wght@200;400;500;600', rel: 'stylesheet' },
81 ],
82 ],
83 markdown: {
84 theme: {
85 light: 'vitesse-light',
86 dark: 'vitesse-dark',
87 },
88 async shikiSetup(shiki) {
89 await shiki.loadLanguage(
90 'html',
91 'xml',
92 'vue',
93 'markdown',
94 'mermaid',
95 'latex',
96 )
97 },
98 codeTransformers: [
99 transformerTwoslash({
100 twoslashOptions: {
101 // The @slidev/* installed in docs package are very old and should only be used in the homepage demo
102 vfsRoot: fileURLToPath(import.meta.url),
103 compilerOptions: {
104 resolveJsonModule: true,
105 moduleResolution: /* Bundler */ 100,
106 ignoreDeprecations: '6.0',
107 },
108 },
109 }),
110 ],
111 config(md) {
112 md.use(groupIconMdPlugin)
113 },
114 },
115 cleanUrls: true,
116 themeConfig: {
117 logo: '/logo.svg',
118 editLink: {
119 pattern: 'https://github.com/slidevjs/slidev/edit/main/docs/:path',
120 text: 'Suggest changes to this page',
121 },
122
123 search: {
124 provider: 'local',
125 },
126
127 nav: [
128 {
129 text: '📖 Guide',
130 items: [
131 ...Guides,
132 {
133 text: 'Advanced',
134 items: Advanced,
135 },
136 ],
137 },
138 {
139 text: '✨ Features',
140 link: '/features/',
141 },
142 {
143 text: 'Reference',
144 items: [
145 {
146 text: 'Built-in',
147 items: BuiltIn,
148 },
149 {
150 text: 'Customize',
151 items: Customizations,
152 },
153 ],
154 },
155 {
156 text: 'Resources',
157 items: Resources,
158 },
159 ],
160
161 socialLinks: [
162 { icon: 'github', link: 'https://github.com/slidevjs/slidev' },
163 { icon: 'twitter', link: 'https://x.com/slidevjs' },
164 { icon: 'discord', link: 'https://chat.sli.dev' },
165 ],
166
167 sidebar: {
168 '/guide/': slidebars,
169 '/themes/': slidebars,
170 '/addons/': slidebars,
171 '/custom/': slidebars,
172 '/builtin/': slidebars,
173 '/resources/': slidebars,
174 // eslint-disable-next-line antfu/no-top-level-await
175 ...await getSidebarObject(),
176 '/features/': [],
177 '/': slidebars,
178 },
179
180 footer: {
181 message: 'Released under the MIT License.',
182 copyright: 'Copyright © 2020-2025 Anthony Fu.',
183 },
184 },
185
186 locales: {
187 root: {
188 label: `English (v${version})`,
189 },
190 zh: {
191 label: '简体中文',
192 link: 'https://cn.sli.dev/',
193 },
194 ja: {
195 label: '日本語',
196 link: 'https://ja.sli.dev/',
197 },
198 },
199 })
200
200 lines TYPESCRIPT