@vuepress/theme-default 2.0.0-beta.8 → 2.0.0-rc.0
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/AutoLink.vue +119 -0
- package/lib/client/components/DropdownTransition.vue +15 -24
- package/lib/client/components/Home.vue +12 -130
- package/lib/client/components/HomeContent.vue +5 -0
- package/lib/client/components/HomeFeatures.vue +23 -0
- package/lib/client/components/HomeFooter.vue +17 -0
- package/lib/client/components/HomeHero.vue +98 -0
- package/lib/client/components/Navbar.vue +60 -95
- package/lib/client/components/NavbarBrand.vue +55 -0
- package/lib/client/components/NavbarDropdown.vue +126 -0
- package/lib/client/components/{NavbarLinks.vue → NavbarItems.vue} +73 -58
- package/lib/client/components/Page.vue +16 -15
- package/lib/client/components/PageMeta.vue +51 -66
- package/lib/client/components/PageNav.vue +47 -60
- package/lib/client/components/Sidebar.vue +12 -32
- package/lib/client/components/SidebarItem.vue +87 -0
- package/lib/client/components/SidebarItems.vue +57 -0
- package/lib/client/components/ToggleColorModeButton.vue +57 -0
- package/lib/client/components/ToggleSidebarButton.vue +21 -24
- package/lib/client/components/global/Badge.vue +24 -26
- package/lib/client/components/global/CodeGroup.d.ts +5 -4
- package/lib/client/components/global/CodeGroup.js +85 -17
- package/lib/client/components/global/CodeGroupItem.vue +23 -17
- package/lib/client/components/global/index.d.ts +4 -0
- package/lib/client/components/global/index.js +4 -0
- package/lib/client/composables/index.d.ts +7 -5
- package/lib/client/composables/index.js +7 -5
- package/lib/client/composables/useDarkMode.d.ts +12 -0
- package/lib/client/composables/useDarkMode.js +57 -0
- package/lib/client/composables/useNavLink.d.ts +6 -1
- package/lib/client/composables/useNavLink.js +5 -2
- package/lib/client/composables/useResolveRouteWithRedirect.js +2 -2
- package/lib/client/composables/useScrollPromise.js +1 -1
- package/lib/client/composables/useSidebarItems.d.ts +13 -8
- package/lib/client/composables/useSidebarItems.js +42 -38
- package/lib/client/composables/useThemeData.d.ts +2 -2
- package/lib/client/composables/useThemeData.js +1 -1
- package/lib/client/composables/useUpdateDeviceStatus.d.ts +7 -0
- package/lib/client/composables/useUpdateDeviceStatus.js +25 -0
- package/lib/client/config.d.ts +3 -0
- package/lib/client/config.js +44 -0
- package/lib/client/index.d.ts +3 -4
- package/lib/client/index.js +3 -2
- package/lib/client/layouts/Layout.vue +133 -136
- package/lib/client/layouts/NotFound.vue +27 -0
- package/lib/client/shim.d.ts +5 -0
- package/lib/client/styles/{_wrapper.scss → _mixins.scss} +7 -2
- package/lib/client/styles/_variables.module.scss +5 -0
- package/lib/client/styles/_variables.scss +0 -28
- package/lib/client/styles/arrow.scss +4 -6
- package/lib/client/styles/badge.scss +14 -11
- package/lib/client/styles/code-group.scss +9 -2
- package/lib/client/styles/code.scss +35 -49
- package/lib/client/styles/custom-container.scss +82 -18
- package/lib/client/styles/home.scss +32 -24
- package/lib/client/styles/index.scss +4 -4
- package/lib/client/styles/layout.scss +82 -73
- package/lib/client/styles/{dropdown.scss → navbar-dropdown.scss} +36 -50
- package/lib/client/styles/navbar.scss +106 -50
- package/lib/client/styles/normalize.scss +200 -0
- package/lib/client/styles/page.scss +24 -8
- package/lib/client/styles/sidebar.scss +69 -87
- package/lib/client/styles/transitions.scss +13 -4
- package/lib/client/styles/vars-dark.scss +68 -0
- package/lib/client/styles/vars.scss +149 -0
- package/lib/client/utils/index.d.ts +3 -2
- package/lib/client/utils/index.js +3 -2
- package/lib/client/utils/isActiveSidebarItem.d.ts +3 -0
- package/lib/client/utils/isActiveSidebarItem.js +20 -0
- package/lib/client/utils/resolveEditLink.d.ts +2 -2
- package/lib/client/utils/resolveEditLink.js +15 -9
- package/lib/client/utils/resolveRepoType.d.ts +1 -1
- package/lib/client/utils/resolveRepoType.js +3 -1
- package/lib/node/defaultTheme.d.ts +4 -4
- package/lib/node/defaultTheme.js +111 -48
- package/lib/node/index.d.ts +4 -4
- package/lib/node/index.js +5 -17
- package/lib/node/utils/assignDefaultLocaleOptions.d.ts +4 -2
- package/lib/node/utils/assignDefaultLocaleOptions.js +13 -13
- package/lib/node/utils/index.d.ts +2 -5
- package/lib/node/utils/index.js +2 -17
- package/lib/node/utils/resolveContainerPluginOptions.d.ts +2 -20
- package/lib/node/utils/resolveContainerPluginOptions.js +4 -66
- package/lib/shared/index.d.ts +3 -3
- package/lib/shared/index.js +3 -15
- package/lib/shared/nav.d.ts +16 -18
- package/lib/shared/nav.js +1 -2
- package/lib/shared/options.d.ts +51 -6
- package/lib/shared/options.js +1 -2
- package/lib/shared/page.d.ts +15 -6
- package/lib/shared/page.js +1 -2
- package/package.json +49 -29
- package/templates/build.html +34 -0
- package/CHANGELOG.md +0 -403
- package/lib/client/clientAppEnhance.d.ts +0 -3
- package/lib/client/clientAppEnhance.js +0 -30
- package/lib/client/clientAppSetup.d.ts +0 -2
- package/lib/client/clientAppSetup.js +0 -11
- package/lib/client/components/DropdownLink.vue +0 -141
- package/lib/client/components/NavLink.vue +0 -115
- package/lib/client/components/SidebarChild.d.ts +0 -6
- package/lib/client/components/SidebarChild.js +0 -91
- package/lib/client/components/global/OutboundLink.vue +0 -30
- package/lib/client/layouts/404.vue +0 -38
- package/lib/client/styles/_normalize.scss +0 -148
- package/lib/client/styles/plugins.scss +0 -18
- package/lib/client/styles/sr-only.scss +0 -12
- package/lib/node/utils/resolveActiveHeaderLinksPluginOptions.d.ts +0 -6
- package/lib/node/utils/resolveActiveHeaderLinksPluginOptions.js +0 -16
- package/lib/node/utils/resolveGitPluginOptions.d.ts +0 -6
- package/lib/node/utils/resolveGitPluginOptions.js +0 -22
- package/lib/node/utils/resolveMediumZoomPluginOptions.d.ts +0 -6
- package/lib/node/utils/resolveMediumZoomPluginOptions.js +0 -17
|
@@ -0,0 +1,126 @@
|
|
|
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,28 +1,28 @@
|
|
|
1
|
-
<
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
</div>
|
|
12
|
-
</nav>
|
|
13
|
-
</template>
|
|
14
|
-
|
|
15
|
-
<script lang="ts">
|
|
16
|
-
import { computed, defineComponent } from 'vue'
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
import AutoLink from '@theme/AutoLink.vue'
|
|
3
|
+
import NavbarDropdown from '@theme/NavbarDropdown.vue'
|
|
4
|
+
import {
|
|
5
|
+
useRouteLocale,
|
|
6
|
+
useSiteData,
|
|
7
|
+
useSiteLocaleData,
|
|
8
|
+
} from '@vuepress/client'
|
|
9
|
+
import { isLinkHttp, isString } from '@vuepress/shared'
|
|
10
|
+
import { computed, ref } from 'vue'
|
|
17
11
|
import type { ComputedRef } from 'vue'
|
|
18
12
|
import { useRouter } from 'vue-router'
|
|
19
|
-
import {
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
import
|
|
25
|
-
|
|
13
|
+
import type {
|
|
14
|
+
NavbarGroup,
|
|
15
|
+
NavbarItem,
|
|
16
|
+
ResolvedNavbarItem,
|
|
17
|
+
} from '../../shared/index.js'
|
|
18
|
+
import {
|
|
19
|
+
DeviceType,
|
|
20
|
+
useNavLink,
|
|
21
|
+
useThemeData,
|
|
22
|
+
useThemeLocaleData,
|
|
23
|
+
useUpdateDeviceStatus,
|
|
24
|
+
} from '../composables/index.js'
|
|
25
|
+
import { resolveRepoType } from '../utils/index.js'
|
|
26
26
|
|
|
27
27
|
/**
|
|
28
28
|
* Get navbar config of select language dropdown
|
|
@@ -30,11 +30,13 @@ import NavLink from './NavLink.vue'
|
|
|
30
30
|
const useNavbarSelectLanguage = (): ComputedRef<ResolvedNavbarItem[]> => {
|
|
31
31
|
const router = useRouter()
|
|
32
32
|
const routeLocale = useRouteLocale()
|
|
33
|
+
const site = useSiteData()
|
|
33
34
|
const siteLocale = useSiteLocaleData()
|
|
35
|
+
const theme = useThemeData()
|
|
34
36
|
const themeLocale = useThemeLocaleData()
|
|
35
37
|
|
|
36
38
|
return computed<ResolvedNavbarItem[]>(() => {
|
|
37
|
-
const localePaths = Object.keys(
|
|
39
|
+
const localePaths = Object.keys(site.value.locales)
|
|
38
40
|
// do not display language selection dropdown if there is only one language
|
|
39
41
|
if (localePaths.length < 2) {
|
|
40
42
|
return []
|
|
@@ -43,14 +45,15 @@ const useNavbarSelectLanguage = (): ComputedRef<ResolvedNavbarItem[]> => {
|
|
|
43
45
|
const currentFullPath = router.currentRoute.value.fullPath
|
|
44
46
|
|
|
45
47
|
const languageDropdown: ResolvedNavbarItem = {
|
|
46
|
-
text: themeLocale.value.selectLanguageText
|
|
47
|
-
ariaLabel:
|
|
48
|
+
text: `${themeLocale.value.selectLanguageText}`,
|
|
49
|
+
ariaLabel: `${
|
|
50
|
+
themeLocale.value.selectLanguageAriaLabel ??
|
|
51
|
+
themeLocale.value.selectLanguageText
|
|
52
|
+
}`,
|
|
48
53
|
children: localePaths.map((targetLocalePath) => {
|
|
49
|
-
// target locale config of this
|
|
50
|
-
const targetSiteLocale =
|
|
51
|
-
|
|
52
|
-
const targetThemeLocale =
|
|
53
|
-
themeLocale.value.locales?.[targetLocalePath] ?? {}
|
|
54
|
+
// target locale config of this language link
|
|
55
|
+
const targetSiteLocale = site.value.locales?.[targetLocalePath] ?? {}
|
|
56
|
+
const targetThemeLocale = theme.value.locales?.[targetLocalePath] ?? {}
|
|
54
57
|
const targetLang = `${targetSiteLocale.lang}`
|
|
55
58
|
|
|
56
59
|
const text = targetThemeLocale.selectLanguageName ?? targetLang
|
|
@@ -66,12 +69,13 @@ const useNavbarSelectLanguage = (): ComputedRef<ResolvedNavbarItem[]> => {
|
|
|
66
69
|
// or fallback to homepage
|
|
67
70
|
const targetLocalePage = currentPath.replace(
|
|
68
71
|
routeLocale.value,
|
|
69
|
-
targetLocalePath
|
|
72
|
+
targetLocalePath,
|
|
70
73
|
)
|
|
71
74
|
if (
|
|
72
75
|
router.getRoutes().some((item) => item.path === targetLocalePage)
|
|
73
76
|
) {
|
|
74
|
-
|
|
77
|
+
// try to keep current hash and params across languages
|
|
78
|
+
link = currentFullPath.replace(currentPath, targetLocalePage)
|
|
75
79
|
} else {
|
|
76
80
|
link = targetThemeLocale.home ?? targetLocalePath
|
|
77
81
|
}
|
|
@@ -96,13 +100,14 @@ const useNavbarRepo = (): ComputedRef<ResolvedNavbarItem[]> => {
|
|
|
96
100
|
|
|
97
101
|
const repo = computed(() => themeLocale.value.repo)
|
|
98
102
|
const repoType = computed(() =>
|
|
99
|
-
repo.value ? resolveRepoType(repo.value) : null
|
|
103
|
+
repo.value ? resolveRepoType(repo.value) : null,
|
|
100
104
|
)
|
|
101
105
|
|
|
102
106
|
const repoLink = computed(() => {
|
|
103
|
-
if (
|
|
107
|
+
if (repo.value && !isLinkHttp(repo.value)) {
|
|
104
108
|
return `https://github.com/${repo.value}`
|
|
105
109
|
}
|
|
110
|
+
|
|
106
111
|
return repo.value
|
|
107
112
|
})
|
|
108
113
|
|
|
@@ -128,7 +133,7 @@ const useNavbarRepo = (): ComputedRef<ResolvedNavbarItem[]> => {
|
|
|
128
133
|
}
|
|
129
134
|
|
|
130
135
|
const resolveNavbarItem = (
|
|
131
|
-
item: NavbarItem | NavbarGroup | string
|
|
136
|
+
item: NavbarItem | NavbarGroup | string,
|
|
132
137
|
): ResolvedNavbarItem => {
|
|
133
138
|
if (isString(item)) {
|
|
134
139
|
return useNavLink(item)
|
|
@@ -147,28 +152,38 @@ const useNavbarConfig = (): ComputedRef<ResolvedNavbarItem[]> => {
|
|
|
147
152
|
return computed(() => (themeLocale.value.navbar || []).map(resolveNavbarItem))
|
|
148
153
|
}
|
|
149
154
|
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
return {
|
|
170
|
-
navbarLinks,
|
|
155
|
+
const isMobile = ref(false)
|
|
156
|
+
const navbarConfig = useNavbarConfig()
|
|
157
|
+
const navbarSelectLanguage = useNavbarSelectLanguage()
|
|
158
|
+
const navbarRepo = useNavbarRepo()
|
|
159
|
+
const navbarLinks = computed(() => [
|
|
160
|
+
...navbarConfig.value,
|
|
161
|
+
...navbarSelectLanguage.value,
|
|
162
|
+
...navbarRepo.value,
|
|
163
|
+
])
|
|
164
|
+
|
|
165
|
+
useUpdateDeviceStatus(
|
|
166
|
+
DeviceType.MOBILE,
|
|
167
|
+
(mobileDesktopBreakpoint: number): void => {
|
|
168
|
+
// avoid overlapping of long title and long navbar links
|
|
169
|
+
if (window.innerWidth < mobileDesktopBreakpoint) {
|
|
170
|
+
isMobile.value = true
|
|
171
|
+
} else {
|
|
172
|
+
isMobile.value = false
|
|
171
173
|
}
|
|
172
174
|
},
|
|
173
|
-
|
|
175
|
+
)
|
|
174
176
|
</script>
|
|
177
|
+
|
|
178
|
+
<template>
|
|
179
|
+
<nav v-if="navbarLinks.length" class="navbar-items">
|
|
180
|
+
<div v-for="item in navbarLinks" :key="item.text" class="navbar-item">
|
|
181
|
+
<NavbarDropdown
|
|
182
|
+
v-if="item.children"
|
|
183
|
+
:item="item"
|
|
184
|
+
:class="isMobile ? 'mobile' : ''"
|
|
185
|
+
/>
|
|
186
|
+
<AutoLink v-else :item="item" />
|
|
187
|
+
</div>
|
|
188
|
+
</nav>
|
|
189
|
+
</template>
|
|
@@ -1,9 +1,25 @@
|
|
|
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
|
+
|
|
1
13
|
<template>
|
|
2
14
|
<main class="page">
|
|
3
15
|
<slot name="top" />
|
|
4
16
|
|
|
5
17
|
<div class="theme-default-content">
|
|
18
|
+
<slot name="content-top" />
|
|
19
|
+
|
|
6
20
|
<Content />
|
|
21
|
+
|
|
22
|
+
<slot name="content-bottom" />
|
|
7
23
|
</div>
|
|
8
24
|
|
|
9
25
|
<PageMeta />
|
|
@@ -13,18 +29,3 @@
|
|
|
13
29
|
<slot name="bottom" />
|
|
14
30
|
</main>
|
|
15
31
|
</template>
|
|
16
|
-
|
|
17
|
-
<script>
|
|
18
|
-
import { defineComponent } from 'vue'
|
|
19
|
-
import PageMeta from './PageMeta.vue'
|
|
20
|
-
import PageNav from './PageNav.vue'
|
|
21
|
-
|
|
22
|
-
export default defineComponent({
|
|
23
|
-
name: 'Page',
|
|
24
|
-
|
|
25
|
-
components: {
|
|
26
|
-
PageMeta,
|
|
27
|
-
PageNav,
|
|
28
|
-
},
|
|
29
|
-
})
|
|
30
|
-
</script>
|
|
@@ -1,48 +1,20 @@
|
|
|
1
|
-
<
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
</div>
|
|
6
|
-
|
|
7
|
-
<div v-if="lastUpdated" class="meta-item last-updated">
|
|
8
|
-
<span class="meta-item-label">{{ themeLocale.lastUpdatedText }}: </span>
|
|
9
|
-
<span class="meta-item-info">{{ lastUpdated }}</span>
|
|
10
|
-
</div>
|
|
11
|
-
|
|
12
|
-
<div
|
|
13
|
-
v-if="contributors && contributors.length"
|
|
14
|
-
class="meta-item contributors"
|
|
15
|
-
>
|
|
16
|
-
<span class="meta-item-label">{{ themeLocale.contributorsText }}: </span>
|
|
17
|
-
<span class="meta-item-info">
|
|
18
|
-
<template v-for="(contributor, index) in contributors" :key="index">
|
|
19
|
-
<span class="contributor" :title="`email: ${contributor.email}`">
|
|
20
|
-
{{ contributor.name }}
|
|
21
|
-
</span>
|
|
22
|
-
<template v-if="index !== contributors.length - 1">, </template>
|
|
23
|
-
</template>
|
|
24
|
-
</span>
|
|
25
|
-
</div>
|
|
26
|
-
</footer>
|
|
27
|
-
</template>
|
|
28
|
-
|
|
29
|
-
<script lang="ts">
|
|
30
|
-
import { computed, defineComponent } from 'vue'
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
import AutoLink from '@theme/AutoLink.vue'
|
|
3
|
+
import { usePageData, usePageFrontmatter } from '@vuepress/client'
|
|
4
|
+
import { computed } from 'vue'
|
|
31
5
|
import type { ComputedRef } from 'vue'
|
|
32
|
-
import {
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
} from '
|
|
37
|
-
import
|
|
38
|
-
import {
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
const useEditNavLink = (): ComputedRef<null | NavLinkType> => {
|
|
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> => {
|
|
43
15
|
const themeLocale = useThemeLocaleData()
|
|
44
16
|
const page = usePageData<DefaultThemePageData>()
|
|
45
|
-
const frontmatter = usePageFrontmatter()
|
|
17
|
+
const frontmatter = usePageFrontmatter<DefaultThemeNormalPageFrontmatter>()
|
|
46
18
|
|
|
47
19
|
return computed(() => {
|
|
48
20
|
const showEditLink =
|
|
@@ -66,7 +38,8 @@ const useEditNavLink = (): ComputedRef<null | NavLinkType> => {
|
|
|
66
38
|
docsBranch,
|
|
67
39
|
docsDir,
|
|
68
40
|
filePathRelative: page.value.filePathRelative,
|
|
69
|
-
editLinkPattern:
|
|
41
|
+
editLinkPattern:
|
|
42
|
+
frontmatter.value.editLinkPattern ?? themeLocale.value.editLinkPattern,
|
|
70
43
|
})
|
|
71
44
|
|
|
72
45
|
if (!editLink) return null
|
|
@@ -79,10 +52,9 @@ const useEditNavLink = (): ComputedRef<null | NavLinkType> => {
|
|
|
79
52
|
}
|
|
80
53
|
|
|
81
54
|
const useLastUpdated = (): ComputedRef<null | string> => {
|
|
82
|
-
const siteLocale = useSiteLocaleData()
|
|
83
55
|
const themeLocale = useThemeLocaleData()
|
|
84
56
|
const page = usePageData<DefaultThemePageData>()
|
|
85
|
-
const frontmatter = usePageFrontmatter()
|
|
57
|
+
const frontmatter = usePageFrontmatter<DefaultThemeNormalPageFrontmatter>()
|
|
86
58
|
|
|
87
59
|
return computed(() => {
|
|
88
60
|
const showLastUpdated =
|
|
@@ -94,7 +66,7 @@ const useLastUpdated = (): ComputedRef<null | string> => {
|
|
|
94
66
|
|
|
95
67
|
const updatedDate = new Date(page.value.git?.updatedTime)
|
|
96
68
|
|
|
97
|
-
return updatedDate.toLocaleString(
|
|
69
|
+
return updatedDate.toLocaleString()
|
|
98
70
|
})
|
|
99
71
|
}
|
|
100
72
|
|
|
@@ -103,7 +75,7 @@ const useContributors = (): ComputedRef<
|
|
|
103
75
|
> => {
|
|
104
76
|
const themeLocale = useThemeLocaleData()
|
|
105
77
|
const page = usePageData<DefaultThemePageData>()
|
|
106
|
-
const frontmatter = usePageFrontmatter()
|
|
78
|
+
const frontmatter = usePageFrontmatter<DefaultThemeNormalPageFrontmatter>()
|
|
107
79
|
|
|
108
80
|
return computed(() => {
|
|
109
81
|
const showContributors =
|
|
@@ -115,25 +87,38 @@ const useContributors = (): ComputedRef<
|
|
|
115
87
|
})
|
|
116
88
|
}
|
|
117
89
|
|
|
118
|
-
|
|
119
|
-
|
|
90
|
+
const themeLocale = useThemeLocaleData()
|
|
91
|
+
const editNavLink = useEditNavLink()
|
|
92
|
+
const lastUpdated = useLastUpdated()
|
|
93
|
+
const contributors = useContributors()
|
|
94
|
+
</script>
|
|
120
95
|
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
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>
|
|
124
101
|
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
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>
|
|
130
108
|
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
}
|
|
139
|
-
|
|
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,34 +1,22 @@
|
|
|
1
|
-
<
|
|
2
|
-
|
|
3
|
-
<p class="inner">
|
|
4
|
-
<span v-if="prevNavLink" class="prev">
|
|
5
|
-
←
|
|
6
|
-
<NavLink :item="prevNavLink" />
|
|
7
|
-
</span>
|
|
8
|
-
|
|
9
|
-
<span v-if="nextNavLink" class="next">
|
|
10
|
-
<NavLink :item="nextNavLink" />
|
|
11
|
-
→
|
|
12
|
-
</span>
|
|
13
|
-
</p>
|
|
14
|
-
</nav>
|
|
15
|
-
</template>
|
|
16
|
-
|
|
17
|
-
<script lang="ts">
|
|
18
|
-
import { computed, defineComponent } from 'vue'
|
|
19
|
-
import { useRoute } from 'vue-router'
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
import AutoLink from '@theme/AutoLink.vue'
|
|
20
3
|
import { usePageFrontmatter } from '@vuepress/client'
|
|
21
4
|
import { isPlainObject, isString } from '@vuepress/shared'
|
|
22
|
-
import
|
|
23
|
-
import {
|
|
24
|
-
import
|
|
5
|
+
import { computed } from 'vue'
|
|
6
|
+
import { useRoute } from 'vue-router'
|
|
7
|
+
import type {
|
|
8
|
+
DefaultThemeNormalPageFrontmatter,
|
|
9
|
+
NavLink,
|
|
10
|
+
ResolvedSidebarItem,
|
|
11
|
+
} from '../../shared/index.js'
|
|
12
|
+
import { useNavLink, useSidebarItems } from '../composables/index.js'
|
|
25
13
|
|
|
26
14
|
/**
|
|
27
15
|
* Resolve `prev` or `next` config from frontmatter
|
|
28
16
|
*/
|
|
29
17
|
const resolveFromFrontmatterConfig = (
|
|
30
|
-
conf: unknown
|
|
31
|
-
): null | false |
|
|
18
|
+
conf: unknown,
|
|
19
|
+
): null | false | NavLink => {
|
|
32
20
|
if (conf === false) {
|
|
33
21
|
return null
|
|
34
22
|
}
|
|
@@ -37,7 +25,7 @@ const resolveFromFrontmatterConfig = (
|
|
|
37
25
|
return useNavLink(conf)
|
|
38
26
|
}
|
|
39
27
|
|
|
40
|
-
if (isPlainObject<
|
|
28
|
+
if (isPlainObject<NavLink>(conf)) {
|
|
41
29
|
return conf
|
|
42
30
|
}
|
|
43
31
|
|
|
@@ -50,15 +38,15 @@ const resolveFromFrontmatterConfig = (
|
|
|
50
38
|
const resolveFromSidebarItems = (
|
|
51
39
|
sidebarItems: ResolvedSidebarItem[],
|
|
52
40
|
currentPath: string,
|
|
53
|
-
offset: number
|
|
54
|
-
): null |
|
|
41
|
+
offset: number,
|
|
42
|
+
): null | NavLink => {
|
|
55
43
|
const index = sidebarItems.findIndex((item) => item.link === currentPath)
|
|
56
44
|
if (index !== -1) {
|
|
57
45
|
const targetItem = sidebarItems[index + offset]
|
|
58
46
|
if (!targetItem?.link) {
|
|
59
47
|
return null
|
|
60
48
|
}
|
|
61
|
-
return targetItem as
|
|
49
|
+
return targetItem as NavLink
|
|
62
50
|
}
|
|
63
51
|
|
|
64
52
|
for (const item of sidebarItems) {
|
|
@@ -66,7 +54,7 @@ const resolveFromSidebarItems = (
|
|
|
66
54
|
const childResult = resolveFromSidebarItems(
|
|
67
55
|
item.children,
|
|
68
56
|
currentPath,
|
|
69
|
-
offset
|
|
57
|
+
offset,
|
|
70
58
|
)
|
|
71
59
|
if (childResult) {
|
|
72
60
|
return childResult
|
|
@@ -77,40 +65,39 @@ const resolveFromSidebarItems = (
|
|
|
77
65
|
return null
|
|
78
66
|
}
|
|
79
67
|
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
components: {
|
|
84
|
-
NavLink,
|
|
85
|
-
},
|
|
86
|
-
|
|
87
|
-
setup() {
|
|
88
|
-
const frontmatter = usePageFrontmatter()
|
|
89
|
-
const sidebarItems = useSidebarItems()
|
|
90
|
-
const route = useRoute()
|
|
91
|
-
|
|
92
|
-
const prevNavLink = computed(() => {
|
|
93
|
-
const prevConfig = resolveFromFrontmatterConfig(frontmatter.value.prev)
|
|
94
|
-
if (prevConfig !== false) {
|
|
95
|
-
return prevConfig
|
|
96
|
-
}
|
|
68
|
+
const frontmatter = usePageFrontmatter<DefaultThemeNormalPageFrontmatter>()
|
|
69
|
+
const sidebarItems = useSidebarItems()
|
|
70
|
+
const route = useRoute()
|
|
97
71
|
|
|
98
|
-
|
|
99
|
-
|
|
72
|
+
const prevNavLink = computed(() => {
|
|
73
|
+
const prevConfig = resolveFromFrontmatterConfig(frontmatter.value.prev)
|
|
74
|
+
if (prevConfig !== false) {
|
|
75
|
+
return prevConfig
|
|
76
|
+
}
|
|
100
77
|
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
if (nextConfig !== false) {
|
|
104
|
-
return nextConfig
|
|
105
|
-
}
|
|
78
|
+
return resolveFromSidebarItems(sidebarItems.value, route.path, -1)
|
|
79
|
+
})
|
|
106
80
|
|
|
107
|
-
|
|
108
|
-
|
|
81
|
+
const nextNavLink = computed(() => {
|
|
82
|
+
const nextConfig = resolveFromFrontmatterConfig(frontmatter.value.next)
|
|
83
|
+
if (nextConfig !== false) {
|
|
84
|
+
return nextConfig
|
|
85
|
+
}
|
|
109
86
|
|
|
110
|
-
|
|
111
|
-
prevNavLink,
|
|
112
|
-
nextNavLink,
|
|
113
|
-
}
|
|
114
|
-
},
|
|
87
|
+
return resolveFromSidebarItems(sidebarItems.value, route.path, 1)
|
|
115
88
|
})
|
|
116
89
|
</script>
|
|
90
|
+
|
|
91
|
+
<template>
|
|
92
|
+
<nav v-if="prevNavLink || nextNavLink" class="page-nav">
|
|
93
|
+
<p class="inner">
|
|
94
|
+
<span v-if="prevNavLink" class="prev">
|
|
95
|
+
<AutoLink :item="prevNavLink" />
|
|
96
|
+
</span>
|
|
97
|
+
|
|
98
|
+
<span v-if="nextNavLink" class="next">
|
|
99
|
+
<AutoLink :item="nextNavLink" />
|
|
100
|
+
</span>
|
|
101
|
+
</p>
|
|
102
|
+
</nav>
|
|
103
|
+
</template>
|