@vuepress/theme-default 2.0.0-rc.1 → 2.0.0-rc.101
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/lib/client/components/VPAutoLink.vue +32 -0
- package/lib/client/components/VPDarkIcon.vue +8 -0
- package/lib/client/components/VPDropdownTransition.vue +43 -0
- package/lib/client/components/VPEditIcon.vue +12 -0
- package/lib/client/components/VPFadeSlideYTransition.vue +23 -0
- package/lib/client/components/VPHome.vue +37 -0
- package/lib/client/components/VPHomeFeatures.vue +65 -0
- package/lib/client/components/VPHomeFooter.vue +30 -0
- package/lib/client/components/VPHomeHero.vue +186 -0
- package/lib/client/components/VPLightIcon.vue +28 -0
- package/lib/client/components/VPNavbar.vue +138 -0
- package/lib/client/components/VPNavbarBrand.vue +89 -0
- package/lib/client/components/VPNavbarDropdown.vue +330 -0
- package/lib/client/components/VPNavbarItems.vue +111 -0
- package/lib/client/components/VPPage.vue +69 -0
- package/lib/client/components/VPPageMeta.vue +139 -0
- package/lib/client/components/VPPageNav.vue +123 -0
- package/lib/client/components/VPSidebar.vue +120 -0
- package/lib/client/components/VPSidebarItem.vue +189 -0
- package/lib/client/components/{SidebarItems.vue → VPSidebarItems.vue} +27 -7
- package/lib/client/components/VPToggleColorModeButton.vue +55 -0
- package/lib/client/components/VPToggleSidebarButton.vue +92 -0
- package/lib/client/components/global/Badge.vue +84 -18
- package/lib/client/components/global/index.d.ts +1 -3
- package/lib/client/components/global/index.js +1 -3
- package/lib/client/composables/index.d.ts +7 -1
- package/lib/client/composables/index.js +7 -1
- package/lib/client/composables/useDarkMode.d.ts +0 -1
- package/lib/client/composables/useDarkMode.js +19 -16
- package/lib/client/composables/useData.d.ts +8 -0
- package/lib/client/composables/useData.js +7 -0
- package/lib/client/composables/useEditLink.d.ts +3 -0
- package/lib/client/composables/useEditLink.js +28 -0
- package/lib/client/composables/useHeaders.d.ts +9 -0
- package/lib/client/composables/useHeaders.js +38 -0
- package/lib/client/composables/useNavbarConfig.d.ts +3 -0
- package/lib/client/composables/useNavbarConfig.js +29 -0
- package/lib/client/composables/useNavbarRepo.d.ts +6 -0
- package/lib/client/composables/useNavbarRepo.js +38 -0
- package/lib/client/composables/useNavbarSelectLanguage.d.ts +6 -0
- package/lib/client/composables/useNavbarSelectLanguage.js +55 -0
- package/lib/client/composables/useNavigate.d.ts +1 -0
- package/lib/client/composables/useNavigate.js +22 -0
- package/lib/client/composables/useRelatedLinks.d.ts +8 -0
- package/lib/client/composables/useRelatedLinks.js +90 -0
- package/lib/client/composables/useScrollPromise.js +3 -1
- package/lib/client/composables/useSidebarItems.d.ts +21 -21
- package/lib/client/composables/useSidebarItems.js +97 -84
- package/lib/client/composables/useUpdateDeviceStatus.d.ts +1 -1
- package/lib/client/composables/useUpdateDeviceStatus.js +10 -5
- package/lib/client/config.d.ts +3 -2
- package/lib/client/config.js +11 -22
- package/lib/client/index.d.ts +2 -1
- package/lib/client/index.js +0 -1
- package/lib/client/layouts/Layout.vue +128 -56
- package/lib/client/layouts/NotFound.vue +25 -11
- package/lib/client/shim.d.ts +6 -5
- package/lib/client/styles/_mixins.scss +4 -4
- package/lib/client/styles/_variables.module.scss +1 -1
- package/lib/client/styles/_variables.scss +2 -1
- package/lib/client/styles/arrow.scss +24 -22
- package/lib/client/styles/code-group.scss +34 -30
- package/lib/client/styles/content/code.scss +23 -0
- package/lib/client/styles/content/index.scss +3 -0
- package/lib/client/styles/content/normalize.scss +39 -0
- package/lib/client/styles/{toc.scss → content/toc.scss} +1 -1
- package/lib/client/styles/external-link-icon.scss +36 -0
- package/lib/client/styles/index.scss +3 -13
- package/lib/client/styles/layout.scss +5 -197
- package/lib/client/styles/normalize.scss +1 -193
- package/lib/client/styles/plugins.scss +28 -0
- package/lib/client/styles/vars-dark.scss +20 -58
- package/lib/client/styles/vars.scss +54 -129
- package/lib/client/typings.d.ts +13 -0
- package/lib/client/typings.js +1 -0
- package/lib/client/utils/index.d.ts +2 -2
- package/lib/client/utils/index.js +2 -2
- package/lib/client/utils/isActiveSidebarItem.d.ts +3 -3
- package/lib/client/utils/isActiveSidebarItem.js +1 -1
- package/lib/client/utils/resolveAutoLink.d.ts +9 -0
- package/lib/client/utils/resolveAutoLink.js +17 -0
- package/lib/client/utils/resolveEditLink.d.ts +3 -3
- package/lib/client/utils/resolveEditLink.js +3 -3
- package/lib/client/utils/resolvePrefix.d.ts +1 -0
- package/lib/client/utils/resolvePrefix.js +4 -0
- package/lib/client/utils/resolveRepoType.d.ts +1 -1
- package/lib/client/utils/resolveRepoType.js +4 -4
- package/lib/node/defaultTheme.d.ts +7 -2
- package/lib/node/defaultTheme.js +82 -59
- package/lib/node/index.d.ts +2 -3
- package/lib/node/index.js +0 -3
- package/lib/node/typings.d.ts +59 -0
- package/lib/node/typings.js +1 -0
- package/lib/node/utils/assignDefaultLocaleOptions.js +3 -8
- package/lib/node/utils/index.d.ts +1 -1
- package/lib/node/utils/index.js +1 -1
- package/lib/node/utils/resolveMarkdownHintLocales.d.ts +9 -0
- package/lib/node/utils/resolveMarkdownHintLocales.js +19 -0
- package/lib/shared/index.d.ts +5 -3
- package/lib/shared/index.js +1 -3
- package/lib/shared/nav.d.ts +19 -29
- package/lib/shared/navbar.d.ts +21 -0
- package/lib/shared/navbar.js +1 -0
- package/lib/shared/options.d.ts +48 -47
- package/lib/shared/page.d.ts +9 -6
- package/lib/shared/sidebar.d.ts +26 -0
- package/lib/shared/sidebar.js +1 -0
- package/package.json +32 -25
- package/templates/build.html +23 -14
- package/lib/client/components/AutoLink.vue +0 -113
- package/lib/client/components/DropdownTransition.vue +0 -25
- package/lib/client/components/Home.vue +0 -15
- package/lib/client/components/HomeContent.vue +0 -5
- package/lib/client/components/HomeFeatures.vue +0 -22
- package/lib/client/components/HomeFooter.vue +0 -17
- package/lib/client/components/HomeHero.vue +0 -97
- package/lib/client/components/Navbar.vue +0 -79
- package/lib/client/components/NavbarBrand.vue +0 -55
- package/lib/client/components/NavbarDropdown.vue +0 -126
- package/lib/client/components/NavbarItems.vue +0 -194
- package/lib/client/components/Page.vue +0 -31
- package/lib/client/components/PageMeta.vue +0 -124
- package/lib/client/components/PageNav.vue +0 -113
- package/lib/client/components/Sidebar.vue +0 -18
- package/lib/client/components/SidebarItem.vue +0 -87
- package/lib/client/components/ToggleColorModeButton.vue +0 -57
- package/lib/client/components/ToggleSidebarButton.vue +0 -24
- package/lib/client/components/global/CodeGroup.d.ts +0 -6
- package/lib/client/components/global/CodeGroup.js +0 -120
- package/lib/client/components/global/CodeGroupItem.vue +0 -27
- package/lib/client/composables/useThemeData.d.ts +0 -4
- package/lib/client/composables/useThemeData.js +0 -3
- package/lib/client/styles/badge.scss +0 -36
- package/lib/client/styles/code.scss +0 -263
- package/lib/client/styles/custom-container.scss +0 -142
- package/lib/client/styles/home.scss +0 -168
- package/lib/client/styles/navbar-dropdown.scss +0 -183
- package/lib/client/styles/navbar.scss +0 -197
- package/lib/client/styles/page.scss +0 -87
- package/lib/client/styles/sidebar.scss +0 -134
- package/lib/client/styles/transitions.scss +0 -22
- package/lib/client/utils/getNavLink.d.ts +0 -15
- package/lib/client/utils/getNavLink.js +0 -18
- package/lib/client/utils/getResolveRouteWithRedirect.d.ts +0 -5
- package/lib/client/utils/getResolveRouteWithRedirect.js +0 -22
- package/lib/node/utils/resolveContainerPluginOptions.d.ts +0 -8
- package/lib/node/utils/resolveContainerPluginOptions.js +0 -17
|
@@ -1,126 +0,0 @@
|
|
|
1
|
-
<script setup lang="ts">
|
|
2
|
-
import AutoLink from '@theme/AutoLink.vue'
|
|
3
|
-
import DropdownTransition from '@theme/DropdownTransition.vue'
|
|
4
|
-
import { computed, ref, toRefs, watch } from 'vue'
|
|
5
|
-
import type { PropType } from 'vue'
|
|
6
|
-
import { useRoute } from 'vue-router'
|
|
7
|
-
import type { NavbarItem, ResolvedNavbarItem } from '../../shared/index.js'
|
|
8
|
-
|
|
9
|
-
const props = defineProps({
|
|
10
|
-
item: {
|
|
11
|
-
type: Object as PropType<Exclude<ResolvedNavbarItem, NavbarItem>>,
|
|
12
|
-
required: true,
|
|
13
|
-
},
|
|
14
|
-
})
|
|
15
|
-
|
|
16
|
-
const { item } = toRefs(props)
|
|
17
|
-
|
|
18
|
-
const dropdownAriaLabel = computed(
|
|
19
|
-
() => item.value.ariaLabel || item.value.text,
|
|
20
|
-
)
|
|
21
|
-
|
|
22
|
-
const open = ref(false)
|
|
23
|
-
const route = useRoute()
|
|
24
|
-
watch(
|
|
25
|
-
() => route.path,
|
|
26
|
-
() => {
|
|
27
|
-
open.value = false
|
|
28
|
-
},
|
|
29
|
-
)
|
|
30
|
-
|
|
31
|
-
/**
|
|
32
|
-
* Open the dropdown when user tab and click from keyboard.
|
|
33
|
-
*
|
|
34
|
-
* Use event.detail to detect tab and click from keyboard.
|
|
35
|
-
* The Tab + Click is UIEvent > KeyboardEvent, so the detail is 0.
|
|
36
|
-
*
|
|
37
|
-
* @see https://developer.mozilla.org/en-US/docs/Web/API/UIEvent/detail
|
|
38
|
-
*/
|
|
39
|
-
const handleDropdown = (e): void => {
|
|
40
|
-
const isTriggerByTab = e.detail === 0
|
|
41
|
-
if (isTriggerByTab) {
|
|
42
|
-
open.value = !open.value
|
|
43
|
-
} else {
|
|
44
|
-
open.value = false
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
const isLastItemOfArray = (item: unknown, arr: unknown[]): boolean =>
|
|
49
|
-
arr[arr.length - 1] === item
|
|
50
|
-
</script>
|
|
51
|
-
|
|
52
|
-
<template>
|
|
53
|
-
<div class="navbar-dropdown-wrapper" :class="{ open }">
|
|
54
|
-
<button
|
|
55
|
-
class="navbar-dropdown-title"
|
|
56
|
-
type="button"
|
|
57
|
-
:aria-label="dropdownAriaLabel"
|
|
58
|
-
@click="handleDropdown"
|
|
59
|
-
>
|
|
60
|
-
<span class="title">{{ item.text }}</span>
|
|
61
|
-
<span class="arrow down" />
|
|
62
|
-
</button>
|
|
63
|
-
|
|
64
|
-
<button
|
|
65
|
-
class="navbar-dropdown-title-mobile"
|
|
66
|
-
type="button"
|
|
67
|
-
:aria-label="dropdownAriaLabel"
|
|
68
|
-
@click="open = !open"
|
|
69
|
-
>
|
|
70
|
-
<span class="title">{{ item.text }}</span>
|
|
71
|
-
<span class="arrow" :class="open ? 'down' : 'right'" />
|
|
72
|
-
</button>
|
|
73
|
-
|
|
74
|
-
<DropdownTransition>
|
|
75
|
-
<ul v-show="open" class="navbar-dropdown">
|
|
76
|
-
<li
|
|
77
|
-
v-for="child in item.children"
|
|
78
|
-
:key="child.text"
|
|
79
|
-
class="navbar-dropdown-item"
|
|
80
|
-
>
|
|
81
|
-
<template v-if="child.children">
|
|
82
|
-
<h4 class="navbar-dropdown-subtitle">
|
|
83
|
-
<AutoLink
|
|
84
|
-
v-if="child.link"
|
|
85
|
-
:item="child"
|
|
86
|
-
@focusout="
|
|
87
|
-
isLastItemOfArray(child, item.children) &&
|
|
88
|
-
child.children.length === 0 &&
|
|
89
|
-
(open = false)
|
|
90
|
-
"
|
|
91
|
-
/>
|
|
92
|
-
|
|
93
|
-
<span v-else>{{ child.text }}</span>
|
|
94
|
-
</h4>
|
|
95
|
-
|
|
96
|
-
<ul class="navbar-dropdown-subitem-wrapper">
|
|
97
|
-
<li
|
|
98
|
-
v-for="grandchild in child.children"
|
|
99
|
-
:key="grandchild.link"
|
|
100
|
-
class="navbar-dropdown-subitem"
|
|
101
|
-
>
|
|
102
|
-
<AutoLink
|
|
103
|
-
:item="grandchild"
|
|
104
|
-
@focusout="
|
|
105
|
-
isLastItemOfArray(grandchild, child.children) &&
|
|
106
|
-
isLastItemOfArray(child, item.children) &&
|
|
107
|
-
(open = false)
|
|
108
|
-
"
|
|
109
|
-
/>
|
|
110
|
-
</li>
|
|
111
|
-
</ul>
|
|
112
|
-
</template>
|
|
113
|
-
|
|
114
|
-
<template v-else>
|
|
115
|
-
<AutoLink
|
|
116
|
-
:item="child"
|
|
117
|
-
@focusout="
|
|
118
|
-
isLastItemOfArray(child, item.children) && (open = false)
|
|
119
|
-
"
|
|
120
|
-
/>
|
|
121
|
-
</template>
|
|
122
|
-
</li>
|
|
123
|
-
</ul>
|
|
124
|
-
</DropdownTransition>
|
|
125
|
-
</div>
|
|
126
|
-
</template>
|
|
@@ -1,194 +0,0 @@
|
|
|
1
|
-
<script setup lang="ts">
|
|
2
|
-
import AutoLink from '@theme/AutoLink.vue'
|
|
3
|
-
import NavbarDropdown from '@theme/NavbarDropdown.vue'
|
|
4
|
-
import { computed, ref } from 'vue'
|
|
5
|
-
import type { ComputedRef } from 'vue'
|
|
6
|
-
import { useRouter } from 'vue-router'
|
|
7
|
-
import type { Router } from 'vue-router'
|
|
8
|
-
import { useRouteLocale, useSiteData, useSiteLocaleData } from 'vuepress/client'
|
|
9
|
-
import { isLinkHttp, isString } from 'vuepress/shared'
|
|
10
|
-
import type {
|
|
11
|
-
NavbarGroup,
|
|
12
|
-
NavbarItem,
|
|
13
|
-
ResolvedNavbarItem,
|
|
14
|
-
} from '../../shared/index.js'
|
|
15
|
-
import {
|
|
16
|
-
DeviceType,
|
|
17
|
-
useThemeData,
|
|
18
|
-
useThemeLocaleData,
|
|
19
|
-
useUpdateDeviceStatus,
|
|
20
|
-
} from '../composables/index.js'
|
|
21
|
-
import { getNavLink, resolveRepoType } from '../utils/index.js'
|
|
22
|
-
|
|
23
|
-
/**
|
|
24
|
-
* Get navbar config of select language dropdown
|
|
25
|
-
*/
|
|
26
|
-
const useNavbarSelectLanguage = (): ComputedRef<ResolvedNavbarItem[]> => {
|
|
27
|
-
const router = useRouter()
|
|
28
|
-
const routeLocale = useRouteLocale()
|
|
29
|
-
const site = useSiteData()
|
|
30
|
-
const siteLocale = useSiteLocaleData()
|
|
31
|
-
const theme = useThemeData()
|
|
32
|
-
const themeLocale = useThemeLocaleData()
|
|
33
|
-
|
|
34
|
-
return computed<ResolvedNavbarItem[]>(() => {
|
|
35
|
-
const localePaths = Object.keys(site.value.locales)
|
|
36
|
-
// do not display language selection dropdown if there is only one language
|
|
37
|
-
if (localePaths.length < 2) {
|
|
38
|
-
return []
|
|
39
|
-
}
|
|
40
|
-
const currentPath = router.currentRoute.value.path
|
|
41
|
-
const currentFullPath = router.currentRoute.value.fullPath
|
|
42
|
-
|
|
43
|
-
const languageDropdown: ResolvedNavbarItem = {
|
|
44
|
-
text: `${themeLocale.value.selectLanguageText}`,
|
|
45
|
-
ariaLabel: `${
|
|
46
|
-
themeLocale.value.selectLanguageAriaLabel ??
|
|
47
|
-
themeLocale.value.selectLanguageText
|
|
48
|
-
}`,
|
|
49
|
-
children: localePaths.map((targetLocalePath) => {
|
|
50
|
-
// target locale config of this language link
|
|
51
|
-
const targetSiteLocale = site.value.locales?.[targetLocalePath] ?? {}
|
|
52
|
-
const targetThemeLocale = theme.value.locales?.[targetLocalePath] ?? {}
|
|
53
|
-
const targetLang = `${targetSiteLocale.lang}`
|
|
54
|
-
|
|
55
|
-
const text = targetThemeLocale.selectLanguageName ?? targetLang
|
|
56
|
-
let link
|
|
57
|
-
|
|
58
|
-
if (targetLang === siteLocale.value.lang) {
|
|
59
|
-
// if the target language is current language
|
|
60
|
-
// stay at current link
|
|
61
|
-
link = currentFullPath
|
|
62
|
-
} else {
|
|
63
|
-
// if the target language is not current language
|
|
64
|
-
// try to link to the corresponding page of current page
|
|
65
|
-
// or fallback to homepage
|
|
66
|
-
const targetLocalePage = currentPath.replace(
|
|
67
|
-
routeLocale.value,
|
|
68
|
-
targetLocalePath,
|
|
69
|
-
)
|
|
70
|
-
if (
|
|
71
|
-
router.getRoutes().some((item) => item.path === targetLocalePage)
|
|
72
|
-
) {
|
|
73
|
-
// try to keep current hash and params across languages
|
|
74
|
-
link = currentFullPath.replace(currentPath, targetLocalePage)
|
|
75
|
-
} else {
|
|
76
|
-
link = targetThemeLocale.home ?? targetLocalePath
|
|
77
|
-
}
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
return {
|
|
81
|
-
text,
|
|
82
|
-
link,
|
|
83
|
-
}
|
|
84
|
-
}),
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
return [languageDropdown]
|
|
88
|
-
})
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
/**
|
|
92
|
-
* Get navbar config of repository link
|
|
93
|
-
*/
|
|
94
|
-
const useNavbarRepo = (): ComputedRef<ResolvedNavbarItem[]> => {
|
|
95
|
-
const themeLocale = useThemeLocaleData()
|
|
96
|
-
|
|
97
|
-
const repo = computed(() => themeLocale.value.repo)
|
|
98
|
-
const repoType = computed(() =>
|
|
99
|
-
repo.value ? resolveRepoType(repo.value) : null,
|
|
100
|
-
)
|
|
101
|
-
|
|
102
|
-
const repoLink = computed(() => {
|
|
103
|
-
if (repo.value && !isLinkHttp(repo.value)) {
|
|
104
|
-
return `https://github.com/${repo.value}`
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
return repo.value
|
|
108
|
-
})
|
|
109
|
-
|
|
110
|
-
const repoLabel = computed(() => {
|
|
111
|
-
if (!repoLink.value) return null
|
|
112
|
-
if (themeLocale.value.repoLabel) return themeLocale.value.repoLabel
|
|
113
|
-
if (repoType.value === null) return 'Source'
|
|
114
|
-
return repoType.value
|
|
115
|
-
})
|
|
116
|
-
|
|
117
|
-
return computed(() => {
|
|
118
|
-
if (!repoLink.value || !repoLabel.value) {
|
|
119
|
-
return []
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
return [
|
|
123
|
-
{
|
|
124
|
-
text: repoLabel.value,
|
|
125
|
-
link: repoLink.value,
|
|
126
|
-
},
|
|
127
|
-
]
|
|
128
|
-
})
|
|
129
|
-
}
|
|
130
|
-
|
|
131
|
-
const resolveNavbarItem = (
|
|
132
|
-
router: Router,
|
|
133
|
-
item: NavbarItem | NavbarGroup | string,
|
|
134
|
-
): ResolvedNavbarItem => {
|
|
135
|
-
if (isString(item)) {
|
|
136
|
-
return getNavLink(router, item)
|
|
137
|
-
}
|
|
138
|
-
if ((item as NavbarGroup).children) {
|
|
139
|
-
return {
|
|
140
|
-
...item,
|
|
141
|
-
children: (item as NavbarGroup).children.map((item) =>
|
|
142
|
-
resolveNavbarItem(router, item),
|
|
143
|
-
),
|
|
144
|
-
}
|
|
145
|
-
}
|
|
146
|
-
return item as ResolvedNavbarItem
|
|
147
|
-
}
|
|
148
|
-
|
|
149
|
-
const useNavbarConfig = (): ComputedRef<ResolvedNavbarItem[]> => {
|
|
150
|
-
const router = useRouter()
|
|
151
|
-
const themeLocale = useThemeLocaleData()
|
|
152
|
-
|
|
153
|
-
return computed(() =>
|
|
154
|
-
(themeLocale.value.navbar || []).map((item) =>
|
|
155
|
-
resolveNavbarItem(router, item),
|
|
156
|
-
),
|
|
157
|
-
)
|
|
158
|
-
}
|
|
159
|
-
|
|
160
|
-
const isMobile = ref(false)
|
|
161
|
-
const navbarConfig = useNavbarConfig()
|
|
162
|
-
const navbarSelectLanguage = useNavbarSelectLanguage()
|
|
163
|
-
const navbarRepo = useNavbarRepo()
|
|
164
|
-
const navbarLinks = computed(() => [
|
|
165
|
-
...navbarConfig.value,
|
|
166
|
-
...navbarSelectLanguage.value,
|
|
167
|
-
...navbarRepo.value,
|
|
168
|
-
])
|
|
169
|
-
|
|
170
|
-
useUpdateDeviceStatus(
|
|
171
|
-
DeviceType.MOBILE,
|
|
172
|
-
(mobileDesktopBreakpoint: number): void => {
|
|
173
|
-
// avoid overlapping of long title and long navbar links
|
|
174
|
-
if (window.innerWidth < mobileDesktopBreakpoint) {
|
|
175
|
-
isMobile.value = true
|
|
176
|
-
} else {
|
|
177
|
-
isMobile.value = false
|
|
178
|
-
}
|
|
179
|
-
},
|
|
180
|
-
)
|
|
181
|
-
</script>
|
|
182
|
-
|
|
183
|
-
<template>
|
|
184
|
-
<nav v-if="navbarLinks.length" class="navbar-items">
|
|
185
|
-
<div v-for="item in navbarLinks" :key="item.text" class="navbar-item">
|
|
186
|
-
<NavbarDropdown
|
|
187
|
-
v-if="item.children"
|
|
188
|
-
:item="item"
|
|
189
|
-
:class="isMobile ? 'mobile' : ''"
|
|
190
|
-
/>
|
|
191
|
-
<AutoLink v-else :item="item" />
|
|
192
|
-
</div>
|
|
193
|
-
</nav>
|
|
194
|
-
</template>
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
<script setup lang="ts">
|
|
2
|
-
import PageMeta from '@theme/PageMeta.vue'
|
|
3
|
-
import PageNav from '@theme/PageNav.vue'
|
|
4
|
-
|
|
5
|
-
defineSlots<{
|
|
6
|
-
'top'?: (props: Record<never, never>) => any
|
|
7
|
-
'bottom'?: (props: Record<never, never>) => any
|
|
8
|
-
'content-top'?: (props: Record<never, never>) => any
|
|
9
|
-
'content-bottom'?: (props: Record<never, never>) => any
|
|
10
|
-
}>()
|
|
11
|
-
</script>
|
|
12
|
-
|
|
13
|
-
<template>
|
|
14
|
-
<main class="page">
|
|
15
|
-
<slot name="top" />
|
|
16
|
-
|
|
17
|
-
<div class="theme-default-content">
|
|
18
|
-
<slot name="content-top" />
|
|
19
|
-
|
|
20
|
-
<Content />
|
|
21
|
-
|
|
22
|
-
<slot name="content-bottom" />
|
|
23
|
-
</div>
|
|
24
|
-
|
|
25
|
-
<PageMeta />
|
|
26
|
-
|
|
27
|
-
<PageNav />
|
|
28
|
-
|
|
29
|
-
<slot name="bottom" />
|
|
30
|
-
</main>
|
|
31
|
-
</template>
|
|
@@ -1,124 +0,0 @@
|
|
|
1
|
-
<script setup lang="ts">
|
|
2
|
-
import AutoLink from '@theme/AutoLink.vue'
|
|
3
|
-
import { computed } from 'vue'
|
|
4
|
-
import type { ComputedRef } from 'vue'
|
|
5
|
-
import { usePageData, usePageFrontmatter } from 'vuepress/client'
|
|
6
|
-
import type {
|
|
7
|
-
DefaultThemeNormalPageFrontmatter,
|
|
8
|
-
DefaultThemePageData,
|
|
9
|
-
NavLink,
|
|
10
|
-
} from '../../shared/index.js'
|
|
11
|
-
import { useThemeLocaleData } from '../composables/index.js'
|
|
12
|
-
import { resolveEditLink } from '../utils/index.js'
|
|
13
|
-
|
|
14
|
-
const useEditNavLink = (): ComputedRef<null | NavLink> => {
|
|
15
|
-
const themeLocale = useThemeLocaleData()
|
|
16
|
-
const page = usePageData<DefaultThemePageData>()
|
|
17
|
-
const frontmatter = usePageFrontmatter<DefaultThemeNormalPageFrontmatter>()
|
|
18
|
-
|
|
19
|
-
return computed(() => {
|
|
20
|
-
const showEditLink =
|
|
21
|
-
frontmatter.value.editLink ?? themeLocale.value.editLink ?? true
|
|
22
|
-
if (!showEditLink) {
|
|
23
|
-
return null
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
const {
|
|
27
|
-
repo,
|
|
28
|
-
docsRepo = repo,
|
|
29
|
-
docsBranch = 'main',
|
|
30
|
-
docsDir = '',
|
|
31
|
-
editLinkText,
|
|
32
|
-
} = themeLocale.value
|
|
33
|
-
|
|
34
|
-
if (!docsRepo) return null
|
|
35
|
-
|
|
36
|
-
const editLink = resolveEditLink({
|
|
37
|
-
docsRepo,
|
|
38
|
-
docsBranch,
|
|
39
|
-
docsDir,
|
|
40
|
-
filePathRelative: page.value.filePathRelative,
|
|
41
|
-
editLinkPattern:
|
|
42
|
-
frontmatter.value.editLinkPattern ?? themeLocale.value.editLinkPattern,
|
|
43
|
-
})
|
|
44
|
-
|
|
45
|
-
if (!editLink) return null
|
|
46
|
-
|
|
47
|
-
return {
|
|
48
|
-
text: editLinkText ?? 'Edit this page',
|
|
49
|
-
link: editLink,
|
|
50
|
-
}
|
|
51
|
-
})
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
const useLastUpdated = (): ComputedRef<null | string> => {
|
|
55
|
-
const themeLocale = useThemeLocaleData()
|
|
56
|
-
const page = usePageData<DefaultThemePageData>()
|
|
57
|
-
const frontmatter = usePageFrontmatter<DefaultThemeNormalPageFrontmatter>()
|
|
58
|
-
|
|
59
|
-
return computed(() => {
|
|
60
|
-
const showLastUpdated =
|
|
61
|
-
frontmatter.value.lastUpdated ?? themeLocale.value.lastUpdated ?? true
|
|
62
|
-
|
|
63
|
-
if (!showLastUpdated) return null
|
|
64
|
-
|
|
65
|
-
if (!page.value.git?.updatedTime) return null
|
|
66
|
-
|
|
67
|
-
const updatedDate = new Date(page.value.git?.updatedTime)
|
|
68
|
-
|
|
69
|
-
return updatedDate.toLocaleString()
|
|
70
|
-
})
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
const useContributors = (): ComputedRef<
|
|
74
|
-
null | Required<DefaultThemePageData['git']>['contributors']
|
|
75
|
-
> => {
|
|
76
|
-
const themeLocale = useThemeLocaleData()
|
|
77
|
-
const page = usePageData<DefaultThemePageData>()
|
|
78
|
-
const frontmatter = usePageFrontmatter<DefaultThemeNormalPageFrontmatter>()
|
|
79
|
-
|
|
80
|
-
return computed(() => {
|
|
81
|
-
const showContributors =
|
|
82
|
-
frontmatter.value.contributors ?? themeLocale.value.contributors ?? true
|
|
83
|
-
|
|
84
|
-
if (!showContributors) return null
|
|
85
|
-
|
|
86
|
-
return page.value.git?.contributors ?? null
|
|
87
|
-
})
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
const themeLocale = useThemeLocaleData()
|
|
91
|
-
const editNavLink = useEditNavLink()
|
|
92
|
-
const lastUpdated = useLastUpdated()
|
|
93
|
-
const contributors = useContributors()
|
|
94
|
-
</script>
|
|
95
|
-
|
|
96
|
-
<template>
|
|
97
|
-
<footer class="page-meta">
|
|
98
|
-
<div v-if="editNavLink" class="meta-item edit-link">
|
|
99
|
-
<AutoLink class="meta-item-label" :item="editNavLink" />
|
|
100
|
-
</div>
|
|
101
|
-
|
|
102
|
-
<div v-if="lastUpdated" class="meta-item last-updated">
|
|
103
|
-
<span class="meta-item-label">{{ themeLocale.lastUpdatedText }}: </span>
|
|
104
|
-
<ClientOnly>
|
|
105
|
-
<span class="meta-item-info">{{ lastUpdated }}</span>
|
|
106
|
-
</ClientOnly>
|
|
107
|
-
</div>
|
|
108
|
-
|
|
109
|
-
<div
|
|
110
|
-
v-if="contributors && contributors.length"
|
|
111
|
-
class="meta-item contributors"
|
|
112
|
-
>
|
|
113
|
-
<span class="meta-item-label">{{ themeLocale.contributorsText }}: </span>
|
|
114
|
-
<span class="meta-item-info">
|
|
115
|
-
<template v-for="(contributor, index) in contributors" :key="index">
|
|
116
|
-
<span class="contributor" :title="`email: ${contributor.email}`">
|
|
117
|
-
{{ contributor.name }}
|
|
118
|
-
</span>
|
|
119
|
-
<template v-if="index !== contributors.length - 1">, </template>
|
|
120
|
-
</template>
|
|
121
|
-
</span>
|
|
122
|
-
</div>
|
|
123
|
-
</footer>
|
|
124
|
-
</template>
|
|
@@ -1,113 +0,0 @@
|
|
|
1
|
-
<script setup lang="ts">
|
|
2
|
-
import AutoLink from '@theme/AutoLink.vue'
|
|
3
|
-
import { computed } from 'vue'
|
|
4
|
-
import type { Router } from 'vue-router'
|
|
5
|
-
import { useRoute, useRouter } from 'vue-router'
|
|
6
|
-
import { usePageFrontmatter } from 'vuepress/client'
|
|
7
|
-
import { isPlainObject, isString } from 'vuepress/shared'
|
|
8
|
-
import type {
|
|
9
|
-
DefaultThemeNormalPageFrontmatter,
|
|
10
|
-
NavLink,
|
|
11
|
-
ResolvedSidebarItem,
|
|
12
|
-
} from '../../shared/index.js'
|
|
13
|
-
import { useSidebarItems } from '../composables/index.js'
|
|
14
|
-
import { getNavLink } from '../utils/index.js'
|
|
15
|
-
|
|
16
|
-
/**
|
|
17
|
-
* Resolve `prev` or `next` config from frontmatter
|
|
18
|
-
*/
|
|
19
|
-
const resolveFromFrontmatterConfig = (
|
|
20
|
-
router: Router,
|
|
21
|
-
conf: unknown,
|
|
22
|
-
): null | false | NavLink => {
|
|
23
|
-
if (conf === false) {
|
|
24
|
-
return null
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
if (isString(conf)) {
|
|
28
|
-
return getNavLink(router, conf)
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
if (isPlainObject<NavLink>(conf)) {
|
|
32
|
-
return conf
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
return false
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
/**
|
|
39
|
-
* Resolve `prev` or `next` config from sidebar items
|
|
40
|
-
*/
|
|
41
|
-
const resolveFromSidebarItems = (
|
|
42
|
-
sidebarItems: ResolvedSidebarItem[],
|
|
43
|
-
currentPath: string,
|
|
44
|
-
offset: number,
|
|
45
|
-
): null | NavLink => {
|
|
46
|
-
const index = sidebarItems.findIndex((item) => item.link === currentPath)
|
|
47
|
-
if (index !== -1) {
|
|
48
|
-
const targetItem = sidebarItems[index + offset]
|
|
49
|
-
if (!targetItem?.link) {
|
|
50
|
-
return null
|
|
51
|
-
}
|
|
52
|
-
return targetItem as NavLink
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
for (const item of sidebarItems) {
|
|
56
|
-
if (item.children) {
|
|
57
|
-
const childResult = resolveFromSidebarItems(
|
|
58
|
-
item.children,
|
|
59
|
-
currentPath,
|
|
60
|
-
offset,
|
|
61
|
-
)
|
|
62
|
-
if (childResult) {
|
|
63
|
-
return childResult
|
|
64
|
-
}
|
|
65
|
-
}
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
return null
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
const frontmatter = usePageFrontmatter<DefaultThemeNormalPageFrontmatter>()
|
|
72
|
-
const sidebarItems = useSidebarItems()
|
|
73
|
-
const route = useRoute()
|
|
74
|
-
const router = useRouter()
|
|
75
|
-
|
|
76
|
-
const prevNavLink = computed(() => {
|
|
77
|
-
const prevConfig = resolveFromFrontmatterConfig(
|
|
78
|
-
router,
|
|
79
|
-
frontmatter.value.prev,
|
|
80
|
-
)
|
|
81
|
-
if (prevConfig !== false) {
|
|
82
|
-
return prevConfig
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
return resolveFromSidebarItems(sidebarItems.value, route.path, -1)
|
|
86
|
-
})
|
|
87
|
-
|
|
88
|
-
const nextNavLink = computed(() => {
|
|
89
|
-
const nextConfig = resolveFromFrontmatterConfig(
|
|
90
|
-
router,
|
|
91
|
-
frontmatter.value.next,
|
|
92
|
-
)
|
|
93
|
-
if (nextConfig !== false) {
|
|
94
|
-
return nextConfig
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
return resolveFromSidebarItems(sidebarItems.value, route.path, 1)
|
|
98
|
-
})
|
|
99
|
-
</script>
|
|
100
|
-
|
|
101
|
-
<template>
|
|
102
|
-
<nav v-if="prevNavLink || nextNavLink" class="page-nav">
|
|
103
|
-
<p class="inner">
|
|
104
|
-
<span v-if="prevNavLink" class="prev">
|
|
105
|
-
<AutoLink :item="prevNavLink" />
|
|
106
|
-
</span>
|
|
107
|
-
|
|
108
|
-
<span v-if="nextNavLink" class="next">
|
|
109
|
-
<AutoLink :item="nextNavLink" />
|
|
110
|
-
</span>
|
|
111
|
-
</p>
|
|
112
|
-
</nav>
|
|
113
|
-
</template>
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
<script setup lang="ts">
|
|
2
|
-
import NavbarItems from '@theme/NavbarItems.vue'
|
|
3
|
-
import SidebarItems from '@theme/SidebarItems.vue'
|
|
4
|
-
|
|
5
|
-
defineSlots<{
|
|
6
|
-
top?: (props: Record<never, never>) => any
|
|
7
|
-
bottom?: (props: Record<never, never>) => any
|
|
8
|
-
}>()
|
|
9
|
-
</script>
|
|
10
|
-
|
|
11
|
-
<template>
|
|
12
|
-
<aside class="sidebar">
|
|
13
|
-
<NavbarItems />
|
|
14
|
-
<slot name="top" />
|
|
15
|
-
<SidebarItems />
|
|
16
|
-
<slot name="bottom" />
|
|
17
|
-
</aside>
|
|
18
|
-
</template>
|
|
@@ -1,87 +0,0 @@
|
|
|
1
|
-
<script setup lang="ts">
|
|
2
|
-
import AutoLink from '@theme/AutoLink.vue'
|
|
3
|
-
import DropdownTransition from '@theme/DropdownTransition.vue'
|
|
4
|
-
import { useToggle } from '@vueuse/core'
|
|
5
|
-
import { computed, nextTick, onBeforeUnmount, toRefs } from 'vue'
|
|
6
|
-
import type { PropType } from 'vue'
|
|
7
|
-
import { useRoute, useRouter } from 'vue-router'
|
|
8
|
-
import type { ResolvedSidebarItem } from '../../shared/index.js'
|
|
9
|
-
import { isActiveSidebarItem } from '../utils/index.js'
|
|
10
|
-
|
|
11
|
-
const props = defineProps({
|
|
12
|
-
item: {
|
|
13
|
-
type: Object as PropType<ResolvedSidebarItem>,
|
|
14
|
-
required: true,
|
|
15
|
-
},
|
|
16
|
-
depth: {
|
|
17
|
-
type: Number,
|
|
18
|
-
required: false,
|
|
19
|
-
default: 0,
|
|
20
|
-
},
|
|
21
|
-
})
|
|
22
|
-
|
|
23
|
-
const { item, depth } = toRefs(props)
|
|
24
|
-
const route = useRoute()
|
|
25
|
-
const router = useRouter()
|
|
26
|
-
|
|
27
|
-
const isActive = computed(() => isActiveSidebarItem(item.value, route))
|
|
28
|
-
const itemClass = computed(() => ({
|
|
29
|
-
'sidebar-item': true,
|
|
30
|
-
'sidebar-heading': depth.value === 0,
|
|
31
|
-
'active': isActive.value,
|
|
32
|
-
'collapsible': item.value.collapsible,
|
|
33
|
-
}))
|
|
34
|
-
|
|
35
|
-
const isOpenDefault = computed(() =>
|
|
36
|
-
item.value.collapsible ? isActive.value : true,
|
|
37
|
-
)
|
|
38
|
-
const [isOpen, toggleIsOpen] = useToggle(isOpenDefault.value)
|
|
39
|
-
const onClick = (e: Event): void => {
|
|
40
|
-
if (item.value.collapsible) {
|
|
41
|
-
e.preventDefault()
|
|
42
|
-
// toggle open status on click
|
|
43
|
-
toggleIsOpen()
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
// reset open status after navigation
|
|
48
|
-
const unregisterRouterHook = router.afterEach((to) => {
|
|
49
|
-
nextTick(() => {
|
|
50
|
-
isOpen.value = isOpenDefault.value
|
|
51
|
-
})
|
|
52
|
-
})
|
|
53
|
-
onBeforeUnmount(() => {
|
|
54
|
-
unregisterRouterHook()
|
|
55
|
-
})
|
|
56
|
-
</script>
|
|
57
|
-
|
|
58
|
-
<template>
|
|
59
|
-
<li>
|
|
60
|
-
<AutoLink v-if="item.link" :class="itemClass" :item="item" />
|
|
61
|
-
<p
|
|
62
|
-
v-else
|
|
63
|
-
tabindex="0"
|
|
64
|
-
:class="itemClass"
|
|
65
|
-
@click="onClick"
|
|
66
|
-
@keydown.enter="onClick"
|
|
67
|
-
>
|
|
68
|
-
{{ item.text }}
|
|
69
|
-
<span
|
|
70
|
-
v-if="item.collapsible"
|
|
71
|
-
class="arrow"
|
|
72
|
-
:class="isOpen ? 'down' : 'right'"
|
|
73
|
-
/>
|
|
74
|
-
</p>
|
|
75
|
-
|
|
76
|
-
<DropdownTransition v-if="item.children?.length">
|
|
77
|
-
<ul v-show="isOpen" class="sidebar-item-children">
|
|
78
|
-
<SidebarItem
|
|
79
|
-
v-for="child in item.children"
|
|
80
|
-
:key="`${depth}${child.text}${child.link}`"
|
|
81
|
-
:item="child"
|
|
82
|
-
:depth="depth + 1"
|
|
83
|
-
/>
|
|
84
|
-
</ul>
|
|
85
|
-
</DropdownTransition>
|
|
86
|
-
</li>
|
|
87
|
-
</template>
|