vitepress 0.22.4 → 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/client.d.ts +2 -3
- package/dist/client/app/components/ClientOnly.js +1 -1
- package/dist/client/app/index.js +1 -1
- 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 +3 -8
- package/dist/node/index.d.ts +104 -79
- package/dist/node/index.js +1 -1
- package/dist/node/{serve-3035f99b.js → serve-428d4610.js} +11418 -1415
- package/package.json +24 -20
- package/types/default-theme.d.ts +104 -79
- 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/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';
|
|
@@ -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>
|
|
@@ -0,0 +1,173 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
import { computed } from 'vue'
|
|
3
|
+
import { useData } from 'vitepress'
|
|
4
|
+
import VPContentDocOutline from './VPContentDocOutline.vue'
|
|
5
|
+
import VPContentDocFooter from './VPContentDocFooter.vue'
|
|
6
|
+
|
|
7
|
+
const { page } = useData()
|
|
8
|
+
|
|
9
|
+
const pageName = computed(() => {
|
|
10
|
+
return page.value.relativePath.slice(0, page.value.relativePath.indexOf('/'))
|
|
11
|
+
})
|
|
12
|
+
</script>
|
|
13
|
+
|
|
14
|
+
<template>
|
|
15
|
+
<div class="VPContentDoc has-aside">
|
|
16
|
+
<div class="container">
|
|
17
|
+
<div class="aside">
|
|
18
|
+
<div class="aside-container">
|
|
19
|
+
<div class="aside-curtain" />
|
|
20
|
+
<div class="aside-content">
|
|
21
|
+
<VPContentDocOutline v-if="page.headers" />
|
|
22
|
+
</div>
|
|
23
|
+
</div>
|
|
24
|
+
</div>
|
|
25
|
+
|
|
26
|
+
<div class="content">
|
|
27
|
+
<main class="main">
|
|
28
|
+
<Content class="vp-doc" :class="pageName" />
|
|
29
|
+
</main>
|
|
30
|
+
|
|
31
|
+
<VPContentDocFooter />
|
|
32
|
+
</div>
|
|
33
|
+
</div>
|
|
34
|
+
</div>
|
|
35
|
+
</template>
|
|
36
|
+
|
|
37
|
+
<style scoped>
|
|
38
|
+
.VPContentDoc {
|
|
39
|
+
padding: 32px 24px 96px;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
@media (min-width: 768px) {
|
|
43
|
+
.VPContentDoc {
|
|
44
|
+
padding: 48px 32px 128px;
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
@media (min-width: 960px) {
|
|
49
|
+
.VPContentDoc {
|
|
50
|
+
padding: 32px 64px 96px;
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
@media (min-width: 1280px) {
|
|
55
|
+
.VPContentDoc {
|
|
56
|
+
padding: 32px 0 128px 64px;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
.VPContentDoc:not(.has-sidebar.has-aside) {
|
|
60
|
+
padding-left: calc((100vw - 688px) / 2);
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
.VPContentDoc.has-aside:not(.has-sidebar) {
|
|
64
|
+
padding-left: calc((100vw - 688px - 320px) / 2);
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
.VPContentDoc:not(.has-aside) .content {
|
|
68
|
+
min-width: 688px;
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
@media (min-width: 1440px) {
|
|
73
|
+
.VPContentDoc {
|
|
74
|
+
padding: 32px 0 128px 96px;
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
@media (min-width: 1280px) {
|
|
79
|
+
.container {
|
|
80
|
+
display: flex;
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
.aside {
|
|
85
|
+
position: relative;
|
|
86
|
+
display: none;
|
|
87
|
+
order: 2;
|
|
88
|
+
flex-shrink: 0;
|
|
89
|
+
flex-grow: 1;
|
|
90
|
+
padding-left: 64px;
|
|
91
|
+
padding-right: 32px;
|
|
92
|
+
min-width: 320px;
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
@media (min-width: 1280px) {
|
|
96
|
+
.aside {
|
|
97
|
+
display: block;
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
@media (min-width: 1440px) {
|
|
102
|
+
.aside {
|
|
103
|
+
padding-left: 96px;
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
.aside-container {
|
|
108
|
+
position: fixed;
|
|
109
|
+
top: var(--vp-nav-height-desktop);
|
|
110
|
+
bottom: 0;
|
|
111
|
+
padding-top: 32px;
|
|
112
|
+
width: 224px;
|
|
113
|
+
overflow-x: hidden;
|
|
114
|
+
overflow-y: auto;
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
.aside-container::-webkit-scrollbar {
|
|
118
|
+
display: none;
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
@media (min-width: 1440px) {
|
|
122
|
+
.aside-container {
|
|
123
|
+
width: 256px;
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
.aside-curtain {
|
|
128
|
+
position: fixed;
|
|
129
|
+
top: var(--vp-nav-height-desktop);
|
|
130
|
+
z-index: 10;
|
|
131
|
+
width: 100%;
|
|
132
|
+
height: 40px;
|
|
133
|
+
background: linear-gradient(var(--vp-c-bg-content), transparent);
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
.aside-content {
|
|
137
|
+
padding-bottom: 96px;
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
.content {
|
|
141
|
+
position: relative;
|
|
142
|
+
margin: 0 auto;
|
|
143
|
+
max-width: 688px;
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
@media (min-width: 1280px) {
|
|
147
|
+
.content {
|
|
148
|
+
order: 1;
|
|
149
|
+
margin: 0;
|
|
150
|
+
min-width: 632px;
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
.edit-link {
|
|
155
|
+
margin: 0 0 32px;
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
.edit-link .vt-link {
|
|
159
|
+
font-size: 14px;
|
|
160
|
+
color: var(--vt-c-brand);
|
|
161
|
+
font-weight: 500;
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
.vt-icon {
|
|
165
|
+
width: 18px;
|
|
166
|
+
height: 18px;
|
|
167
|
+
color: var(--vt-c-brand);
|
|
168
|
+
display: inline-block;
|
|
169
|
+
margin-right: 8px;
|
|
170
|
+
position: relative;
|
|
171
|
+
top: -1px;
|
|
172
|
+
}
|
|
173
|
+
</style>
|