vitepress 0.22.2 → 1.0.0-draft.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 +4 -4
- package/client.d.ts +2 -3
- package/dist/client/app/components/ClientOnly.js +1 -1
- package/dist/client/app/index.js +5 -7
- package/dist/client/app/router.js +11 -5
- package/dist/client/theme-default/Layout.vue +25 -183
- package/dist/client/theme-default/NotFound.vue +9 -8
- 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/VPContent.vue +44 -0
- package/dist/client/theme-default/components/VPContentDoc.vue +173 -0
- package/dist/client/theme-default/components/VPContentDocFooter.vue +140 -0
- package/dist/client/theme-default/components/VPContentDocOutline.vue +108 -0
- package/dist/client/theme-default/components/VPFlyout.vue +149 -0
- package/dist/client/theme-default/components/VPLink.vue +37 -0
- package/dist/client/theme-default/components/VPLocalNav.vue +106 -0
- package/dist/client/theme-default/components/VPMenu.vue +79 -0
- package/dist/client/theme-default/components/VPMenuGroup.vue +35 -0
- package/dist/client/theme-default/components/VPMenuLink.vue +30 -0
- package/dist/client/theme-default/components/VPNav.vue +33 -0
- package/dist/client/theme-default/components/VPNavBar.vue +109 -0
- package/dist/client/theme-default/components/VPNavBarAppearance.vue +22 -0
- package/dist/client/theme-default/components/VPNavBarExtra.vue +107 -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 +18 -0
- package/dist/client/theme-default/components/VPNavBarMenuLink.vue +56 -0
- package/dist/client/theme-default/components/VPNavBarSearch.vue +269 -0
- package/dist/client/theme-default/components/VPNavBarSocialLinks.vue +27 -0
- package/dist/client/theme-default/components/VPNavBarTitle.vue +44 -0
- package/dist/client/theme-default/components/VPNavBarTranslations.vue +74 -0
- package/dist/client/theme-default/components/VPNavScreen.vue +100 -0
- package/dist/client/theme-default/components/VPNavScreenAppearance.vue +30 -0
- package/dist/client/theme-default/components/VPNavScreenMenu.vue +24 -0
- package/dist/client/theme-default/components/VPNavScreenMenuGroup.vue +118 -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/VPSidebar.vue +118 -0
- package/dist/client/theme-default/components/VPSidebarGroup.vue +44 -0
- package/dist/client/theme-default/components/VPSidebarLink.vue +57 -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/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/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/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/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/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 +130 -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/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 +4 -4
- package/dist/client/theme-default/styles/base.css +200 -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 +206 -66
- package/dist/client/theme-default/styles/vp-doc.css +419 -0
- package/dist/client/theme-default/support/sidebar.js +29 -0
- package/dist/client/theme-default/support/utils.js +43 -0
- package/dist/node/cli.js +1 -1
- package/dist/node/index.d.ts +106 -81
- package/dist/node/index.js +1 -1
- package/dist/node/{serve-cf4b2162.js → serve-428d4610.js} +27 -10
- package/package.json +31 -27
- package/types/default-theme.d.ts +105 -80
- package/dist/client/theme-default/components/AlgoliaSearchBox.vue +0 -195
- 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
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
|
|
6
6
|
---
|
|
7
7
|
|
|
8
|
-
VitePress is [VuePress](
|
|
8
|
+
VitePress is [VuePress](https://vuepress.vuejs.org)' spiritual successor, built on top of [vite](https://github.com/vitejs/vite).
|
|
9
9
|
|
|
10
10
|
## Documentation
|
|
11
11
|
|
|
@@ -13,14 +13,14 @@ To check out docs, visit [vitepress.vuejs.org](https://vitepress.vuejs.org).
|
|
|
13
13
|
|
|
14
14
|
## Changelog
|
|
15
15
|
|
|
16
|
-
Detailed changes for each release are documented in the [CHANGELOG](https://github.com/vuejs/vitepress/blob/
|
|
16
|
+
Detailed changes for each release are documented in the [CHANGELOG](https://github.com/vuejs/vitepress/blob/main/CHANGELOG.md).
|
|
17
17
|
|
|
18
18
|
## Contribution
|
|
19
19
|
|
|
20
|
-
Please make sure to read the [Contributing Guide](
|
|
20
|
+
Please make sure to read the [Contributing Guide](https://github.com/vuejs/vitepress/blob/main/.github/contributing.md) before making a pull request.
|
|
21
21
|
|
|
22
22
|
## License
|
|
23
23
|
|
|
24
|
-
[MIT](https://
|
|
24
|
+
[MIT](https://github.com/vuejs/vitepress/blob/main/LICENSE)
|
|
25
25
|
|
|
26
26
|
Copyright (c) 2019-present, Yuxi (Evan) You
|
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" />
|
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';
|
|
@@ -33,10 +33,6 @@ export function createApp() {
|
|
|
33
33
|
app.provide(RouterSymbol, router);
|
|
34
34
|
const data = initData(router.route);
|
|
35
35
|
app.provide(dataSymbol, data);
|
|
36
|
-
if (inBrowser) {
|
|
37
|
-
// dynamically update head tags
|
|
38
|
-
useUpdateHead(router.route, data.site);
|
|
39
|
-
}
|
|
40
36
|
// install global components
|
|
41
37
|
app.component('Content', Content);
|
|
42
38
|
app.component('ClientOnly', ClientOnly);
|
|
@@ -56,7 +52,7 @@ export function createApp() {
|
|
|
56
52
|
siteData: siteDataRef
|
|
57
53
|
});
|
|
58
54
|
}
|
|
59
|
-
return { app, router };
|
|
55
|
+
return { app, router, data };
|
|
60
56
|
}
|
|
61
57
|
function newApp() {
|
|
62
58
|
return import.meta.env.PROD
|
|
@@ -104,9 +100,11 @@ function shouldHotReload(payload) {
|
|
|
104
100
|
return payloadPath === locationPath;
|
|
105
101
|
}
|
|
106
102
|
if (inBrowser) {
|
|
107
|
-
const { app, router } = createApp();
|
|
103
|
+
const { app, router, data } = createApp();
|
|
108
104
|
// wait until page component is fetched before mounting
|
|
109
105
|
router.go().then(() => {
|
|
106
|
+
// dynamically update head tags
|
|
107
|
+
useUpdateHead(router.route, data.site);
|
|
110
108
|
app.mount('#app');
|
|
111
109
|
});
|
|
112
110
|
}
|
|
@@ -5,13 +5,18 @@ export const RouterSymbol = Symbol();
|
|
|
5
5
|
// we are just using URL to parse the pathname and hash - the base doesn't
|
|
6
6
|
// matter and is only passed to support same-host hrefs.
|
|
7
7
|
const fakeHost = `http://a.com`;
|
|
8
|
+
const notFoundPageData = {
|
|
9
|
+
relativePath: '',
|
|
10
|
+
title: '404',
|
|
11
|
+
description: 'Not Found',
|
|
12
|
+
headers: [],
|
|
13
|
+
frontmatter: {},
|
|
14
|
+
lastUpdated: 0
|
|
15
|
+
};
|
|
8
16
|
const getDefaultRoute = () => ({
|
|
9
17
|
path: '/',
|
|
10
18
|
component: null,
|
|
11
|
-
|
|
12
|
-
// the app is mounted, so it's guaranteed to be available in
|
|
13
|
-
// components. We just need enough data for 404 pages to render.
|
|
14
|
-
data: { frontmatter: {} }
|
|
19
|
+
data: notFoundPageData
|
|
15
20
|
});
|
|
16
21
|
export function createRouter(loadPageModule, fallbackComponent) {
|
|
17
22
|
const route = reactive(getDefaultRoute());
|
|
@@ -91,6 +96,7 @@ export function createRouter(loadPageModule, fallbackComponent) {
|
|
|
91
96
|
latestPendingPath = null;
|
|
92
97
|
route.path = pendingPath;
|
|
93
98
|
route.component = fallbackComponent ? markRaw(fallbackComponent) : null;
|
|
99
|
+
route.data = notFoundPageData;
|
|
94
100
|
}
|
|
95
101
|
}
|
|
96
102
|
}
|
|
@@ -153,7 +159,7 @@ export function useRoute() {
|
|
|
153
159
|
function scrollTo(el, hash, smooth = false) {
|
|
154
160
|
let target = null;
|
|
155
161
|
try {
|
|
156
|
-
target = el.classList.contains('
|
|
162
|
+
target = el.classList.contains('header-anchor')
|
|
157
163
|
? el
|
|
158
164
|
: document.querySelector(decodeURIComponent(hash));
|
|
159
165
|
}
|
|
@@ -1,189 +1,31 @@
|
|
|
1
1
|
<script setup lang="ts">
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
import
|
|
8
|
-
import
|
|
9
|
-
import
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
const AlgoliaSearchBox = __ALGOLIA__
|
|
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
|
+
|
|
11
|
+
const {
|
|
12
|
+
isOpen: isSidebarOpen,
|
|
13
|
+
open: openSidebar,
|
|
14
|
+
close: closeSidebar
|
|
15
|
+
} = useSidebar()
|
|
16
|
+
|
|
17
|
+
useCloseSidebarOnEscape(isSidebarOpen, closeSidebar)
|
|
18
|
+
|
|
19
|
+
provide('close-sidebar', closeSidebar)
|
|
80
20
|
</script>
|
|
81
21
|
|
|
82
22
|
<template>
|
|
83
|
-
<div class="
|
|
84
|
-
<
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
:multilang="isMultiLang"
|
|
91
|
-
/>
|
|
92
|
-
</slot>
|
|
93
|
-
</template>
|
|
94
|
-
</NavBar>
|
|
95
|
-
|
|
96
|
-
<SideBar :open="openSideBar">
|
|
97
|
-
<template #sidebar-top>
|
|
98
|
-
<slot name="sidebar-top" />
|
|
99
|
-
</template>
|
|
100
|
-
<template #sidebar-bottom>
|
|
101
|
-
<slot name="sidebar-bottom" />
|
|
102
|
-
</template>
|
|
103
|
-
</SideBar>
|
|
104
|
-
<!-- TODO: make this button accessible -->
|
|
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>
|
|
23
|
+
<div class="Layout">
|
|
24
|
+
<VPSkipLink />
|
|
25
|
+
<VPBackdrop class="backdrop" :show="isSidebarOpen" @click="closeSidebar" />
|
|
26
|
+
<VPNav />
|
|
27
|
+
<VPLocalNav :open="isSidebarOpen" @open-menu="openSidebar" />
|
|
28
|
+
<VPSidebar :open="isSidebarOpen" />
|
|
29
|
+
<VPContent />
|
|
154
30
|
</div>
|
|
155
|
-
|
|
156
|
-
<Debug />
|
|
157
31
|
</template>
|
|
158
|
-
|
|
159
|
-
<style>
|
|
160
|
-
#ads-container {
|
|
161
|
-
margin: 0 auto;
|
|
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
|
-
}
|
|
188
|
-
}
|
|
189
|
-
</style>
|
|
@@ -1,15 +1,8 @@
|
|
|
1
|
-
<template>
|
|
2
|
-
<div class="theme">
|
|
3
|
-
<h1>404</h1>
|
|
4
|
-
<blockquote>{{ getMsg() }}</blockquote>
|
|
5
|
-
<a :href="site.base" aria-label="go to home">Take me home.</a>
|
|
6
|
-
</div>
|
|
7
|
-
</template>
|
|
8
|
-
|
|
9
1
|
<script setup lang="ts">
|
|
10
2
|
import { useData } from 'vitepress'
|
|
11
3
|
|
|
12
4
|
const { site } = useData()
|
|
5
|
+
|
|
13
6
|
const msgs = [
|
|
14
7
|
`There's nothing here.`,
|
|
15
8
|
`How did we get here?`,
|
|
@@ -21,3 +14,11 @@ function getMsg() {
|
|
|
21
14
|
return msgs[Math.floor(Math.random() * msgs.length)]
|
|
22
15
|
}
|
|
23
16
|
</script>
|
|
17
|
+
|
|
18
|
+
<template>
|
|
19
|
+
<div class="NotFound">
|
|
20
|
+
<h1>404</h1>
|
|
21
|
+
<blockquote>{{ getMsg() }}</blockquote>
|
|
22
|
+
<a :href="site.base" aria-label="go to home">Take me home.</a>
|
|
23
|
+
</div>
|
|
24
|
+
</template>
|
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
import docsearch from '@docsearch/js'
|
|
3
|
+
import { DocSearchHit } from '@docsearch/react/dist/esm/types'
|
|
4
|
+
import { onMounted } from 'vue'
|
|
5
|
+
import { useRouter, useRoute, useData } from 'vitepress'
|
|
6
|
+
import { DefaultTheme } from '../config'
|
|
7
|
+
|
|
8
|
+
const router = useRouter()
|
|
9
|
+
const route = useRoute()
|
|
10
|
+
const { theme } = useData()
|
|
11
|
+
|
|
12
|
+
onMounted(() => {
|
|
13
|
+
initialize(theme.value.algolia)
|
|
14
|
+
setTimeout(poll, 16)
|
|
15
|
+
})
|
|
16
|
+
|
|
17
|
+
function poll() {
|
|
18
|
+
// programmatically open the search box after initialize
|
|
19
|
+
const e = new Event('keydown') as any
|
|
20
|
+
|
|
21
|
+
e.key = 'k'
|
|
22
|
+
e.metaKey = true
|
|
23
|
+
|
|
24
|
+
window.dispatchEvent(e)
|
|
25
|
+
|
|
26
|
+
setTimeout(() => {
|
|
27
|
+
if (!document.querySelector('.DocSearch-Modal')) {
|
|
28
|
+
poll()
|
|
29
|
+
}
|
|
30
|
+
}, 16)
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
function initialize(userOptions: DefaultTheme.AlgoliaSearchOptions) {
|
|
34
|
+
// note: multi-lang search support is removed since the theme
|
|
35
|
+
// doesn't support multiple locales as of now.
|
|
36
|
+
const options = Object.assign({}, userOptions, {
|
|
37
|
+
container: '#docsearch',
|
|
38
|
+
|
|
39
|
+
navigator: {
|
|
40
|
+
navigate({ itemUrl }: { itemUrl: string }) {
|
|
41
|
+
const { pathname: hitPathname } = new URL(
|
|
42
|
+
window.location.origin + itemUrl
|
|
43
|
+
)
|
|
44
|
+
|
|
45
|
+
// router doesn't handle same-page navigation so we use the native
|
|
46
|
+
// browser location API for anchor navigation
|
|
47
|
+
if (route.path === hitPathname) {
|
|
48
|
+
window.location.assign(window.location.origin + itemUrl)
|
|
49
|
+
} else {
|
|
50
|
+
router.go(itemUrl)
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
},
|
|
54
|
+
|
|
55
|
+
transformItems(items: DocSearchHit[]) {
|
|
56
|
+
return items.map((item) => {
|
|
57
|
+
return Object.assign({}, item, {
|
|
58
|
+
url: getRelativePath(item.url)
|
|
59
|
+
})
|
|
60
|
+
})
|
|
61
|
+
},
|
|
62
|
+
|
|
63
|
+
hitComponent({ hit, children }: { hit: DocSearchHit, children: any }) {
|
|
64
|
+
const relativeHit = hit.url.startsWith('http')
|
|
65
|
+
? getRelativePath(hit.url as string)
|
|
66
|
+
: hit.url
|
|
67
|
+
|
|
68
|
+
return {
|
|
69
|
+
__v: null,
|
|
70
|
+
type: 'a',
|
|
71
|
+
ref: undefined,
|
|
72
|
+
constructor: undefined,
|
|
73
|
+
key: undefined,
|
|
74
|
+
|
|
75
|
+
props: {
|
|
76
|
+
href: hit.url,
|
|
77
|
+
|
|
78
|
+
onClick(event: MouseEvent) {
|
|
79
|
+
if (isSpecialClick(event)) {
|
|
80
|
+
return
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
// we rely on the native link scrolling when user is already on
|
|
84
|
+
// the right anchor because Router doesn't support duplicated
|
|
85
|
+
// history entries.
|
|
86
|
+
if (route.path === relativeHit) {
|
|
87
|
+
return
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
// if the hits goes to another page, we prevent the native link
|
|
91
|
+
// behavior to leverage the Router loading feature.
|
|
92
|
+
if (route.path !== relativeHit) {
|
|
93
|
+
event.preventDefault()
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
router.go(relativeHit)
|
|
97
|
+
},
|
|
98
|
+
|
|
99
|
+
children
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
})
|
|
104
|
+
|
|
105
|
+
docsearch(options)
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
function isSpecialClick(event: MouseEvent) {
|
|
109
|
+
return (
|
|
110
|
+
event.button === 1 ||
|
|
111
|
+
event.altKey ||
|
|
112
|
+
event.ctrlKey ||
|
|
113
|
+
event.metaKey ||
|
|
114
|
+
event.shiftKey
|
|
115
|
+
)
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
function getRelativePath(absoluteUrl: string) {
|
|
119
|
+
const { pathname, hash } = new URL(absoluteUrl)
|
|
120
|
+
|
|
121
|
+
return pathname + hash
|
|
122
|
+
}
|
|
123
|
+
</script>
|
|
124
|
+
|
|
125
|
+
<template>
|
|
126
|
+
<div id="docsearch" />
|
|
127
|
+
</template>
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
<script lang="ts" setup>
|
|
2
|
+
defineProps<{
|
|
3
|
+
show: boolean
|
|
4
|
+
}>()
|
|
5
|
+
</script>
|
|
6
|
+
|
|
7
|
+
<template>
|
|
8
|
+
<transition name="fade">
|
|
9
|
+
<div v-if="show" class="VPBackdrop" />
|
|
10
|
+
</transition>
|
|
11
|
+
</template>
|
|
12
|
+
|
|
13
|
+
<style scoped>
|
|
14
|
+
.VPBackdrop {
|
|
15
|
+
position: fixed;
|
|
16
|
+
top: 0;
|
|
17
|
+
right: 0;
|
|
18
|
+
bottom: 0;
|
|
19
|
+
left: 0;
|
|
20
|
+
z-index: var(--vp-z-backdrop);
|
|
21
|
+
background: rgba(0, 0, 0, .6);
|
|
22
|
+
transition: opacity 0.5s;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
.VPBackdrop.fade-enter-from,
|
|
26
|
+
.VPBackdrop.fade-leave-to {
|
|
27
|
+
opacity: 0;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
.VPBackdrop.fade-leave-active {
|
|
31
|
+
transition-duration: .25s;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
@media (min-width: 1280px) {
|
|
35
|
+
.VPBackdrop {
|
|
36
|
+
display: none;
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
</style>
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
import { useRoute } from 'vitepress'
|
|
3
|
+
import { useSidebar } from '../composables/sidebar'
|
|
4
|
+
import NotFound from '../NotFound.vue'
|
|
5
|
+
import VPContentDoc from './VPContentDoc.vue'
|
|
6
|
+
|
|
7
|
+
const route = useRoute()
|
|
8
|
+
const { hasSidebar } = useSidebar()
|
|
9
|
+
</script>
|
|
10
|
+
|
|
11
|
+
<template>
|
|
12
|
+
<div
|
|
13
|
+
class="VPContent"
|
|
14
|
+
id="VPContent"
|
|
15
|
+
:class="{ 'has-sidebar': hasSidebar }"
|
|
16
|
+
>
|
|
17
|
+
<NotFound v-if="route.component === NotFound" />
|
|
18
|
+
<VPContentDoc v-else :class="{ 'has-sidebar': hasSidebar }" />
|
|
19
|
+
</div>
|
|
20
|
+
</template>
|
|
21
|
+
|
|
22
|
+
<style scoped>
|
|
23
|
+
@media (max-width: 768px) {
|
|
24
|
+
.VPContent {
|
|
25
|
+
overflow-x: hidden;
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
@media (min-width: 960px) {
|
|
30
|
+
.VPContent {
|
|
31
|
+
padding-top: var(--vp-nav-height-desktop);
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
.VPContent.has-sidebar {
|
|
35
|
+
padding-left: var(--vp-sidebar-width);
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
@media (min-width: 1440px) {
|
|
40
|
+
.VPContent.has-sidebar {
|
|
41
|
+
padding-left: calc((100vw - var(--vp-layout-max-width)) / 2 + var(--vp-sidebar-width) - 32px);
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
</style>
|