vitepress 1.0.0-draft.1 → 1.0.0-draft.4
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/dist/client/app/composables/head.js +2 -2
- package/dist/client/app/data.js +2 -4
- package/dist/client/index.d.ts +8 -0
- package/dist/client/shared.js +22 -0
- package/dist/client/theme-default/Layout.vue +18 -1
- package/dist/client/theme-default/components/VPBackdrop.vue +1 -1
- package/dist/client/theme-default/components/VPBox.vue +59 -0
- package/dist/client/theme-default/components/VPButton.vue +123 -0
- package/dist/client/theme-default/components/VPContent.vue +34 -10
- package/dist/client/theme-default/components/{VPContentDoc.vue → VPDoc.vue} +66 -42
- package/dist/client/theme-default/components/{VPContentDocFooter.vue → VPDocFooter.vue} +3 -2
- package/dist/client/theme-default/components/{VPContentDocOutline.vue → VPDocOutline.vue} +14 -3
- package/dist/client/theme-default/components/VPFooter.vue +53 -0
- package/dist/client/theme-default/components/VPHero.vue +144 -0
- package/dist/client/theme-default/components/VPHome.vue +33 -0
- package/dist/client/theme-default/components/VPHomeFeatures.vue +96 -0
- package/dist/client/theme-default/components/VPHomeHero.vue +17 -0
- package/dist/client/theme-default/components/VPHomeSponsors.vue +93 -0
- package/dist/client/theme-default/components/VPNavBar.vue +2 -1
- package/dist/client/theme-default/components/VPNavBarAppearance.vue +4 -1
- package/dist/client/theme-default/components/VPNavBarExtra.vue +2 -2
- package/dist/client/theme-default/components/VPNavBarSearch.vue +3 -3
- package/dist/client/theme-default/components/VPNavBarTitle.vue +26 -13
- package/dist/client/theme-default/components/VPNavScreenAppearance.vue +4 -1
- package/dist/client/theme-default/components/VPPage.vue +5 -0
- package/dist/client/theme-default/components/VPSidebar.vue +2 -2
- package/dist/client/theme-default/components/VPSponsors.vue +77 -0
- package/dist/client/theme-default/components/VPSponsorsGrid.vue +32 -0
- package/dist/client/theme-default/components/VPSwitchAppearance.vue +3 -3
- package/dist/client/theme-default/components/icons/VPIconHeart.vue +5 -0
- package/dist/client/theme-default/composables/outline.js +12 -20
- package/dist/client/theme-default/composables/sponsor-grid.js +92 -0
- package/dist/client/theme-default/index.js +6 -1
- package/dist/client/theme-default/styles/base.css +3 -0
- package/dist/client/theme-default/styles/components/custom-block.css +90 -0
- package/dist/client/theme-default/styles/{vp-doc.css → components/vp-doc.css} +63 -11
- package/dist/client/theme-default/styles/components/vp-sponsor.css +86 -0
- package/dist/client/theme-default/styles/vars.css +150 -29
- package/dist/client/theme-default/support/utils.js +19 -0
- package/dist/node/cli.js +1 -1
- package/dist/node/index.d.ts +22 -1
- package/dist/node/index.js +1 -1
- package/dist/node/{serve-428d4610.js → serve-b3182d88.js} +50 -8
- package/package.json +2 -1
- package/types/default-theme.d.ts +12 -0
- package/types/shared.d.ts +14 -6
|
@@ -43,39 +43,33 @@
|
|
|
43
43
|
--vp-c-text-dark-3: rgba(235, 235, 235, 0.38);
|
|
44
44
|
--vp-c-text-dark-4: rgba(235, 235, 235, 0.18);
|
|
45
45
|
|
|
46
|
+
--vp-c-indigo: #213547;
|
|
47
|
+
--vp-c-indigo-soft: #476582;
|
|
48
|
+
--vp-c-indigo-light: #aac8e4;
|
|
49
|
+
--vp-c-indigo-lighter: #c9def1;
|
|
50
|
+
--vp-c-indigo-dark: #1d2f3f;
|
|
51
|
+
--vp-c-indigo-darker: #14212e;
|
|
52
|
+
|
|
46
53
|
--vp-c-green: #42b883;
|
|
47
54
|
--vp-c-green-light: #42d392;
|
|
48
55
|
--vp-c-green-lighter: #35eb9a;
|
|
49
56
|
--vp-c-green-dark: #33a06f;
|
|
50
57
|
--vp-c-green-darker: #155f3e;
|
|
51
|
-
|
|
52
|
-
--vp-c-indigo: #213547;
|
|
53
|
-
--vp-c-indigo-soft: #476582;
|
|
54
|
-
--vp-c-indigo-light: #aac8e4;
|
|
55
|
-
|
|
56
|
-
--vp-c-blue: #3b8eed;
|
|
57
|
-
--vp-c-blue-light: #549ced;
|
|
58
|
-
--vp-c-blue-lighter: #50a2ff;
|
|
59
|
-
--vp-c-blue-dark: #3468a3;
|
|
60
|
-
--vp-c-blue-darker: #255489;
|
|
58
|
+
--vp-c-green-dimm: rgba(66, 184, 131, 0.08);
|
|
61
59
|
|
|
62
60
|
--vp-c-yellow: #ffc517;
|
|
63
61
|
--vp-c-yellow-light: #ffe417;
|
|
64
62
|
--vp-c-yellow-lighter: #ffff17;
|
|
65
63
|
--vp-c-yellow-dark: #e0ad15;
|
|
66
|
-
--vp-c-yellow-darker: #
|
|
64
|
+
--vp-c-yellow-darker: #ad850e;
|
|
65
|
+
--vp-c-yellow-dimm: rgba(255, 197, 23, 0.08);
|
|
67
66
|
|
|
68
67
|
--vp-c-red: #ed3c50;
|
|
69
68
|
--vp-c-red-light: #f43771;
|
|
70
69
|
--vp-c-red-lighter: #fd1d7c;
|
|
71
70
|
--vp-c-red-dark: #cd2d3f;
|
|
72
71
|
--vp-c-red-darker: #ab2131;
|
|
73
|
-
|
|
74
|
-
--vp-c-purple: #de41e0;
|
|
75
|
-
--vp-c-purple-light: #e936eb;
|
|
76
|
-
--vp-c-purple-lighter: #f616f8;
|
|
77
|
-
--vp-c-purple-dark: #823c83;
|
|
78
|
-
--vp-c-purple-darker: #602960;
|
|
72
|
+
--vp-c-red-dimm: rgba(237, 60, 80, 0.08);
|
|
79
73
|
}
|
|
80
74
|
|
|
81
75
|
/**
|
|
@@ -109,7 +103,11 @@
|
|
|
109
103
|
|
|
110
104
|
--vp-c-brand: var(--vp-c-green);
|
|
111
105
|
--vp-c-brand-light: var(--vp-c-green-light);
|
|
106
|
+
--vp-c-brand-lighter: var(--vp-c-green-lighter);
|
|
112
107
|
--vp-c-brand-dark: var(--vp-c-green-dark);
|
|
108
|
+
--vp-c-brand-darker: var(--vp-c-green-darker);
|
|
109
|
+
|
|
110
|
+
--vp-c-sponsor: #fd1d7c;
|
|
113
111
|
}
|
|
114
112
|
|
|
115
113
|
.dark {
|
|
@@ -168,8 +166,9 @@
|
|
|
168
166
|
:root {
|
|
169
167
|
--vp-z-index-local-nav: 10;
|
|
170
168
|
--vp-z-index-nav: 20;
|
|
171
|
-
--vp-z-backdrop: 30;
|
|
169
|
+
--vp-z-index-backdrop: 30;
|
|
172
170
|
--vp-z-index-sidebar: 40;
|
|
171
|
+
--vp-z-index-footer: 50;
|
|
173
172
|
}
|
|
174
173
|
|
|
175
174
|
/**
|
|
@@ -177,7 +176,129 @@
|
|
|
177
176
|
* -------------------------------------------------------------------------- */
|
|
178
177
|
|
|
179
178
|
:root {
|
|
180
|
-
--vp-layout-max-width:
|
|
179
|
+
--vp-layout-max-width: 1440px;
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
/**
|
|
183
|
+
* Component: Code
|
|
184
|
+
* -------------------------------------------------------------------------- */
|
|
185
|
+
|
|
186
|
+
:root {
|
|
187
|
+
--vp-code-line-height: 24px;
|
|
188
|
+
--vp-code-font-size: 14px;
|
|
189
|
+
|
|
190
|
+
--vp-code-block-color: var(--vp-c-text-dark-1);
|
|
191
|
+
--vp-code-block-bg: #292d3e;
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
.dark {
|
|
195
|
+
--vp-code-block-bg: var(--vp-c-bg-sidebar);
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
/**
|
|
199
|
+
* Component: Button
|
|
200
|
+
* -------------------------------------------------------------------------- */
|
|
201
|
+
|
|
202
|
+
:root {
|
|
203
|
+
--vp-button-brand-border: var(--vp-c-brand-light);
|
|
204
|
+
--vp-button-brand-text: var(--vp-c-text-dark-1);
|
|
205
|
+
--vp-button-brand-bg: var(--vp-c-brand);
|
|
206
|
+
--vp-button-brand-hover-border: var(--vp-c-brand-light);
|
|
207
|
+
--vp-button-brand-hover-text: var(--vp-c-text-dark-1);
|
|
208
|
+
--vp-button-brand-hover-bg: var(--vp-c-brand-light);
|
|
209
|
+
--vp-button-brand-active-border: var(--vp-c-brand-light);
|
|
210
|
+
--vp-button-brand-active-text: var(--vp-c-text-dark-1);
|
|
211
|
+
--vp-button-brand-active-bg: var(--vp-button-brand-bg);
|
|
212
|
+
|
|
213
|
+
--vp-button-alt-border: var(--vp-c-gray-light-3);
|
|
214
|
+
--vp-button-alt-text: var(--vp-c-text-light-1);
|
|
215
|
+
--vp-button-alt-bg: var(--vp-c-gray-light-5);
|
|
216
|
+
--vp-button-alt-hover-border: var(--vp-c-gray-light-3);
|
|
217
|
+
--vp-button-alt-hover-text: var(--vp-c-text-light-1);
|
|
218
|
+
--vp-button-alt-hover-bg: var(--vp-c-gray-light-4);
|
|
219
|
+
--vp-button-alt-active-border: var(--vp-c-gray-light-3);
|
|
220
|
+
--vp-button-alt-active-text: var(--vp-c-text-light-1);
|
|
221
|
+
--vp-button-alt-active-bg: var(--vp-c-gray-light-3);
|
|
222
|
+
|
|
223
|
+
--vp-button-sponsor-border: var(--vp-c-gray-light-3);
|
|
224
|
+
--vp-button-sponsor-text: var(--vp-c-text-light-2);
|
|
225
|
+
--vp-button-sponsor-bg: transparent;
|
|
226
|
+
--vp-button-sponsor-hover-border: var(--vp-c-sponsor);
|
|
227
|
+
--vp-button-sponsor-hover-text: var(--vp-c-sponsor);
|
|
228
|
+
--vp-button-sponsor-hover-bg: transparent;
|
|
229
|
+
--vp-button-sponsor-active-border: var(--vp-c-sponsor);
|
|
230
|
+
--vp-button-sponsor-active-text: var(--vp-c-sponsor);
|
|
231
|
+
--vp-button-sponsor-active-bg: transparent;
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
.dark {
|
|
235
|
+
--vp-button-brand-border: var(--vp-c-brand-lighter);
|
|
236
|
+
--vp-button-brand-text: var(--vp-c-text-light-1);
|
|
237
|
+
--vp-button-brand-bg: var(--vp-c-brand-light);
|
|
238
|
+
--vp-button-brand-hover-border: var(--vp-c-brand-lighter);
|
|
239
|
+
--vp-button-brand-hover-text: var(--vp-c-text-light-1);
|
|
240
|
+
--vp-button-brand-hover-bg: var(--vp-c-brand-lighter);
|
|
241
|
+
--vp-button-brand-active-border: var(--vp-c-brand-lighter);
|
|
242
|
+
--vp-button-brand-active-text: var(--vp-c-text-light-1);
|
|
243
|
+
--vp-button-brand-active-bg: var(--vp-button-brand-bg);
|
|
244
|
+
|
|
245
|
+
--vp-button-alt-border: var(--vp-c-gray-dark-2);
|
|
246
|
+
--vp-button-alt-text: var(--vp-c-text-dark-1);
|
|
247
|
+
--vp-button-alt-bg: var(--vp-c-bg-mute);
|
|
248
|
+
--vp-button-alt-hover-border: var(--vp-c-gray-dark-2);
|
|
249
|
+
--vp-button-alt-hover-text: var(--vp-c-text-dark-1);
|
|
250
|
+
--vp-button-alt-hover-bg: var(--vp-c-gray-dark-3);
|
|
251
|
+
--vp-button-alt-active-border: var(--vp-c-gray-dark-2);
|
|
252
|
+
--vp-button-alt-active-text: var(--vp-c-text-dark-1);
|
|
253
|
+
--vp-button-alt-active-bg: var(--vp-button-alt-bg);
|
|
254
|
+
|
|
255
|
+
--vp-button-sponsor-border: var(--vp-c-gray-dark-1);
|
|
256
|
+
--vp-button-sponsor-text: var(--vp-c-text-dark-2);
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
/**
|
|
260
|
+
* Component: Custom Block
|
|
261
|
+
* -------------------------------------------------------------------------- */
|
|
262
|
+
|
|
263
|
+
:root {
|
|
264
|
+
--vp-custom-block-code-font-size: 13px;
|
|
265
|
+
|
|
266
|
+
--vp-custom-block-info-border: var(--vp-c-divider-light);
|
|
267
|
+
--vp-custom-block-info-text: var(--vp-c-text-2);
|
|
268
|
+
--vp-custom-block-info-bg: var(--vp-c-white-soft);
|
|
269
|
+
--vp-custom-block-info-code-bg: var(--vp-c-gray-light-4);
|
|
270
|
+
|
|
271
|
+
--vp-custom-block-tip-border: var(--vp-c-green);
|
|
272
|
+
--vp-custom-block-tip-text: var(--vp-c-green-darker);
|
|
273
|
+
--vp-custom-block-tip-bg: var(--vp-c-green-dimm);
|
|
274
|
+
--vp-custom-block-tip-code-bg: var(--vp-custom-block-tip-bg);
|
|
275
|
+
|
|
276
|
+
--vp-custom-block-warning-border: var(--vp-c-yellow);
|
|
277
|
+
--vp-custom-block-warning-text: var(--vp-c-yellow-darker);
|
|
278
|
+
--vp-custom-block-warning-bg: var(--vp-c-yellow-dimm);
|
|
279
|
+
--vp-custom-block-warning-code-bg: var(--vp-custom-block-warning-bg);
|
|
280
|
+
|
|
281
|
+
--vp-custom-block-danger-border: var(--vp-c-red);
|
|
282
|
+
--vp-custom-block-danger-text: var(--vp-c-red-darker);
|
|
283
|
+
--vp-custom-block-danger-bg: var(--vp-c-red-dimm);
|
|
284
|
+
--vp-custom-block-danger-code-bg: var(--vp-custom-block-danger-bg);
|
|
285
|
+
|
|
286
|
+
--vp-custom-block-details-border: var(--vp-custom-block-info-border);
|
|
287
|
+
--vp-custom-block-details-text: var(--vp-custom-block-info-text);
|
|
288
|
+
--vp-custom-block-details-bg: var(--vp-custom-block-info-bg);
|
|
289
|
+
--vp-custom-block-details-code-bg: var(--vp-custom-block-details-bg);
|
|
290
|
+
}
|
|
291
|
+
|
|
292
|
+
.dark {
|
|
293
|
+
--vp-custom-block-info-border: var(--vp-c-divider-light);
|
|
294
|
+
--vp-custom-block-info-bg: var(--vp-c-black-mute);
|
|
295
|
+
--vp-custom-block-info-code-bg: var(--vp-c-gray-dark-4);
|
|
296
|
+
|
|
297
|
+
--vp-custom-block-tip-text: var(--vp-c-green);
|
|
298
|
+
|
|
299
|
+
--vp-custom-block-warning-text: var(--vp-c-yellow);
|
|
300
|
+
|
|
301
|
+
--vp-custom-block-danger-text: var(--vp-c-red);
|
|
181
302
|
}
|
|
182
303
|
|
|
183
304
|
/**
|
|
@@ -185,10 +306,17 @@
|
|
|
185
306
|
* -------------------------------------------------------------------------- */
|
|
186
307
|
|
|
187
308
|
:root {
|
|
309
|
+
--vp-nav-height: var(--vp-nav-height-mobile);
|
|
188
310
|
--vp-nav-height-mobile: 56px;
|
|
189
311
|
--vp-nav-height-desktop: 72px;
|
|
190
312
|
}
|
|
191
313
|
|
|
314
|
+
@media (min-width: 960px) {
|
|
315
|
+
:root {
|
|
316
|
+
--vp-nav-height: var(--vp-nav-height-desktop);
|
|
317
|
+
}
|
|
318
|
+
}
|
|
319
|
+
|
|
192
320
|
/**
|
|
193
321
|
* Component: Sidebar
|
|
194
322
|
* -------------------------------------------------------------------------- */
|
|
@@ -198,17 +326,10 @@
|
|
|
198
326
|
}
|
|
199
327
|
|
|
200
328
|
/**
|
|
201
|
-
* Component:
|
|
329
|
+
* Component: Home
|
|
202
330
|
* -------------------------------------------------------------------------- */
|
|
203
331
|
|
|
204
332
|
:root {
|
|
205
|
-
--vp-
|
|
206
|
-
--vp-
|
|
207
|
-
|
|
208
|
-
--vp-code-block-color: var(--vp-c-text-dark-1);
|
|
209
|
-
--vp-code-block-bg: #292d3e;
|
|
210
|
-
}
|
|
211
|
-
|
|
212
|
-
.dark {
|
|
213
|
-
--vp-code-block-bg: var(--vp-c-bg-sidebar);
|
|
333
|
+
--vp-home-hero-name-color: var(--vp-c-brand);
|
|
334
|
+
--vp-home-hero-name-background: transparent;
|
|
214
335
|
}
|
|
@@ -8,6 +8,25 @@ const hashRef = ref(inBrowser ? location.hash : '');
|
|
|
8
8
|
export function isExternal(path) {
|
|
9
9
|
return OUTBOUND_RE.test(path);
|
|
10
10
|
}
|
|
11
|
+
export function throttleAndDebounce(fn, delay) {
|
|
12
|
+
let timeout;
|
|
13
|
+
let called = false;
|
|
14
|
+
return () => {
|
|
15
|
+
if (timeout) {
|
|
16
|
+
clearTimeout(timeout);
|
|
17
|
+
}
|
|
18
|
+
if (!called) {
|
|
19
|
+
fn();
|
|
20
|
+
called = true;
|
|
21
|
+
setTimeout(() => {
|
|
22
|
+
called = false;
|
|
23
|
+
}, delay);
|
|
24
|
+
}
|
|
25
|
+
else {
|
|
26
|
+
timeout = setTimeout(fn, delay);
|
|
27
|
+
}
|
|
28
|
+
};
|
|
29
|
+
}
|
|
11
30
|
export function isActive(currentPath, matchPath, asRegex = false) {
|
|
12
31
|
if (matchPath === undefined) {
|
|
13
32
|
return false;
|
package/dist/node/cli.js
CHANGED
package/dist/node/index.d.ts
CHANGED
|
@@ -46,6 +46,11 @@ export declare namespace DefaultTheme {
|
|
|
46
46
|
*/
|
|
47
47
|
socialLinks?: SocialLink[]
|
|
48
48
|
|
|
49
|
+
/**
|
|
50
|
+
* The footer configuration.
|
|
51
|
+
*/
|
|
52
|
+
footer?: Footer
|
|
53
|
+
|
|
49
54
|
/**
|
|
50
55
|
* Adds locale menu to the nav. This option should be used when you have
|
|
51
56
|
* your translated sites outside of the project.
|
|
@@ -150,6 +155,13 @@ export declare namespace DefaultTheme {
|
|
|
150
155
|
| 'twitter'
|
|
151
156
|
| 'youtube'
|
|
152
157
|
|
|
158
|
+
// footer --------------------------------------------------------------------
|
|
159
|
+
|
|
160
|
+
export interface Footer {
|
|
161
|
+
message?: string
|
|
162
|
+
copyright?: string
|
|
163
|
+
}
|
|
164
|
+
|
|
153
165
|
// locales -------------------------------------------------------------------
|
|
154
166
|
|
|
155
167
|
export interface LocaleLinks {
|
|
@@ -210,6 +222,7 @@ export declare interface Header {
|
|
|
210
222
|
export declare interface LocaleConfig {
|
|
211
223
|
lang: string
|
|
212
224
|
title?: string
|
|
225
|
+
titleTemplate?: string | boolean
|
|
213
226
|
description?: string
|
|
214
227
|
head?: HeadConfig[]
|
|
215
228
|
label?: string
|
|
@@ -272,17 +285,23 @@ export declare interface SiteConfig<ThemeConfig = any> extends Pick<UserConfig,
|
|
|
272
285
|
|
|
273
286
|
export declare interface SiteData<ThemeConfig = any> {
|
|
274
287
|
base: string
|
|
288
|
+
|
|
275
289
|
/**
|
|
276
290
|
* Language of the site as it should be set on the `html` element.
|
|
291
|
+
*
|
|
277
292
|
* @example `en-US`, `zh-CN`
|
|
278
293
|
*/
|
|
279
294
|
lang: string
|
|
295
|
+
|
|
280
296
|
title: string
|
|
297
|
+
titleTemplate?: string | boolean
|
|
281
298
|
description: string
|
|
282
299
|
head: HeadConfig[]
|
|
300
|
+
appearance: boolean
|
|
283
301
|
themeConfig: ThemeConfig
|
|
284
302
|
scrollOffset: number | string
|
|
285
303
|
locales: Record<string, LocaleConfig>
|
|
304
|
+
|
|
286
305
|
/**
|
|
287
306
|
* Available locales for the site when it has defined `locales` in its
|
|
288
307
|
* `themeConfig`. This object is otherwise empty. Keys are paths like `/` or
|
|
@@ -307,11 +326,13 @@ export declare interface SiteData<ThemeConfig = any> {
|
|
|
307
326
|
|
|
308
327
|
export declare interface UserConfig<ThemeConfig = any> {
|
|
309
328
|
extends?: RawConfigExports<ThemeConfig>;
|
|
310
|
-
lang?: string;
|
|
311
329
|
base?: string;
|
|
330
|
+
lang?: string;
|
|
312
331
|
title?: string;
|
|
332
|
+
titleTemplate?: string | boolean;
|
|
313
333
|
description?: string;
|
|
314
334
|
head?: HeadConfig[];
|
|
335
|
+
appearance?: boolean;
|
|
315
336
|
themeConfig?: ThemeConfig;
|
|
316
337
|
locales?: Record<string, LocaleConfig>;
|
|
317
338
|
markdown?: MarkdownOptions;
|
package/dist/node/index.js
CHANGED
|
@@ -12249,6 +12249,7 @@ globby$2.exports.gitignore = gitignore;
|
|
|
12249
12249
|
var globby = globby$2.exports;
|
|
12250
12250
|
|
|
12251
12251
|
const EXTERNAL_URL_RE = /^https?:/i;
|
|
12252
|
+
const APPEARANCE_KEY = "vitepress-theme-appearance";
|
|
12252
12253
|
const inBrowser = typeof window !== "undefined";
|
|
12253
12254
|
function findMatchRoot(route, roots) {
|
|
12254
12255
|
roots.sort((a, b) => {
|
|
@@ -12292,6 +12293,25 @@ function resolveSiteDataByRoute(siteData, route) {
|
|
|
12292
12293
|
langs: createLangDictionary(siteData)
|
|
12293
12294
|
});
|
|
12294
12295
|
}
|
|
12296
|
+
function createTitle(siteData, pageData) {
|
|
12297
|
+
var _a;
|
|
12298
|
+
const title = pageData.title || siteData.title;
|
|
12299
|
+
const template = (_a = pageData.titleTemplate) != null ? _a : siteData.titleTemplate;
|
|
12300
|
+
const templateString = createTitleTemplate(siteData.title, template);
|
|
12301
|
+
return `${title}${templateString}`;
|
|
12302
|
+
}
|
|
12303
|
+
function createTitleTemplate(siteTitle, template) {
|
|
12304
|
+
if (template === false) {
|
|
12305
|
+
return "";
|
|
12306
|
+
}
|
|
12307
|
+
if (template === true || template === void 0) {
|
|
12308
|
+
return ` | ${siteTitle}`;
|
|
12309
|
+
}
|
|
12310
|
+
if (siteTitle === template) {
|
|
12311
|
+
return "";
|
|
12312
|
+
}
|
|
12313
|
+
return ` | ${template}`;
|
|
12314
|
+
}
|
|
12295
12315
|
function cleanRoute(siteData, route) {
|
|
12296
12316
|
if (!inBrowser) {
|
|
12297
12317
|
return route;
|
|
@@ -13449,19 +13469,42 @@ function isObject$3(value) {
|
|
|
13449
13469
|
return Object.prototype.toString.call(value) === "[object Object]";
|
|
13450
13470
|
}
|
|
13451
13471
|
async function resolveSiteData(root, userConfig, command = "serve", mode = "development") {
|
|
13472
|
+
var _a;
|
|
13452
13473
|
userConfig = userConfig || (await resolveUserConfig(root, command, mode))[0];
|
|
13453
13474
|
return {
|
|
13454
13475
|
lang: userConfig.lang || "en-US",
|
|
13455
13476
|
title: userConfig.title || "VitePress",
|
|
13477
|
+
titleTemplate: userConfig.titleTemplate,
|
|
13456
13478
|
description: userConfig.description || "A VitePress site",
|
|
13457
13479
|
base: userConfig.base ? userConfig.base.replace(/([^/])$/, "$1/") : "/",
|
|
13458
|
-
head: userConfig
|
|
13480
|
+
head: resolveSiteDataHead(userConfig),
|
|
13481
|
+
appearance: (_a = userConfig.appearance) != null ? _a : true,
|
|
13459
13482
|
themeConfig: userConfig.themeConfig || {},
|
|
13460
13483
|
locales: userConfig.locales || {},
|
|
13461
13484
|
langs: createLangDictionary(userConfig),
|
|
13462
13485
|
scrollOffset: userConfig.scrollOffset || 90
|
|
13463
13486
|
};
|
|
13464
13487
|
}
|
|
13488
|
+
function resolveSiteDataHead(userConfig) {
|
|
13489
|
+
var _a, _b;
|
|
13490
|
+
const head = (_a = userConfig == null ? void 0 : userConfig.head) != null ? _a : [];
|
|
13491
|
+
if ((_b = userConfig == null ? void 0 : userConfig.appearance) != null ? _b : true) {
|
|
13492
|
+
head.push([
|
|
13493
|
+
"script",
|
|
13494
|
+
{},
|
|
13495
|
+
`
|
|
13496
|
+
;(() => {
|
|
13497
|
+
const saved = localStorage.getItem('${APPEARANCE_KEY}')
|
|
13498
|
+
const prefereDark = window.matchMedia('(prefers-color-scheme: dark)').matches
|
|
13499
|
+
if (!saved || saved === 'auto' ? prefereDark : saved === 'dark') {
|
|
13500
|
+
document.documentElement.classList.add('dark')
|
|
13501
|
+
}
|
|
13502
|
+
})()
|
|
13503
|
+
`
|
|
13504
|
+
]);
|
|
13505
|
+
}
|
|
13506
|
+
return head;
|
|
13507
|
+
}
|
|
13465
13508
|
|
|
13466
13509
|
var toString = Object.prototype.toString;
|
|
13467
13510
|
|
|
@@ -34933,7 +34976,7 @@ var markdownItContainer = function container_plugin(md, name, options) {
|
|
|
34933
34976
|
};
|
|
34934
34977
|
|
|
34935
34978
|
const containerPlugin = (md) => {
|
|
34936
|
-
md.use(...createContainer("tip", "TIP")).use(...createContainer("info", "INFO")).use(...createContainer("warning", "WARNING")).use(...createContainer("danger", "
|
|
34979
|
+
md.use(...createContainer("tip", "TIP")).use(...createContainer("info", "INFO")).use(...createContainer("warning", "WARNING")).use(...createContainer("danger", "DANGER")).use(...createContainer("details", "Details")).use(markdownItContainer, "v-pre", {
|
|
34937
34980
|
render: (tokens, idx) => tokens[idx].nesting === 1 ? `<div v-pre>
|
|
34938
34981
|
` : `</div>
|
|
34939
34982
|
`
|
|
@@ -34949,7 +34992,7 @@ function createContainer(klass, defaultTitle) {
|
|
|
34949
34992
|
const info = token.info.trim().slice(klass.length).trim();
|
|
34950
34993
|
if (token.nesting === 1) {
|
|
34951
34994
|
if (klass === "details") {
|
|
34952
|
-
return `<details class="${klass} custom-block">${info ? `<summary>${info}</summary>` :
|
|
34995
|
+
return `<details class="${klass} custom-block">${info ? `<summary>${info}</summary>` : `<summary>Details</summary>`}
|
|
34953
34996
|
`;
|
|
34954
34997
|
}
|
|
34955
34998
|
return `<div class="${klass} custom-block"><p class="custom-block-title">${info || defaultTitle}</p>
|
|
@@ -37180,6 +37223,7 @@ function createMarkdownToVueRenderFn(srcDir, options = {}, pages, userDefines, i
|
|
|
37180
37223
|
}
|
|
37181
37224
|
const pageData = {
|
|
37182
37225
|
title: inferTitle(frontmatter, content),
|
|
37226
|
+
titleTemplate: frontmatter.titleTemplate,
|
|
37183
37227
|
description: inferDescription(frontmatter),
|
|
37184
37228
|
frontmatter,
|
|
37185
37229
|
headers: data.headers || [],
|
|
@@ -37228,9 +37272,6 @@ const inferTitle = (frontmatter, content) => {
|
|
|
37228
37272
|
if (frontmatter.title) {
|
|
37229
37273
|
return deeplyParseHeader(frontmatter.title);
|
|
37230
37274
|
}
|
|
37231
|
-
if (frontmatter.home) {
|
|
37232
|
-
return "Home";
|
|
37233
|
-
}
|
|
37234
37275
|
const match = content.match(/^\s*#+\s+(.*)/m);
|
|
37235
37276
|
if (match) {
|
|
37236
37277
|
return deeplyParseHeader(match[1].trim());
|
|
@@ -40928,7 +40969,8 @@ async function renderPage(config, page, result, appChunk, cssChunk, pageToHashMa
|
|
|
40928
40969
|
return `<link rel="prefetch" href="${siteData.base}${file}">`;
|
|
40929
40970
|
}).join("\n ");
|
|
40930
40971
|
const stylesheetLink = cssChunk ? `<link rel="stylesheet" href="${siteData.base}${cssChunk.fileName}">` : "";
|
|
40931
|
-
const title =
|
|
40972
|
+
const title = createTitle(siteData, pageData);
|
|
40973
|
+
const description = pageData.description || siteData.description;
|
|
40932
40974
|
const head = addSocialTags(title, ...siteData.head, ...filterOutHeadDescription(pageData.frontmatter.head));
|
|
40933
40975
|
let inlinedScript = "";
|
|
40934
40976
|
if (config.mpa && result) {
|
|
@@ -40949,7 +40991,7 @@ async function renderPage(config, page, result, appChunk, cssChunk, pageToHashMa
|
|
|
40949
40991
|
<meta charset="utf-8">
|
|
40950
40992
|
<meta name="viewport" content="width=device-width,initial-scale=1">
|
|
40951
40993
|
<title>${title}</title>
|
|
40952
|
-
<meta name="description" content="${
|
|
40994
|
+
<meta name="description" content="${description}">
|
|
40953
40995
|
${stylesheetLink}
|
|
40954
40996
|
${preloadLinksString}
|
|
40955
40997
|
${prefetchLinkString}
|
package/package.json
CHANGED
package/types/default-theme.d.ts
CHANGED
|
@@ -29,6 +29,11 @@ export namespace DefaultTheme {
|
|
|
29
29
|
*/
|
|
30
30
|
socialLinks?: SocialLink[]
|
|
31
31
|
|
|
32
|
+
/**
|
|
33
|
+
* The footer configuration.
|
|
34
|
+
*/
|
|
35
|
+
footer?: Footer
|
|
36
|
+
|
|
32
37
|
/**
|
|
33
38
|
* Adds locale menu to the nav. This option should be used when you have
|
|
34
39
|
* your translated sites outside of the project.
|
|
@@ -133,6 +138,13 @@ export namespace DefaultTheme {
|
|
|
133
138
|
| 'twitter'
|
|
134
139
|
| 'youtube'
|
|
135
140
|
|
|
141
|
+
// footer --------------------------------------------------------------------
|
|
142
|
+
|
|
143
|
+
export interface Footer {
|
|
144
|
+
message?: string
|
|
145
|
+
copyright?: string
|
|
146
|
+
}
|
|
147
|
+
|
|
136
148
|
// locales -------------------------------------------------------------------
|
|
137
149
|
|
|
138
150
|
export interface LocaleLinks {
|
package/types/shared.d.ts
CHANGED
|
@@ -5,25 +5,38 @@ export { DefaultTheme } from './default-theme'
|
|
|
5
5
|
export interface PageData {
|
|
6
6
|
relativePath: string
|
|
7
7
|
title: string
|
|
8
|
+
titleTemplate?: string | boolean
|
|
8
9
|
description: string
|
|
9
10
|
headers: Header[]
|
|
10
11
|
frontmatter: Record<string, any>
|
|
11
12
|
lastUpdated?: number
|
|
12
13
|
}
|
|
13
14
|
|
|
15
|
+
export interface Header {
|
|
16
|
+
level: number
|
|
17
|
+
title: string
|
|
18
|
+
slug: string
|
|
19
|
+
}
|
|
20
|
+
|
|
14
21
|
export interface SiteData<ThemeConfig = any> {
|
|
15
22
|
base: string
|
|
23
|
+
|
|
16
24
|
/**
|
|
17
25
|
* Language of the site as it should be set on the `html` element.
|
|
26
|
+
*
|
|
18
27
|
* @example `en-US`, `zh-CN`
|
|
19
28
|
*/
|
|
20
29
|
lang: string
|
|
30
|
+
|
|
21
31
|
title: string
|
|
32
|
+
titleTemplate?: string | boolean
|
|
22
33
|
description: string
|
|
23
34
|
head: HeadConfig[]
|
|
35
|
+
appearance: boolean
|
|
24
36
|
themeConfig: ThemeConfig
|
|
25
37
|
scrollOffset: number | string
|
|
26
38
|
locales: Record<string, LocaleConfig>
|
|
39
|
+
|
|
27
40
|
/**
|
|
28
41
|
* Available locales for the site when it has defined `locales` in its
|
|
29
42
|
* `themeConfig`. This object is otherwise empty. Keys are paths like `/` or
|
|
@@ -50,15 +63,10 @@ export type HeadConfig =
|
|
|
50
63
|
| [string, Record<string, string>]
|
|
51
64
|
| [string, Record<string, string>, string]
|
|
52
65
|
|
|
53
|
-
export interface Header {
|
|
54
|
-
level: number
|
|
55
|
-
title: string
|
|
56
|
-
slug: string
|
|
57
|
-
}
|
|
58
|
-
|
|
59
66
|
export interface LocaleConfig {
|
|
60
67
|
lang: string
|
|
61
68
|
title?: string
|
|
69
|
+
titleTemplate?: string | boolean
|
|
62
70
|
description?: string
|
|
63
71
|
head?: HeadConfig[]
|
|
64
72
|
label?: string
|