vitepress 0.22.4 → 1.0.0-alpha.1
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/README.md +3 -1
- package/bin/vitepress.js +1 -1
- package/client.d.ts +2 -3
- package/dist/client/app/components/ClientOnly.js +1 -1
- package/dist/client/app/composables/head.js +2 -2
- package/dist/client/app/data.js +2 -4
- package/dist/client/app/index.js +2 -6
- package/dist/client/app/router.js +3 -3
- package/dist/client/index.d.ts +123 -129
- package/dist/client/index.js +1 -2
- package/dist/client/shared.js +22 -0
- package/dist/client/theme-default/Layout.vue +46 -180
- package/dist/client/theme-default/NotFound.vue +77 -16
- package/dist/client/theme-default/components/VPAlgoliaSearchBox.vue +127 -0
- package/dist/client/theme-default/components/VPBackdrop.vue +39 -0
- package/dist/client/theme-default/components/VPBox.vue +55 -0
- package/dist/client/theme-default/components/VPButton.vue +122 -0
- package/dist/client/theme-default/components/VPCarbonAds.vue +90 -0
- package/dist/client/theme-default/components/VPContent.vue +78 -0
- package/dist/client/theme-default/components/VPDoc.vue +191 -0
- package/dist/client/theme-default/components/VPDocAside.vue +46 -0
- package/dist/client/theme-default/components/VPDocAsideCarbonAds.vue +13 -0
- package/dist/client/theme-default/components/VPDocAsideOutline.vue +124 -0
- package/dist/client/theme-default/components/VPDocAsideSponsors.vue +32 -0
- package/dist/client/theme-default/components/VPDocFooter.vue +159 -0
- package/dist/client/theme-default/components/VPDocFooterLastUpdated.vue +43 -0
- package/dist/client/theme-default/components/VPFlyout.vue +148 -0
- package/dist/client/theme-default/components/VPFooter.vue +53 -0
- package/dist/client/theme-default/components/VPHero.vue +310 -0
- package/dist/client/theme-default/components/VPHome.vue +33 -0
- package/dist/client/theme-default/components/VPHomeFeatures.vue +97 -0
- package/dist/client/theme-default/components/VPHomeHero.vue +18 -0
- package/dist/client/theme-default/components/VPHomeSponsors.vue +93 -0
- package/dist/client/theme-default/components/VPLink.vue +38 -0
- package/dist/client/theme-default/components/VPLocalNav.vue +108 -0
- package/dist/client/theme-default/components/VPMenu.vue +74 -0
- package/dist/client/theme-default/components/VPMenuGroup.vue +46 -0
- package/dist/client/theme-default/components/VPMenuLink.vue +55 -0
- package/dist/client/theme-default/components/VPNav.vue +50 -0
- package/dist/client/theme-default/components/VPNavBar.vue +122 -0
- package/dist/client/theme-default/components/VPNavBarAppearance.vue +25 -0
- package/dist/client/theme-default/components/VPNavBarExtra.vue +82 -0
- package/dist/client/theme-default/components/VPNavBarHamburger.vue +79 -0
- package/dist/client/theme-default/components/VPNavBarMenu.vue +29 -0
- package/dist/client/theme-default/components/VPNavBarMenuGroup.vue +12 -0
- package/dist/client/theme-default/components/VPNavBarMenuLink.vue +56 -0
- package/dist/client/theme-default/components/VPNavBarSearch.vue +270 -0
- package/dist/client/theme-default/components/VPNavBarSocialLinks.vue +27 -0
- package/dist/client/theme-default/components/VPNavBarTitle.vue +60 -0
- package/dist/client/theme-default/components/VPNavBarTranslations.vue +45 -0
- package/dist/client/theme-default/components/VPNavScreen.vue +100 -0
- package/dist/client/theme-default/components/VPNavScreenAppearance.vue +33 -0
- package/dist/client/theme-default/components/VPNavScreenMenu.vue +24 -0
- package/dist/client/theme-default/components/VPNavScreenMenuGroup.vue +117 -0
- package/dist/client/theme-default/components/VPNavScreenMenuGroupLink.vue +33 -0
- package/dist/client/theme-default/components/VPNavScreenMenuGroupSection.vue +35 -0
- package/dist/client/theme-default/components/VPNavScreenMenuLink.vue +34 -0
- package/dist/client/theme-default/components/VPNavScreenSocialLinks.vue +14 -0
- package/dist/client/theme-default/components/VPNavScreenTranslations.vue +73 -0
- package/dist/client/theme-default/components/VPPage.vue +5 -0
- package/dist/client/theme-default/components/VPSidebar.vue +124 -0
- package/dist/client/theme-default/components/VPSidebarGroup.vue +107 -0
- package/dist/client/theme-default/components/VPSidebarLink.vue +50 -0
- package/dist/client/theme-default/components/VPSkipLink.vue +72 -0
- package/dist/client/theme-default/components/VPSocialLink.vue +63 -0
- package/dist/client/theme-default/components/VPSocialLinks.vue +27 -0
- package/dist/client/theme-default/components/VPSponsors.vue +52 -0
- package/dist/client/theme-default/components/VPSponsorsGrid.vue +32 -0
- package/dist/client/theme-default/components/VPSwitch.vue +66 -0
- package/dist/client/theme-default/components/VPSwitchAppearance.vue +74 -0
- package/dist/client/theme-default/components/icons/VPIconAlignJustify.vue +8 -0
- package/dist/client/theme-default/components/icons/VPIconAlignLeft.vue +8 -0
- package/dist/client/theme-default/components/icons/VPIconAlignRight.vue +8 -0
- package/dist/client/theme-default/components/icons/{ArrowLeft.vue → VPIconArrowLeft.vue} +0 -0
- package/dist/client/theme-default/components/icons/{ArrowRight.vue → VPIconArrowRight.vue} +0 -0
- package/dist/client/theme-default/components/icons/VPIconChevronDown.vue +5 -0
- package/dist/client/theme-default/components/icons/VPIconChevronLeft.vue +5 -0
- package/dist/client/theme-default/components/icons/VPIconChevronRight.vue +5 -0
- package/dist/client/theme-default/components/icons/VPIconChevronUp.vue +5 -0
- package/dist/client/theme-default/components/icons/VPIconDiscord.vue +5 -0
- package/dist/client/theme-default/components/icons/VPIconEdit.vue +6 -0
- package/dist/client/theme-default/components/icons/VPIconExternalLink.vue +13 -0
- package/dist/client/theme-default/components/icons/VPIconFacebook.vue +5 -0
- package/dist/client/theme-default/components/icons/VPIconGitHub.vue +5 -0
- package/dist/client/theme-default/components/icons/VPIconHeart.vue +5 -0
- package/dist/client/theme-default/components/icons/VPIconInstagram.vue +5 -0
- package/dist/client/theme-default/components/icons/VPIconLanguages.vue +9 -0
- package/dist/client/theme-default/components/icons/VPIconLinkedIn.vue +5 -0
- package/dist/client/theme-default/components/icons/VPIconMinus.vue +5 -0
- package/dist/client/theme-default/components/icons/VPIconMinusSquare.vue +6 -0
- package/dist/client/theme-default/components/icons/VPIconMoon.vue +5 -0
- package/dist/client/theme-default/components/icons/VPIconMoreHorizontal.vue +7 -0
- package/dist/client/theme-default/components/icons/VPIconPlus.vue +5 -0
- package/dist/client/theme-default/components/icons/VPIconPlusSquare.vue +6 -0
- package/dist/client/theme-default/components/icons/VPIconSlack.vue +5 -0
- package/dist/client/theme-default/components/icons/VPIconSun.vue +13 -0
- package/dist/client/theme-default/components/icons/VPIconTwitter.vue +5 -0
- package/dist/client/theme-default/components/icons/VPIconYouTube.vue +5 -0
- package/dist/client/theme-default/composables/aside.js +17 -0
- package/dist/client/theme-default/composables/copy-code.js +33 -0
- package/dist/client/theme-default/composables/edit-link.js +22 -0
- package/dist/client/theme-default/composables/flyout.js +40 -0
- package/dist/client/theme-default/composables/nav.js +27 -1
- package/dist/client/theme-default/composables/outline.js +122 -0
- package/dist/client/theme-default/composables/prev-next.js +18 -0
- package/dist/client/theme-default/composables/sidebar.js +57 -0
- package/dist/client/theme-default/composables/sponsor-grid.js +94 -0
- package/dist/client/theme-default/fonts/inter-cyrillic-ext.woff2 +0 -0
- package/dist/client/theme-default/fonts/inter-cyrillic.woff2 +0 -0
- package/dist/client/theme-default/fonts/inter-greek-ext.woff2 +0 -0
- package/dist/client/theme-default/fonts/inter-greek.woff2 +0 -0
- package/dist/client/theme-default/fonts/inter-latin-ext.woff2 +0 -0
- package/dist/client/theme-default/fonts/inter-latin.woff2 +0 -0
- package/dist/client/theme-default/fonts/inter-vietnamese.woff2 +0 -0
- package/dist/client/theme-default/index.js +11 -4
- package/dist/client/theme-default/styles/base.css +215 -0
- package/dist/client/theme-default/styles/components/custom-block.css +90 -0
- package/dist/client/theme-default/styles/components/vp-code.css +7 -0
- package/dist/client/theme-default/styles/components/vp-doc.css +463 -0
- package/dist/client/theme-default/styles/components/vp-sponsor.css +130 -0
- package/dist/client/theme-default/styles/fonts.css +67 -0
- package/dist/client/theme-default/styles/utils.css +9 -0
- package/dist/client/theme-default/styles/vars.css +340 -54
- package/dist/client/theme-default/support/sidebar.js +29 -0
- package/dist/client/theme-default/support/utils.js +62 -0
- package/dist/node/cli.js +33 -37
- package/dist/node/index.d.ts +388 -318
- package/dist/node/index.js +22 -37
- package/dist/node/serve-e8d58be3.js +64802 -0
- package/dist/node-cjs/cli.cjs +304 -0
- package/dist/node-cjs/index.cjs +38 -0
- package/dist/{node/serve-3035f99b.js → node-cjs/serve-2fc02922.cjs} +41769 -32932
- package/package.json +54 -41
- package/theme.d.ts +7 -2
- package/types/default-theme.d.ts +137 -74
- package/types/shared.d.ts +14 -6
- package/dist/client/theme-default/components/AlgoliaSearchBox.vue +0 -188
- package/dist/client/theme-default/components/BuySellAds.vue +0 -152
- package/dist/client/theme-default/components/CarbonAds.vue +0 -99
- package/dist/client/theme-default/components/EditLink.vue +0 -38
- package/dist/client/theme-default/components/Home.vue +0 -31
- package/dist/client/theme-default/components/HomeFeatures.vue +0 -143
- package/dist/client/theme-default/components/HomeFooter.vue +0 -50
- package/dist/client/theme-default/components/HomeHero.vue +0 -161
- package/dist/client/theme-default/components/LastUpdated.vue +0 -60
- package/dist/client/theme-default/components/NavBar.vue +0 -60
- package/dist/client/theme-default/components/NavBarTitle.vue +0 -41
- package/dist/client/theme-default/components/NavDropdownLink.vue +0 -135
- package/dist/client/theme-default/components/NavDropdownLinkItem.vue +0 -76
- package/dist/client/theme-default/components/NavLink.vue +0 -61
- package/dist/client/theme-default/components/NavLinks.vue +0 -52
- package/dist/client/theme-default/components/NextAndPrevLinks.vue +0 -88
- package/dist/client/theme-default/components/Page.vue +0 -53
- package/dist/client/theme-default/components/PageFooter.vue +0 -44
- package/dist/client/theme-default/components/SideBar.vue +0 -60
- package/dist/client/theme-default/components/SideBarLink.js +0 -68
- package/dist/client/theme-default/components/SideBarLinks.vue +0 -12
- package/dist/client/theme-default/components/ToggleSideBarButton.vue +0 -46
- package/dist/client/theme-default/components/icons/OutboundLink.vue +0 -31
- package/dist/client/theme-default/composables/activeSidebarLink.js +0 -99
- package/dist/client/theme-default/composables/editLink.js +0 -49
- package/dist/client/theme-default/composables/navLink.js +0 -42
- package/dist/client/theme-default/composables/nextAndPrevLinks.js +0 -37
- package/dist/client/theme-default/composables/repo.js +0 -38
- package/dist/client/theme-default/composables/sideBar.js +0 -57
- package/dist/client/theme-default/styles/code.css +0 -299
- package/dist/client/theme-default/styles/custom-blocks.css +0 -76
- package/dist/client/theme-default/styles/layout.css +0 -236
- package/dist/client/theme-default/styles/sidebar-links.css +0 -107
- package/dist/client/theme-default/support/sideBar.js +0 -46
- package/dist/client/theme-default/utils.js +0 -63
package/README.md
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
# (
|
|
1
|
+
# VitePress (alpha) 📝💨
|
|
2
2
|
|
|
3
3
|
[](https://github.com/vuejs/vitepress/actions)
|
|
4
4
|
[](https://www.npmjs.com/package/vitepress)
|
|
@@ -7,6 +7,8 @@
|
|
|
7
7
|
|
|
8
8
|
VitePress is [VuePress](https://vuepress.vuejs.org)' spiritual successor, built on top of [vite](https://github.com/vitejs/vite).
|
|
9
9
|
|
|
10
|
+
Currently, it's in the `alpha` stage. It is already suitable for out-of-the-box documentation use, but the config and theming API may still change between minor releases.
|
|
11
|
+
|
|
10
12
|
## Documentation
|
|
11
13
|
|
|
12
14
|
To check out docs, visit [vitepress.vuejs.org](https://vitepress.vuejs.org).
|
package/bin/vitepress.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
|
|
2
|
+
import('../dist/node/cli.js')
|
package/client.d.ts
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
// re-export vite client types
|
|
2
|
-
//
|
|
3
|
-
// in project root
|
|
1
|
+
// re-export vite client types. with strict installers like pnpm, user won't
|
|
2
|
+
// be able to reference vite/client in project root.
|
|
4
3
|
/// <reference types="vite/client" />
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { watchEffect } from 'vue';
|
|
2
|
+
import { createTitle } from '../../shared';
|
|
2
3
|
export function useUpdateHead(route, siteDataByRouteRef) {
|
|
3
4
|
let managedHeadTags = [];
|
|
4
5
|
let isFirstUpdate = true;
|
|
@@ -50,11 +51,10 @@ export function useUpdateHead(route, siteDataByRouteRef) {
|
|
|
50
51
|
watchEffect(() => {
|
|
51
52
|
const pageData = route.data;
|
|
52
53
|
const siteData = siteDataByRouteRef.value;
|
|
53
|
-
const pageTitle = pageData && pageData.title;
|
|
54
54
|
const pageDescription = pageData && pageData.description;
|
|
55
55
|
const frontmatterHead = pageData && pageData.frontmatter.head;
|
|
56
56
|
// update title and description
|
|
57
|
-
document.title = (
|
|
57
|
+
document.title = createTitle(siteData, pageData);
|
|
58
58
|
document
|
|
59
59
|
.querySelector(`meta[name=description]`)
|
|
60
60
|
.setAttribute('content', pageDescription || siteData.description);
|
package/dist/client/app/data.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { shallowRef, readonly, computed, inject } from 'vue';
|
|
2
2
|
import serializedSiteData from '@siteData';
|
|
3
|
-
import { resolveSiteDataByRoute } from '../shared';
|
|
3
|
+
import { resolveSiteDataByRoute, createTitle } from '../shared';
|
|
4
4
|
import { withBase } from './utils';
|
|
5
5
|
export const dataSymbol = Symbol();
|
|
6
6
|
export const siteDataRef = shallowRef(parse(serializedSiteData));
|
|
@@ -29,9 +29,7 @@ export function initData(route) {
|
|
|
29
29
|
return withBase(path || '/');
|
|
30
30
|
}),
|
|
31
31
|
title: computed(() => {
|
|
32
|
-
return route.data
|
|
33
|
-
? route.data.title + ' | ' + site.value.title
|
|
34
|
-
: site.value.title;
|
|
32
|
+
return createTitle(site.value, route.data);
|
|
35
33
|
}),
|
|
36
34
|
description: computed(() => {
|
|
37
35
|
return route.data.description || site.value.description;
|
package/dist/client/app/index.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { createApp as createClientApp, createSSRApp, defineAsyncComponent, h, onMounted, watch } from 'vue';
|
|
2
|
+
import Theme from '/@theme/index';
|
|
2
3
|
import { inBrowser, pathToFile } from './utils';
|
|
3
4
|
import { RouterSymbol, createRouter } from './router';
|
|
4
5
|
import { siteDataRef, useData } from './data';
|
|
5
6
|
import { useUpdateHead } from './composables/head';
|
|
6
|
-
import Theme from '/@theme/index';
|
|
7
7
|
import { usePrefetch } from './composables/preFetch';
|
|
8
8
|
import { dataSymbol, initData } from './data';
|
|
9
9
|
import { Content } from './components/Content';
|
|
@@ -73,14 +73,10 @@ function newRouter() {
|
|
|
73
73
|
if (isInitialPageLoad || initialPath === pageFilePath) {
|
|
74
74
|
pageFilePath = pageFilePath.replace(/\.js$/, '.lean.js');
|
|
75
75
|
}
|
|
76
|
-
// in browser: native dynamic import
|
|
77
76
|
if (inBrowser) {
|
|
78
77
|
isInitialPageLoad = false;
|
|
79
|
-
return import(/*@vite-ignore*/ pageFilePath);
|
|
80
78
|
}
|
|
81
|
-
|
|
82
|
-
// @ts-ignore
|
|
83
|
-
return require(pageFilePath);
|
|
79
|
+
return import(/*@vite-ignore*/ pageFilePath);
|
|
84
80
|
}, NotFound);
|
|
85
81
|
}
|
|
86
82
|
function handleHMR(router) {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { reactive, inject, markRaw, nextTick, readonly } from 'vue';
|
|
2
|
-
import { inBrowser } from './utils';
|
|
2
|
+
import { inBrowser, withBase } from './utils';
|
|
3
3
|
import { siteDataRef } from './data';
|
|
4
4
|
export const RouterSymbol = Symbol();
|
|
5
5
|
// we are just using URL to parse the pathname and hash - the base doesn't
|
|
@@ -51,7 +51,7 @@ export function createRouter(loadPageModule, fallbackComponent) {
|
|
|
51
51
|
if (!comp) {
|
|
52
52
|
throw new Error(`Invalid route component: ${comp}`);
|
|
53
53
|
}
|
|
54
|
-
route.path = pendingPath;
|
|
54
|
+
route.path = inBrowser ? pendingPath : withBase(pendingPath);
|
|
55
55
|
route.component = markRaw(comp);
|
|
56
56
|
route.data = import.meta.env.PROD
|
|
57
57
|
? markRaw(JSON.parse(__pageData))
|
|
@@ -94,7 +94,7 @@ export function createRouter(loadPageModule, fallbackComponent) {
|
|
|
94
94
|
}
|
|
95
95
|
if (latestPendingPath === pendingPath) {
|
|
96
96
|
latestPendingPath = null;
|
|
97
|
-
route.path = pendingPath;
|
|
97
|
+
route.path = inBrowser ? pendingPath : withBase(pendingPath);
|
|
98
98
|
route.component = fallbackComponent ? markRaw(fallbackComponent) : null;
|
|
99
99
|
route.data = notFoundPageData;
|
|
100
100
|
}
|
package/dist/client/index.d.ts
CHANGED
|
@@ -1,129 +1,123 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { App } from 'vue';
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
localePath: Ref<string>;
|
|
125
|
-
}
|
|
126
|
-
|
|
127
|
-
export declare function withBase(path: string): string;
|
|
128
|
-
|
|
129
|
-
export { }
|
|
1
|
+
import * as vue from 'vue';
|
|
2
|
+
import { Component, Ref, App } from 'vue';
|
|
3
|
+
|
|
4
|
+
// types shared between server and client
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
interface PageData {
|
|
8
|
+
relativePath: string
|
|
9
|
+
title: string
|
|
10
|
+
titleTemplate?: string | boolean
|
|
11
|
+
description: string
|
|
12
|
+
headers: Header[]
|
|
13
|
+
frontmatter: Record<string, any>
|
|
14
|
+
lastUpdated?: number
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
interface Header {
|
|
18
|
+
level: number
|
|
19
|
+
title: string
|
|
20
|
+
slug: string
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
interface SiteData<ThemeConfig = any> {
|
|
24
|
+
base: string
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* Language of the site as it should be set on the `html` element.
|
|
28
|
+
*
|
|
29
|
+
* @example `en-US`, `zh-CN`
|
|
30
|
+
*/
|
|
31
|
+
lang: string
|
|
32
|
+
|
|
33
|
+
title: string
|
|
34
|
+
titleTemplate?: string | boolean
|
|
35
|
+
description: string
|
|
36
|
+
head: HeadConfig[]
|
|
37
|
+
appearance: boolean
|
|
38
|
+
themeConfig: ThemeConfig
|
|
39
|
+
scrollOffset: number | string
|
|
40
|
+
locales: Record<string, LocaleConfig>
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* Available locales for the site when it has defined `locales` in its
|
|
44
|
+
* `themeConfig`. This object is otherwise empty. Keys are paths like `/` or
|
|
45
|
+
* `/zh/`.
|
|
46
|
+
*/
|
|
47
|
+
langs: Record<
|
|
48
|
+
string,
|
|
49
|
+
{
|
|
50
|
+
/**
|
|
51
|
+
* Lang attribute as set on the `<html>` element.
|
|
52
|
+
* @example `en-US`, `zh-CN`
|
|
53
|
+
*/
|
|
54
|
+
lang: string
|
|
55
|
+
/**
|
|
56
|
+
* Label to display in the language menu.
|
|
57
|
+
* @example `English`, `简体中文`
|
|
58
|
+
*/
|
|
59
|
+
label: string
|
|
60
|
+
}
|
|
61
|
+
>
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
type HeadConfig =
|
|
65
|
+
| [string, Record<string, string>]
|
|
66
|
+
| [string, Record<string, string>, string]
|
|
67
|
+
|
|
68
|
+
interface LocaleConfig {
|
|
69
|
+
lang: string
|
|
70
|
+
title?: string
|
|
71
|
+
titleTemplate?: string | boolean
|
|
72
|
+
description?: string
|
|
73
|
+
head?: HeadConfig[]
|
|
74
|
+
label?: string
|
|
75
|
+
selectText?: string
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
declare const inBrowser: boolean;
|
|
79
|
+
|
|
80
|
+
interface Route {
|
|
81
|
+
path: string;
|
|
82
|
+
data: PageData;
|
|
83
|
+
component: Component | null;
|
|
84
|
+
}
|
|
85
|
+
interface Router {
|
|
86
|
+
route: Route;
|
|
87
|
+
go: (href?: string) => Promise<void>;
|
|
88
|
+
}
|
|
89
|
+
declare function useRouter(): Router;
|
|
90
|
+
declare function useRoute(): Route;
|
|
91
|
+
|
|
92
|
+
interface VitePressData<T = any> {
|
|
93
|
+
site: Ref<SiteData<T>>;
|
|
94
|
+
page: Ref<PageData>;
|
|
95
|
+
theme: Ref<T>;
|
|
96
|
+
frontmatter: Ref<PageData['frontmatter']>;
|
|
97
|
+
title: Ref<string>;
|
|
98
|
+
description: Ref<string>;
|
|
99
|
+
lang: Ref<string>;
|
|
100
|
+
localePath: Ref<string>;
|
|
101
|
+
}
|
|
102
|
+
declare function useData<T = any>(): VitePressData<T>;
|
|
103
|
+
|
|
104
|
+
interface EnhanceAppContext {
|
|
105
|
+
app: App;
|
|
106
|
+
router: Router;
|
|
107
|
+
siteData: Ref<SiteData>;
|
|
108
|
+
}
|
|
109
|
+
interface Theme {
|
|
110
|
+
Layout: Component;
|
|
111
|
+
NotFound?: Component;
|
|
112
|
+
enhanceApp?: (ctx: EnhanceAppContext) => void;
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
declare function withBase(path: string): string;
|
|
116
|
+
|
|
117
|
+
declare const Content: vue.DefineComponent<{}, () => vue.VNode<vue.RendererNode, vue.RendererElement, {
|
|
118
|
+
[key: string]: any;
|
|
119
|
+
}>, {}, {}, {}, vue.ComponentOptionsMixin, vue.ComponentOptionsMixin, vue.EmitsOptions, string, vue.VNodeProps & vue.AllowedComponentProps & vue.ComponentCustomProps, Readonly<vue.ExtractPropTypes<{}>>, {}>;
|
|
120
|
+
|
|
121
|
+
declare const Debug: vue.ComponentOptions<{}, any, any, any, any, any, any, any>;
|
|
122
|
+
|
|
123
|
+
export { Content, Debug, EnhanceAppContext, HeadConfig, Header, LocaleConfig, PageData, Route, Router, SiteData, Theme, VitePressData, inBrowser, useData, useRoute, useRouter, withBase };
|
package/dist/client/index.js
CHANGED
package/dist/client/shared.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
export const EXTERNAL_URL_RE = /^https?:/i;
|
|
2
|
+
export const APPEARANCE_KEY = 'vitepress-theme-appearance';
|
|
2
3
|
// @ts-ignore
|
|
3
4
|
export const inBrowser = typeof window !== 'undefined';
|
|
4
5
|
function findMatchRoot(route, roots) {
|
|
@@ -52,6 +53,27 @@ export function resolveSiteDataByRoute(siteData, route) {
|
|
|
52
53
|
langs: createLangDictionary(siteData)
|
|
53
54
|
});
|
|
54
55
|
}
|
|
56
|
+
/**
|
|
57
|
+
* Create the page title string based on configs.
|
|
58
|
+
*/
|
|
59
|
+
export function createTitle(siteData, pageData) {
|
|
60
|
+
const title = pageData.title || siteData.title;
|
|
61
|
+
const template = pageData.titleTemplate ?? siteData.titleTemplate;
|
|
62
|
+
const templateString = createTitleTemplate(siteData.title, template);
|
|
63
|
+
return `${title}${templateString}`;
|
|
64
|
+
}
|
|
65
|
+
function createTitleTemplate(siteTitle, template) {
|
|
66
|
+
if (template === false) {
|
|
67
|
+
return '';
|
|
68
|
+
}
|
|
69
|
+
if (template === true || template === undefined) {
|
|
70
|
+
return ` | ${siteTitle}`;
|
|
71
|
+
}
|
|
72
|
+
if (siteTitle === template) {
|
|
73
|
+
return '';
|
|
74
|
+
}
|
|
75
|
+
return ` | ${template}`;
|
|
76
|
+
}
|
|
55
77
|
/**
|
|
56
78
|
* Clean up the route by removing the `base` path if it's set in config.
|
|
57
79
|
*/
|
|
@@ -1,189 +1,55 @@
|
|
|
1
1
|
<script setup lang="ts">
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
import
|
|
8
|
-
import
|
|
9
|
-
import
|
|
10
|
-
import
|
|
11
|
-
|
|
12
|
-
const
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
? defineAsyncComponent(() => import('./components/AlgoliaSearchBox.vue'))
|
|
22
|
-
: NoopComponent
|
|
23
|
-
|
|
24
|
-
// generic state
|
|
25
|
-
const route = useRoute()
|
|
26
|
-
const { site, page, theme, frontmatter } = useData()
|
|
27
|
-
|
|
28
|
-
// custom layout
|
|
29
|
-
const isCustomLayout = computed(() => !!frontmatter.value.customLayout)
|
|
30
|
-
// home
|
|
31
|
-
const enableHome = computed(() => !!frontmatter.value.home)
|
|
32
|
-
|
|
33
|
-
// automatic multilang check for AlgoliaSearchBox
|
|
34
|
-
const isMultiLang = computed(() => Object.keys(site.value.langs).length > 1)
|
|
35
|
-
|
|
36
|
-
// navbar
|
|
37
|
-
const showNavbar = computed(() => {
|
|
38
|
-
const themeConfig = theme.value
|
|
39
|
-
if (frontmatter.value.navbar === false || themeConfig.navbar === false) {
|
|
40
|
-
return false
|
|
41
|
-
}
|
|
42
|
-
return (
|
|
43
|
-
site.value.title || themeConfig.logo || themeConfig.repo || themeConfig.nav
|
|
44
|
-
)
|
|
45
|
-
})
|
|
46
|
-
|
|
47
|
-
// sidebar
|
|
48
|
-
const openSideBar = ref(false)
|
|
49
|
-
|
|
50
|
-
const showSidebar = computed(() => {
|
|
51
|
-
if (frontmatter.value.home || frontmatter.value.sidebar === false) {
|
|
52
|
-
return false
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
return !isSideBarEmpty(
|
|
56
|
-
getSideBarConfig(theme.value.sidebar, route.data.relativePath)
|
|
57
|
-
)
|
|
58
|
-
})
|
|
59
|
-
|
|
60
|
-
const toggleSidebar = (to?: boolean) => {
|
|
61
|
-
openSideBar.value = typeof to === 'boolean' ? to : !openSideBar.value
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
const hideSidebar = toggleSidebar.bind(null, false)
|
|
65
|
-
// close the sidebar when navigating to a different location
|
|
66
|
-
watch(route, hideSidebar)
|
|
67
|
-
// TODO: route only changes when the pathname changes
|
|
68
|
-
// listening to hashchange does nothing because it's prevented in router
|
|
69
|
-
|
|
70
|
-
// page classes
|
|
71
|
-
const pageClasses = computed(() => {
|
|
72
|
-
return [
|
|
73
|
-
{
|
|
74
|
-
'no-navbar': !showNavbar.value,
|
|
75
|
-
'sidebar-open': openSideBar.value,
|
|
76
|
-
'no-sidebar': !showSidebar.value
|
|
77
|
-
}
|
|
78
|
-
]
|
|
79
|
-
})
|
|
2
|
+
import { provide } from 'vue'
|
|
3
|
+
import { useSidebar, useCloseSidebarOnEscape } from './composables/sidebar'
|
|
4
|
+
import VPSkipLink from './components/VPSkipLink.vue'
|
|
5
|
+
import VPBackdrop from './components/VPBackdrop.vue'
|
|
6
|
+
import VPNav from './components/VPNav.vue'
|
|
7
|
+
import VPLocalNav from './components/VPLocalNav.vue'
|
|
8
|
+
import VPSidebar from './components/VPSidebar.vue'
|
|
9
|
+
import VPContent from './components/VPContent.vue'
|
|
10
|
+
import VPFooter from './components/VPFooter.vue'
|
|
11
|
+
|
|
12
|
+
const {
|
|
13
|
+
isOpen: isSidebarOpen,
|
|
14
|
+
open: openSidebar,
|
|
15
|
+
close: closeSidebar
|
|
16
|
+
} = useSidebar()
|
|
17
|
+
|
|
18
|
+
useCloseSidebarOnEscape(isSidebarOpen, closeSidebar)
|
|
19
|
+
|
|
20
|
+
provide('close-sidebar', closeSidebar)
|
|
80
21
|
</script>
|
|
81
22
|
|
|
82
23
|
<template>
|
|
83
|
-
<div class="
|
|
84
|
-
<
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
<template #
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
<template #
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
<div class="sidebar-mask" @click="toggleSidebar(false)" />
|
|
106
|
-
|
|
107
|
-
<Content v-if="isCustomLayout" />
|
|
108
|
-
|
|
109
|
-
<template v-else-if="enableHome">
|
|
110
|
-
<!-- A slot for customizing the entire homepage easily -->
|
|
111
|
-
<slot name="home">
|
|
112
|
-
<Home>
|
|
113
|
-
<template #hero>
|
|
114
|
-
<slot name="home-hero" />
|
|
115
|
-
</template>
|
|
116
|
-
<template #features>
|
|
117
|
-
<slot name="home-features" />
|
|
118
|
-
</template>
|
|
119
|
-
<template #footer>
|
|
120
|
-
<slot name="home-footer" />
|
|
121
|
-
</template>
|
|
122
|
-
</Home>
|
|
123
|
-
</slot>
|
|
124
|
-
</template>
|
|
125
|
-
|
|
126
|
-
<Page v-else>
|
|
127
|
-
<template #top>
|
|
128
|
-
<slot name="page-top-ads">
|
|
129
|
-
<div
|
|
130
|
-
id="ads-container"
|
|
131
|
-
v-if="theme.carbonAds && theme.carbonAds.carbon"
|
|
132
|
-
>
|
|
133
|
-
<CarbonAds
|
|
134
|
-
:key="'carbon' + page.relativePath"
|
|
135
|
-
:code="theme.carbonAds.carbon"
|
|
136
|
-
:placement="theme.carbonAds.placement"
|
|
137
|
-
/>
|
|
138
|
-
</div>
|
|
139
|
-
</slot>
|
|
140
|
-
<slot name="page-top" />
|
|
141
|
-
</template>
|
|
142
|
-
<template #bottom>
|
|
143
|
-
<slot name="page-bottom" />
|
|
144
|
-
<slot name="page-bottom-ads">
|
|
145
|
-
<BuySellAds
|
|
146
|
-
v-if="theme.carbonAds && theme.carbonAds.custom"
|
|
147
|
-
:key="'custom' + page.relativePath"
|
|
148
|
-
:code="theme.carbonAds.custom"
|
|
149
|
-
:placement="theme.carbonAds.placement"
|
|
150
|
-
/>
|
|
151
|
-
</slot>
|
|
152
|
-
</template>
|
|
153
|
-
</Page>
|
|
24
|
+
<div class="Layout">
|
|
25
|
+
<VPSkipLink />
|
|
26
|
+
<VPBackdrop class="backdrop" :show="isSidebarOpen" @click="closeSidebar" />
|
|
27
|
+
<VPNav />
|
|
28
|
+
<VPLocalNav :open="isSidebarOpen" @open-menu="openSidebar" />
|
|
29
|
+
<VPSidebar :open="isSidebarOpen" />
|
|
30
|
+
|
|
31
|
+
<VPContent>
|
|
32
|
+
<template #home-hero-before><slot name="home-hero-before" /></template>
|
|
33
|
+
<template #home-hero-after><slot name="home-hero-after" /></template>
|
|
34
|
+
<template #home-features-before><slot name="home-features-before" /></template>
|
|
35
|
+
<template #home-features-after><slot name="home-features-after" /></template>
|
|
36
|
+
|
|
37
|
+
<template #aside-top><slot name="aside-top" /></template>
|
|
38
|
+
<template #aside-bottom><slot name="aside-bottom" /></template>
|
|
39
|
+
<template #aside-outline-before><slot name="aside-outline-before" /></template>
|
|
40
|
+
<template #aside-outline-after><slot name="aside-outline-after" /></template>
|
|
41
|
+
<template #aside-ads-before><slot name="aside-ads-before" /></template>
|
|
42
|
+
<template #aside-ads-after><slot name="aside-ads-after" /></template>
|
|
43
|
+
</VPContent>
|
|
44
|
+
|
|
45
|
+
<VPFooter />
|
|
154
46
|
</div>
|
|
155
|
-
|
|
156
|
-
<Debug />
|
|
157
47
|
</template>
|
|
158
48
|
|
|
159
|
-
<style>
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
@media (min-width: 420px) {
|
|
165
|
-
#ads-container {
|
|
166
|
-
position: relative;
|
|
167
|
-
right: 0;
|
|
168
|
-
float: right;
|
|
169
|
-
margin: -8px -8px 24px 24px;
|
|
170
|
-
width: 146px;
|
|
171
|
-
}
|
|
172
|
-
}
|
|
173
|
-
|
|
174
|
-
@media (max-width: 420px) {
|
|
175
|
-
#ads-container {
|
|
176
|
-
/* Avoid layout shift */
|
|
177
|
-
height: 105px;
|
|
178
|
-
margin: 1.75rem 0;
|
|
179
|
-
}
|
|
180
|
-
}
|
|
181
|
-
|
|
182
|
-
@media (min-width: 1400px) {
|
|
183
|
-
#ads-container {
|
|
184
|
-
position: fixed;
|
|
185
|
-
right: 8px;
|
|
186
|
-
bottom: 8px;
|
|
187
|
-
}
|
|
49
|
+
<style scoped>
|
|
50
|
+
.Layout {
|
|
51
|
+
display: flex;
|
|
52
|
+
flex-direction: column;
|
|
53
|
+
min-height: 100vh;
|
|
188
54
|
}
|
|
189
55
|
</style>
|