@vuepress/theme-default 2.0.0-rc.2 → 2.0.0-rc.20
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 +15 -17
- package/lib/client/components/NavbarBrand.vue +13 -3
- package/lib/client/components/NavbarDropdown.vue +1 -1
- package/lib/client/components/NavbarItems.vue +39 -35
- package/lib/client/components/PageNav.vue +13 -5
- package/lib/client/components/SidebarItem.vue +1 -1
- package/lib/client/components/SidebarItems.vue +1 -1
- package/lib/client/composables/useSidebarItems.d.ts +3 -4
- package/lib/client/composables/useSidebarItems.js +12 -11
- package/lib/client/config.js +7 -3
- package/lib/client/index.d.ts +1 -1
- package/lib/client/index.js +0 -1
- package/lib/client/layouts/Layout.vue +1 -2
- package/lib/client/layouts/NotFound.vue +2 -2
- package/lib/client/styles/layout.scss +4 -0
- package/lib/client/styles/navbar-dropdown.scss +2 -2
- package/lib/client/styles/navbar.scss +4 -4
- package/lib/client/styles/sidebar.scss +1 -1
- package/lib/client/styles/vars-dark.scss +7 -0
- package/lib/client/styles/vars.scss +46 -9
- package/lib/client/utils/getNavLink.d.ts +1 -7
- package/lib/client/utils/getNavLink.js +9 -10
- package/lib/client/utils/index.d.ts +0 -1
- package/lib/client/utils/index.js +0 -1
- package/lib/client/utils/isActiveSidebarItem.d.ts +1 -1
- package/lib/node/defaultTheme.d.ts +5 -1
- package/lib/node/defaultTheme.js +39 -2
- package/lib/node/index.d.ts +2 -1
- package/lib/node/index.js +1 -1
- package/lib/shared/nav.d.ts +2 -1
- package/lib/shared/options.d.ts +37 -1
- package/package.json +25 -20
- package/templates/build.html +13 -10
- package/lib/client/utils/getResolveRouteWithRedirect.d.ts +0 -5
- package/lib/client/utils/getResolveRouteWithRedirect.js +0 -22
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
<script setup lang="ts">
|
|
2
2
|
import { computed, toRefs } from 'vue'
|
|
3
3
|
import type { PropType } from 'vue'
|
|
4
|
-
import { useRoute } from '
|
|
5
|
-
import { useSiteData } from 'vuepress/client'
|
|
4
|
+
import { useRoute, useSiteData } from 'vuepress/client'
|
|
6
5
|
import { isLinkHttp, isLinkWithProtocol } from 'vuepress/shared'
|
|
7
6
|
import type { NavLink } from '../../shared/index.js'
|
|
8
7
|
|
|
@@ -41,8 +40,8 @@ const linkTarget = computed(() => {
|
|
|
41
40
|
})
|
|
42
41
|
// if the `target` attr is '_blank'
|
|
43
42
|
const isBlankTarget = computed(() => linkTarget.value === '_blank')
|
|
44
|
-
// is `<
|
|
45
|
-
const
|
|
43
|
+
// is `<RouteLink>` or not
|
|
44
|
+
const isRouteLink = computed(
|
|
46
45
|
() =>
|
|
47
46
|
!hasHttpProtocol.value && !hasNonHttpProtocol.value && !isBlankTarget.value,
|
|
48
47
|
)
|
|
@@ -64,30 +63,29 @@ const shouldBeActiveInSubpath = computed(() => {
|
|
|
64
63
|
}
|
|
65
64
|
return item.value.link !== '/'
|
|
66
65
|
})
|
|
67
|
-
// if this link is active in subpath
|
|
68
|
-
const isActiveInSubpath = computed(() => {
|
|
69
|
-
if (!shouldBeActiveInSubpath.value) {
|
|
70
|
-
return false
|
|
71
|
-
}
|
|
72
|
-
return route.path.startsWith(item.value.link)
|
|
73
|
-
})
|
|
74
66
|
|
|
75
67
|
// if this link is active
|
|
76
68
|
const isActive = computed(() => {
|
|
77
|
-
if (!
|
|
69
|
+
if (!isRouteLink.value) {
|
|
78
70
|
return false
|
|
79
71
|
}
|
|
80
72
|
if (item.value.activeMatch) {
|
|
81
73
|
return new RegExp(item.value.activeMatch).test(route.path)
|
|
82
74
|
}
|
|
83
|
-
|
|
75
|
+
|
|
76
|
+
if (!shouldBeActiveInSubpath.value) {
|
|
77
|
+
return false
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
// if this link is active in subpath
|
|
81
|
+
return route.path.startsWith(item.value.link)
|
|
84
82
|
})
|
|
85
83
|
</script>
|
|
86
84
|
|
|
87
85
|
<template>
|
|
88
|
-
<
|
|
89
|
-
v-if="
|
|
90
|
-
:
|
|
86
|
+
<RouteLink
|
|
87
|
+
v-if="isRouteLink"
|
|
88
|
+
:active="isActive"
|
|
91
89
|
:to="item.link"
|
|
92
90
|
:aria-label="linkAriaLabel"
|
|
93
91
|
v-bind="$attrs"
|
|
@@ -95,7 +93,7 @@ const isActive = computed(() => {
|
|
|
95
93
|
<slot name="before" />
|
|
96
94
|
{{ item.text }}
|
|
97
95
|
<slot name="after" />
|
|
98
|
-
</
|
|
96
|
+
</RouteLink>
|
|
99
97
|
<a
|
|
100
98
|
v-else
|
|
101
99
|
class="external-link"
|
|
@@ -3,6 +3,7 @@ import { computed, h } from 'vue'
|
|
|
3
3
|
import type { FunctionalComponent } from 'vue'
|
|
4
4
|
import {
|
|
5
5
|
ClientOnly,
|
|
6
|
+
RouteLink,
|
|
6
7
|
useRouteLocale,
|
|
7
8
|
useSiteLocaleData,
|
|
8
9
|
withBase,
|
|
@@ -24,12 +25,20 @@ const navbarBrandLogo = computed(() => {
|
|
|
24
25
|
}
|
|
25
26
|
return themeLocale.value.logo
|
|
26
27
|
})
|
|
28
|
+
const navbarBrandLogoAlt = computed(
|
|
29
|
+
() => themeLocale.value.logoAlt ?? navbarBrandTitle.value,
|
|
30
|
+
)
|
|
31
|
+
const navBarLogoAltMatchesTitle = computed(
|
|
32
|
+
() =>
|
|
33
|
+
navbarBrandTitle.value.toLocaleUpperCase().trim() ===
|
|
34
|
+
navbarBrandLogoAlt.value.toLocaleUpperCase().trim(),
|
|
35
|
+
)
|
|
27
36
|
const NavbarBrandLogo: FunctionalComponent = () => {
|
|
28
37
|
if (!navbarBrandLogo.value) return null
|
|
29
38
|
const img = h('img', {
|
|
30
39
|
class: 'logo',
|
|
31
40
|
src: withBase(navbarBrandLogo.value),
|
|
32
|
-
alt:
|
|
41
|
+
alt: navbarBrandLogoAlt.value,
|
|
33
42
|
})
|
|
34
43
|
if (themeLocale.value.logoDark === undefined) {
|
|
35
44
|
return img
|
|
@@ -41,15 +50,16 @@ const NavbarBrandLogo: FunctionalComponent = () => {
|
|
|
41
50
|
</script>
|
|
42
51
|
|
|
43
52
|
<template>
|
|
44
|
-
<
|
|
53
|
+
<RouteLink :to="navbarBrandLink">
|
|
45
54
|
<NavbarBrandLogo />
|
|
46
55
|
|
|
47
56
|
<span
|
|
48
57
|
v-if="navbarBrandTitle"
|
|
49
58
|
class="site-name"
|
|
50
59
|
:class="{ 'can-hide': navbarBrandLogo }"
|
|
60
|
+
:aria-hidden="navBarLogoAltMatchesTitle"
|
|
51
61
|
>
|
|
52
62
|
{{ navbarBrandTitle }}
|
|
53
63
|
</span>
|
|
54
|
-
</
|
|
64
|
+
</RouteLink>
|
|
55
65
|
</template>
|
|
@@ -3,7 +3,7 @@ import AutoLink from '@theme/AutoLink.vue'
|
|
|
3
3
|
import DropdownTransition from '@theme/DropdownTransition.vue'
|
|
4
4
|
import { computed, ref, toRefs, watch } from 'vue'
|
|
5
5
|
import type { PropType } from 'vue'
|
|
6
|
-
import { useRoute } from '
|
|
6
|
+
import { useRoute } from 'vuepress/client'
|
|
7
7
|
import type { NavbarItem, ResolvedNavbarItem } from '../../shared/index.js'
|
|
8
8
|
|
|
9
9
|
const props = defineProps({
|
|
@@ -1,11 +1,15 @@
|
|
|
1
1
|
<script setup lang="ts">
|
|
2
2
|
import AutoLink from '@theme/AutoLink.vue'
|
|
3
3
|
import NavbarDropdown from '@theme/NavbarDropdown.vue'
|
|
4
|
+
import { useRoutePaths } from '@vuepress/helper/client'
|
|
4
5
|
import { computed, ref } from 'vue'
|
|
5
6
|
import type { ComputedRef } from 'vue'
|
|
6
|
-
import {
|
|
7
|
-
|
|
8
|
-
|
|
7
|
+
import {
|
|
8
|
+
useRoute,
|
|
9
|
+
useRouteLocale,
|
|
10
|
+
useSiteData,
|
|
11
|
+
useSiteLocaleData,
|
|
12
|
+
} from 'vuepress/client'
|
|
9
13
|
import { isLinkHttp, isString } from 'vuepress/shared'
|
|
10
14
|
import type {
|
|
11
15
|
NavbarGroup,
|
|
@@ -24,7 +28,8 @@ import { getNavLink, resolveRepoType } from '../utils/index.js'
|
|
|
24
28
|
* Get navbar config of select language dropdown
|
|
25
29
|
*/
|
|
26
30
|
const useNavbarSelectLanguage = (): ComputedRef<ResolvedNavbarItem[]> => {
|
|
27
|
-
const
|
|
31
|
+
const route = useRoute()
|
|
32
|
+
const routePaths = useRoutePaths()
|
|
28
33
|
const routeLocale = useRouteLocale()
|
|
29
34
|
const site = useSiteData()
|
|
30
35
|
const siteLocale = useSiteLocaleData()
|
|
@@ -37,8 +42,8 @@ const useNavbarSelectLanguage = (): ComputedRef<ResolvedNavbarItem[]> => {
|
|
|
37
42
|
if (localePaths.length < 2) {
|
|
38
43
|
return []
|
|
39
44
|
}
|
|
40
|
-
const currentPath =
|
|
41
|
-
const currentFullPath =
|
|
45
|
+
const currentPath = route.path
|
|
46
|
+
const currentFullPath = route.fullPath
|
|
42
47
|
|
|
43
48
|
const languageDropdown: ResolvedNavbarItem = {
|
|
44
49
|
text: `${themeLocale.value.selectLanguageText}`,
|
|
@@ -53,33 +58,31 @@ const useNavbarSelectLanguage = (): ComputedRef<ResolvedNavbarItem[]> => {
|
|
|
53
58
|
const targetLang = `${targetSiteLocale.lang}`
|
|
54
59
|
|
|
55
60
|
const text = targetThemeLocale.selectLanguageName ?? targetLang
|
|
56
|
-
let link
|
|
57
61
|
|
|
62
|
+
// if the target language is current language
|
|
63
|
+
// stay at current link
|
|
58
64
|
if (targetLang === siteLocale.value.lang) {
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
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
|
|
65
|
+
return {
|
|
66
|
+
text,
|
|
67
|
+
activeMatch: /./,
|
|
68
|
+
link: route.hash ?? '#',
|
|
77
69
|
}
|
|
78
70
|
}
|
|
79
71
|
|
|
72
|
+
// if the target language is not current language
|
|
73
|
+
// try to link to the corresponding page of current page
|
|
74
|
+
// or fallback to homepage
|
|
75
|
+
const targetLocalePage = currentPath.replace(
|
|
76
|
+
routeLocale.value,
|
|
77
|
+
targetLocalePath,
|
|
78
|
+
)
|
|
79
|
+
|
|
80
80
|
return {
|
|
81
81
|
text,
|
|
82
|
-
|
|
82
|
+
// try to keep current hash and params across languages
|
|
83
|
+
link: routePaths.value.some((item) => item === targetLocalePage)
|
|
84
|
+
? currentFullPath.replace(currentPath, targetLocalePage)
|
|
85
|
+
: targetThemeLocale.home ?? targetLocalePath,
|
|
83
86
|
}
|
|
84
87
|
}),
|
|
85
88
|
}
|
|
@@ -129,17 +132,16 @@ const useNavbarRepo = (): ComputedRef<ResolvedNavbarItem[]> => {
|
|
|
129
132
|
}
|
|
130
133
|
|
|
131
134
|
const resolveNavbarItem = (
|
|
132
|
-
router: Router,
|
|
133
135
|
item: NavbarItem | NavbarGroup | string,
|
|
134
136
|
): ResolvedNavbarItem => {
|
|
135
137
|
if (isString(item)) {
|
|
136
|
-
return getNavLink(
|
|
138
|
+
return getNavLink(item)
|
|
137
139
|
}
|
|
138
140
|
if ((item as NavbarGroup).children) {
|
|
139
141
|
return {
|
|
140
142
|
...item,
|
|
141
143
|
children: (item as NavbarGroup).children.map((item) =>
|
|
142
|
-
resolveNavbarItem(
|
|
144
|
+
resolveNavbarItem(item),
|
|
143
145
|
),
|
|
144
146
|
}
|
|
145
147
|
}
|
|
@@ -147,13 +149,10 @@ const resolveNavbarItem = (
|
|
|
147
149
|
}
|
|
148
150
|
|
|
149
151
|
const useNavbarConfig = (): ComputedRef<ResolvedNavbarItem[]> => {
|
|
150
|
-
const router = useRouter()
|
|
151
152
|
const themeLocale = useThemeLocaleData()
|
|
152
153
|
|
|
153
154
|
return computed(() =>
|
|
154
|
-
(themeLocale.value.navbar || []).map((item) =>
|
|
155
|
-
resolveNavbarItem(router, item),
|
|
156
|
-
),
|
|
155
|
+
(themeLocale.value.navbar || []).map((item) => resolveNavbarItem(item)),
|
|
157
156
|
)
|
|
158
157
|
}
|
|
159
158
|
|
|
@@ -178,13 +177,18 @@ useUpdateDeviceStatus(
|
|
|
178
177
|
}
|
|
179
178
|
},
|
|
180
179
|
)
|
|
180
|
+
|
|
181
|
+
const navbarLabel = computed(() => {
|
|
182
|
+
const themeLocale = useThemeLocaleData()
|
|
183
|
+
return themeLocale.value.navbarLabel ?? 'site navigation'
|
|
184
|
+
})
|
|
181
185
|
</script>
|
|
182
186
|
|
|
183
187
|
<template>
|
|
184
|
-
<nav v-if="navbarLinks.length" class="navbar-items">
|
|
188
|
+
<nav v-if="navbarLinks.length" class="navbar-items" :aria-label="navbarLabel">
|
|
185
189
|
<div v-for="item in navbarLinks" :key="item.text" class="navbar-item">
|
|
186
190
|
<NavbarDropdown
|
|
187
|
-
v-if="item
|
|
191
|
+
v-if="'children' in item"
|
|
188
192
|
:item="item"
|
|
189
193
|
:class="isMobile ? 'mobile' : ''"
|
|
190
194
|
/>
|
|
@@ -1,16 +1,15 @@
|
|
|
1
1
|
<script setup lang="ts">
|
|
2
2
|
import AutoLink from '@theme/AutoLink.vue'
|
|
3
3
|
import { computed } from 'vue'
|
|
4
|
-
import type { Router } from '
|
|
5
|
-
import { useRoute, useRouter } from '
|
|
6
|
-
import { usePageFrontmatter } from 'vuepress/client'
|
|
4
|
+
import type { Router } from 'vuepress/client'
|
|
5
|
+
import { usePageFrontmatter, useRoute, useRouter } from 'vuepress/client'
|
|
7
6
|
import { isPlainObject, isString } from 'vuepress/shared'
|
|
8
7
|
import type {
|
|
9
8
|
DefaultThemeNormalPageFrontmatter,
|
|
10
9
|
NavLink,
|
|
11
10
|
ResolvedSidebarItem,
|
|
12
11
|
} from '../../shared/index.js'
|
|
13
|
-
import { useSidebarItems } from '../composables/index.js'
|
|
12
|
+
import { useSidebarItems, useThemeLocaleData } from '../composables/index.js'
|
|
14
13
|
import { getNavLink } from '../utils/index.js'
|
|
15
14
|
|
|
16
15
|
/**
|
|
@@ -96,10 +95,19 @@ const nextNavLink = computed(() => {
|
|
|
96
95
|
|
|
97
96
|
return resolveFromSidebarItems(sidebarItems.value, route.path, 1)
|
|
98
97
|
})
|
|
98
|
+
|
|
99
|
+
const navbarLabel = computed(() => {
|
|
100
|
+
const themeLocale = useThemeLocaleData()
|
|
101
|
+
return themeLocale.value.pageNavbarLabel ?? 'page navigation'
|
|
102
|
+
})
|
|
99
103
|
</script>
|
|
100
104
|
|
|
101
105
|
<template>
|
|
102
|
-
<nav
|
|
106
|
+
<nav
|
|
107
|
+
v-if="prevNavLink || nextNavLink"
|
|
108
|
+
class="page-nav"
|
|
109
|
+
:aria-label="navbarLabel"
|
|
110
|
+
>
|
|
103
111
|
<p class="inner">
|
|
104
112
|
<span v-if="prevNavLink" class="prev">
|
|
105
113
|
<AutoLink :item="prevNavLink" />
|
|
@@ -4,7 +4,7 @@ import DropdownTransition from '@theme/DropdownTransition.vue'
|
|
|
4
4
|
import { useToggle } from '@vueuse/core'
|
|
5
5
|
import { computed, nextTick, onBeforeUnmount, toRefs } from 'vue'
|
|
6
6
|
import type { PropType } from 'vue'
|
|
7
|
-
import { useRoute, useRouter } from '
|
|
7
|
+
import { useRoute, useRouter } from 'vuepress/client'
|
|
8
8
|
import type { ResolvedSidebarItem } from '../../shared/index.js'
|
|
9
9
|
import { isActiveSidebarItem } from '../utils/index.js'
|
|
10
10
|
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
<script setup lang="ts">
|
|
2
2
|
import SidebarItem from '@theme/SidebarItem.vue'
|
|
3
3
|
import { onMounted, watch } from 'vue'
|
|
4
|
-
import { useRoute } from '
|
|
4
|
+
import { useRoute } from 'vuepress/client'
|
|
5
5
|
import { useSidebarItems } from '../composables/index.js'
|
|
6
6
|
|
|
7
7
|
const route = useRoute()
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import type { ComputedRef, InjectionKey } from 'vue';
|
|
2
|
-
import type { Router } from 'vue-router';
|
|
3
2
|
import type { PageData, PageHeader } from 'vuepress/client';
|
|
4
3
|
import type { DefaultThemeData, DefaultThemeNormalPageFrontmatter, ResolvedSidebarItem, SidebarConfigArray, SidebarConfigObject } from '../../shared/index.js';
|
|
5
4
|
export type SidebarItemsRef = ComputedRef<ResolvedSidebarItem[]>;
|
|
@@ -17,7 +16,7 @@ export declare const setupSidebarItems: () => void;
|
|
|
17
16
|
*
|
|
18
17
|
* It should only be resolved and provided once
|
|
19
18
|
*/
|
|
20
|
-
export declare const resolveSidebarItems: (frontmatter: DefaultThemeNormalPageFrontmatter, themeLocale: DefaultThemeData, page: PageData,
|
|
19
|
+
export declare const resolveSidebarItems: (frontmatter: DefaultThemeNormalPageFrontmatter, themeLocale: DefaultThemeData, page: PageData, path: string) => ResolvedSidebarItem[];
|
|
21
20
|
/**
|
|
22
21
|
* Util to transform page header to sidebar item
|
|
23
22
|
*/
|
|
@@ -30,8 +29,8 @@ export declare const resolveAutoSidebarItems: (page: PageData, sidebarDepth: num
|
|
|
30
29
|
/**
|
|
31
30
|
* Resolve sidebar items if the config is an array
|
|
32
31
|
*/
|
|
33
|
-
export declare const resolveArraySidebarItems: (page: PageData,
|
|
32
|
+
export declare const resolveArraySidebarItems: (page: PageData, path: string, sidebarConfig: SidebarConfigArray, sidebarDepth: number) => ResolvedSidebarItem[];
|
|
34
33
|
/**
|
|
35
34
|
* Resolve sidebar items if the config is a key -> value (path-prefix -> array) object
|
|
36
35
|
*/
|
|
37
|
-
export declare const resolveMultiSidebarItems: (page: PageData,
|
|
36
|
+
export declare const resolveMultiSidebarItems: (page: PageData, path: string, sidebarConfig: SidebarConfigObject, sidebarDepth: number) => ResolvedSidebarItem[];
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { computed, inject, provide } from 'vue';
|
|
2
|
-
import {
|
|
3
|
-
import { usePageData, usePageFrontmatter } from 'vuepress/client';
|
|
2
|
+
import { usePageData, usePageFrontmatter, useRoute } from 'vuepress/client';
|
|
4
3
|
import { isPlainObject, isString, resolveLocalePath } from 'vuepress/shared';
|
|
5
4
|
import { getNavLink } from '../utils/index.js';
|
|
6
5
|
import { useThemeLocaleData } from './useThemeData.js';
|
|
@@ -23,8 +22,7 @@ export const setupSidebarItems = () => {
|
|
|
23
22
|
const frontmatter = usePageFrontmatter();
|
|
24
23
|
const page = usePageData();
|
|
25
24
|
const route = useRoute();
|
|
26
|
-
const
|
|
27
|
-
const sidebarItems = computed(() => resolveSidebarItems(frontmatter.value, themeLocale.value, page.value, router, route.path));
|
|
25
|
+
const sidebarItems = computed(() => resolveSidebarItems(frontmatter.value, themeLocale.value, page.value, route.path));
|
|
28
26
|
provide(sidebarItemsSymbol, sidebarItems);
|
|
29
27
|
};
|
|
30
28
|
/**
|
|
@@ -32,7 +30,7 @@ export const setupSidebarItems = () => {
|
|
|
32
30
|
*
|
|
33
31
|
* It should only be resolved and provided once
|
|
34
32
|
*/
|
|
35
|
-
export const resolveSidebarItems = (frontmatter, themeLocale, page,
|
|
33
|
+
export const resolveSidebarItems = (frontmatter, themeLocale, page, path) => {
|
|
36
34
|
// get sidebar config from frontmatter > theme data
|
|
37
35
|
const sidebarConfig = frontmatter.sidebar ?? themeLocale.sidebar ?? 'auto';
|
|
38
36
|
const sidebarDepth = frontmatter.sidebarDepth ?? themeLocale.sidebarDepth ?? 2;
|
|
@@ -44,10 +42,10 @@ export const resolveSidebarItems = (frontmatter, themeLocale, page, router, path
|
|
|
44
42
|
return resolveAutoSidebarItems(page, sidebarDepth);
|
|
45
43
|
}
|
|
46
44
|
if (Array.isArray(sidebarConfig)) {
|
|
47
|
-
return resolveArraySidebarItems(page,
|
|
45
|
+
return resolveArraySidebarItems(page, path, sidebarConfig, sidebarDepth);
|
|
48
46
|
}
|
|
49
47
|
if (isPlainObject(sidebarConfig)) {
|
|
50
|
-
return resolveMultiSidebarItems(page,
|
|
48
|
+
return resolveMultiSidebarItems(page, path, sidebarConfig, sidebarDepth);
|
|
51
49
|
}
|
|
52
50
|
return [];
|
|
53
51
|
};
|
|
@@ -76,11 +74,11 @@ export const resolveAutoSidebarItems = (page, sidebarDepth) => {
|
|
|
76
74
|
/**
|
|
77
75
|
* Resolve sidebar items if the config is an array
|
|
78
76
|
*/
|
|
79
|
-
export const resolveArraySidebarItems = (page,
|
|
77
|
+
export const resolveArraySidebarItems = (page, path, sidebarConfig, sidebarDepth) => {
|
|
80
78
|
const handleChildItem = (item) => {
|
|
81
79
|
let childItem;
|
|
82
80
|
if (isString(item)) {
|
|
83
|
-
childItem = getNavLink(
|
|
81
|
+
childItem = getNavLink(item);
|
|
84
82
|
}
|
|
85
83
|
else {
|
|
86
84
|
childItem = item;
|
|
@@ -108,8 +106,11 @@ export const resolveArraySidebarItems = (page, router, path, sidebarConfig, side
|
|
|
108
106
|
/**
|
|
109
107
|
* Resolve sidebar items if the config is a key -> value (path-prefix -> array) object
|
|
110
108
|
*/
|
|
111
|
-
export const resolveMultiSidebarItems = (page,
|
|
109
|
+
export const resolveMultiSidebarItems = (page, path, sidebarConfig, sidebarDepth) => {
|
|
112
110
|
const sidebarPath = resolveLocalePath(sidebarConfig, path);
|
|
113
111
|
const matchedSidebarConfig = sidebarConfig[sidebarPath] ?? [];
|
|
114
|
-
|
|
112
|
+
if (matchedSidebarConfig === 'heading') {
|
|
113
|
+
return resolveAutoSidebarItems(page, sidebarDepth);
|
|
114
|
+
}
|
|
115
|
+
return resolveArraySidebarItems(page, path, matchedSidebarConfig, sidebarDepth);
|
|
115
116
|
};
|
package/lib/client/config.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { hasGlobalComponent } from '@vuepress/helper/client';
|
|
1
2
|
import { h } from 'vue';
|
|
2
3
|
import { defineClientConfig } from 'vuepress/client';
|
|
3
4
|
import { Badge, CodeGroup, CodeGroupItem } from './components/global/index.js';
|
|
@@ -7,9 +8,12 @@ import NotFound from './layouts/NotFound.vue';
|
|
|
7
8
|
import './styles/index.scss';
|
|
8
9
|
export default defineClientConfig({
|
|
9
10
|
enhance({ app, router }) {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
11
|
+
if (!hasGlobalComponent('Badge'))
|
|
12
|
+
app.component('Badge', Badge);
|
|
13
|
+
if (!hasGlobalComponent('CodeGroup'))
|
|
14
|
+
app.component('CodeGroup', CodeGroup);
|
|
15
|
+
if (!hasGlobalComponent('CodeGroupItem'))
|
|
16
|
+
app.component('CodeGroupItem', CodeGroupItem);
|
|
13
17
|
// compat with @vuepress/plugin-external-link-icon
|
|
14
18
|
app.component('AutoLinkExternalIcon', () => {
|
|
15
19
|
const ExternalLinkIcon = app.component('ExternalLinkIcon');
|
package/lib/client/index.d.ts
CHANGED
package/lib/client/index.js
CHANGED
|
@@ -4,8 +4,7 @@ import Navbar from '@theme/Navbar.vue'
|
|
|
4
4
|
import Page from '@theme/Page.vue'
|
|
5
5
|
import Sidebar from '@theme/Sidebar.vue'
|
|
6
6
|
import { computed, onMounted, onUnmounted, ref } from 'vue'
|
|
7
|
-
import { useRouter } from '
|
|
8
|
-
import { usePageData, usePageFrontmatter } from 'vuepress/client'
|
|
7
|
+
import { usePageData, usePageFrontmatter, useRouter } from 'vuepress/client'
|
|
9
8
|
import type { DefaultThemePageFrontmatter } from '../../shared/index.js'
|
|
10
9
|
import {
|
|
11
10
|
useScrollPromise,
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
<script setup lang="ts">
|
|
2
|
-
import { useRouteLocale } from 'vuepress/client'
|
|
2
|
+
import { RouteLink, useRouteLocale } from 'vuepress/client'
|
|
3
3
|
import { useThemeLocaleData } from '../composables/index.js'
|
|
4
4
|
|
|
5
5
|
const routeLocale = useRouteLocale()
|
|
@@ -20,7 +20,7 @@ const homeText = themeLocale.value.backToHome ?? 'Back to home'
|
|
|
20
20
|
|
|
21
21
|
<blockquote>{{ getMsg() }}</blockquote>
|
|
22
22
|
|
|
23
|
-
<
|
|
23
|
+
<RouteLink :to="homeLink">{{ homeText }}</RouteLink>
|
|
24
24
|
</div>
|
|
25
25
|
</main>
|
|
26
26
|
</div>
|
|
@@ -54,7 +54,7 @@
|
|
|
54
54
|
|
|
55
55
|
& > a {
|
|
56
56
|
font-weight: inherit;
|
|
57
|
-
&.
|
|
57
|
+
&.route-link-active {
|
|
58
58
|
&::after {
|
|
59
59
|
display: none;
|
|
60
60
|
}
|
|
@@ -84,7 +84,7 @@
|
|
|
84
84
|
color: var(--c-text-accent);
|
|
85
85
|
}
|
|
86
86
|
|
|
87
|
-
&.
|
|
87
|
+
&.route-link-active {
|
|
88
88
|
color: var(--c-text-accent);
|
|
89
89
|
|
|
90
90
|
&::after {
|
|
@@ -76,7 +76,7 @@
|
|
|
76
76
|
color: inherit;
|
|
77
77
|
|
|
78
78
|
&:hover,
|
|
79
|
-
&.
|
|
79
|
+
&.route-link-active {
|
|
80
80
|
color: var(--c-text);
|
|
81
81
|
}
|
|
82
82
|
}
|
|
@@ -93,7 +93,7 @@
|
|
|
93
93
|
|
|
94
94
|
> a {
|
|
95
95
|
&:hover,
|
|
96
|
-
&.
|
|
96
|
+
&.route-link-active {
|
|
97
97
|
margin-bottom: -2px;
|
|
98
98
|
border-bottom: 2px solid var(--c-text-accent);
|
|
99
99
|
}
|
|
@@ -108,7 +108,7 @@
|
|
|
108
108
|
|
|
109
109
|
> a {
|
|
110
110
|
&:hover,
|
|
111
|
-
&.
|
|
111
|
+
&.route-link-active {
|
|
112
112
|
margin-bottom: 0;
|
|
113
113
|
border-bottom: none;
|
|
114
114
|
}
|
|
@@ -117,7 +117,7 @@
|
|
|
117
117
|
|
|
118
118
|
a {
|
|
119
119
|
&:hover,
|
|
120
|
-
&.
|
|
120
|
+
&.route-link-active {
|
|
121
121
|
color: var(--c-text-accent);
|
|
122
122
|
}
|
|
123
123
|
}
|
|
@@ -66,3 +66,10 @@ html.dark .DocSearch {
|
|
|
66
66
|
--docsearch-footer-shadow: inset 0 1px 0 0 rgba(73, 76, 106, 0.5),
|
|
67
67
|
0 -4px 8px 0 rgba(0, 0, 0, 0.2);
|
|
68
68
|
}
|
|
69
|
+
|
|
70
|
+
// plugin-pwa
|
|
71
|
+
html.dark body {
|
|
72
|
+
--pwa-shadow-color: rgb(0 0 0 / 30%);
|
|
73
|
+
--pwa-content-color: #ccc;
|
|
74
|
+
--pwa-content-light-color: #999;
|
|
75
|
+
}
|
|
@@ -94,9 +94,30 @@
|
|
|
94
94
|
}
|
|
95
95
|
|
|
96
96
|
// plugin-back-to-top
|
|
97
|
-
.back-to-top {
|
|
97
|
+
.vp-back-to-top-button {
|
|
98
98
|
--back-to-top-color: var(--c-brand);
|
|
99
99
|
--back-to-top-color-hover: var(--c-brand-light);
|
|
100
|
+
--back-to-top-bg-color: var(--c-bg);
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
// plugin-catalog
|
|
104
|
+
.vp-catalog-wrapper {
|
|
105
|
+
--catalog-bg-color: var(--c-bg);
|
|
106
|
+
--catalog-bg-secondary-color: var(--c-bg-dark);
|
|
107
|
+
--catalog-border-color: var(--c-border);
|
|
108
|
+
--catalog-active-color: var(--c-brand);
|
|
109
|
+
--catalog-hover-color: var(--c-brand-light);
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
// plugin-comment
|
|
113
|
+
.waline-wrapper {
|
|
114
|
+
--waline-bg-color: var(--c-bg);
|
|
115
|
+
--waline-bg-color-light: var(--c-bg-light);
|
|
116
|
+
--waline-text-color: var(--c-color);
|
|
117
|
+
--waline-border: 1px solid var(--c-border);
|
|
118
|
+
--waline-border-color: var(--c-border);
|
|
119
|
+
--waline-theme-color: var(--c-brand);
|
|
120
|
+
--waline-active-color: var(--c-brand-light);
|
|
100
121
|
}
|
|
101
122
|
|
|
102
123
|
// plugin-docsearch
|
|
@@ -132,15 +153,31 @@
|
|
|
132
153
|
--nprogress-color: var(--c-brand);
|
|
133
154
|
}
|
|
134
155
|
|
|
156
|
+
// plugin-photo-swipe
|
|
157
|
+
body {
|
|
158
|
+
--photo-swipe-bullet: var(--c-bg);
|
|
159
|
+
--photo-swipe-bullet-active: var(--c-brand);
|
|
160
|
+
}
|
|
161
|
+
|
|
135
162
|
// plugin-pwa-popup
|
|
136
|
-
|
|
137
|
-
--pwa-
|
|
138
|
-
--pwa-
|
|
139
|
-
--pwa-
|
|
140
|
-
--pwa-
|
|
141
|
-
--pwa-
|
|
142
|
-
--pwa-
|
|
143
|
-
|
|
163
|
+
body {
|
|
164
|
+
--pwa-text-color: var(--c-text);
|
|
165
|
+
--pwa-bg-color: var(--c-bg);
|
|
166
|
+
--pwa-border-color: var(--c-brand);
|
|
167
|
+
--pwa-btn-text-color: var(--c-bg);
|
|
168
|
+
--pwa-btn-bg-color: var(--c-brand);
|
|
169
|
+
--pwa-btn-hover-bg-color: var(--c-brand-light);
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
// plugin-redirect
|
|
173
|
+
.language-modal-mask {
|
|
174
|
+
--redirect-bg-color: var(--c-bg);
|
|
175
|
+
--redirect-bg-color-light: var(--c-bg-light);
|
|
176
|
+
--redirect-bg-color-lighter: var(--c-bg-lighter);
|
|
177
|
+
--redirect-text-color: var(--c-text);
|
|
178
|
+
--redirect-primary-color: var(--c-brand);
|
|
179
|
+
--redirect-primary-hover-color: var(--c-brand-light);
|
|
180
|
+
--redirect-primary-text-color: var(--c-bg);
|
|
144
181
|
}
|
|
145
182
|
|
|
146
183
|
// plugin-search
|
|
@@ -1,10 +1,4 @@
|
|
|
1
|
-
import type { Router } from 'vue-router';
|
|
2
1
|
import type { NavLink } from '../../shared/index.js';
|
|
3
|
-
declare module 'vue-router' {
|
|
4
|
-
interface RouteMeta {
|
|
5
|
-
title?: string;
|
|
6
|
-
}
|
|
7
|
-
}
|
|
8
2
|
/**
|
|
9
3
|
* Resolve NavLink props from string
|
|
10
4
|
*
|
|
@@ -12,4 +6,4 @@ declare module 'vue-router' {
|
|
|
12
6
|
* - Input: '/README.md'
|
|
13
7
|
* - Output: { text: 'Home', link: '/' }
|
|
14
8
|
*/
|
|
15
|
-
export declare const getNavLink: (
|
|
9
|
+
export declare const getNavLink: (config: string) => NavLink;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { resolveRoute } from 'vuepress/client';
|
|
2
2
|
/**
|
|
3
3
|
* Resolve NavLink props from string
|
|
4
4
|
*
|
|
@@ -6,13 +6,12 @@ import { getResolveRouteWithRedirect } from './getResolveRouteWithRedirect.js';
|
|
|
6
6
|
* - Input: '/README.md'
|
|
7
7
|
* - Output: { text: 'Home', link: '/' }
|
|
8
8
|
*/
|
|
9
|
-
export const getNavLink = (
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
};
|
|
9
|
+
export const getNavLink = (config) => {
|
|
10
|
+
const { notFound, meta, path } = resolveRoute(config);
|
|
11
|
+
return notFound
|
|
12
|
+
? { text: path, link: path }
|
|
13
|
+
: {
|
|
14
|
+
text: meta.title || path,
|
|
15
|
+
link: path,
|
|
16
|
+
};
|
|
18
17
|
};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import type { RouteLocationNormalizedLoaded } from '
|
|
1
|
+
import type { RouteLocationNormalizedLoaded } from 'vuepress/client';
|
|
2
2
|
import type { ResolvedSidebarItem } from '../../shared/index.js';
|
|
3
3
|
export declare const isActiveSidebarItem: (item: ResolvedSidebarItem, route: RouteLocationNormalizedLoaded) => boolean;
|
|
@@ -1,10 +1,14 @@
|
|
|
1
1
|
import type { Theme } from 'vuepress/core';
|
|
2
2
|
import type { DefaultThemeLocaleOptions, DefaultThemePluginsOptions } from '../shared/index.js';
|
|
3
3
|
export interface DefaultThemeOptions extends DefaultThemeLocaleOptions {
|
|
4
|
+
/**
|
|
5
|
+
* deployed hostname
|
|
6
|
+
*/
|
|
7
|
+
hostname?: string;
|
|
4
8
|
/**
|
|
5
9
|
* To avoid confusion with the root `plugins` option,
|
|
6
10
|
* we use `themePlugins`
|
|
7
11
|
*/
|
|
8
12
|
themePlugins?: DefaultThemePluginsOptions;
|
|
9
13
|
}
|
|
10
|
-
export declare const defaultTheme: ({ themePlugins, ...localeOptions }?: DefaultThemeOptions) => Theme;
|
|
14
|
+
export declare const defaultTheme: ({ hostname, themePlugins, ...localeOptions }?: DefaultThemeOptions) => Theme;
|
package/lib/node/defaultTheme.js
CHANGED
|
@@ -1,17 +1,22 @@
|
|
|
1
1
|
import { activeHeaderLinksPlugin } from '@vuepress/plugin-active-header-links';
|
|
2
2
|
import { backToTopPlugin } from '@vuepress/plugin-back-to-top';
|
|
3
3
|
import { containerPlugin } from '@vuepress/plugin-container';
|
|
4
|
+
import { copyCodePlugin } from '@vuepress/plugin-copy-code';
|
|
4
5
|
import { externalLinkIconPlugin } from '@vuepress/plugin-external-link-icon';
|
|
5
6
|
import { gitPlugin } from '@vuepress/plugin-git';
|
|
7
|
+
import { linksCheckPlugin } from '@vuepress/plugin-links-check';
|
|
6
8
|
import { mediumZoomPlugin } from '@vuepress/plugin-medium-zoom';
|
|
7
9
|
import { nprogressPlugin } from '@vuepress/plugin-nprogress';
|
|
8
10
|
import { palettePlugin } from '@vuepress/plugin-palette';
|
|
9
11
|
import { prismjsPlugin } from '@vuepress/plugin-prismjs';
|
|
12
|
+
import { seoPlugin } from '@vuepress/plugin-seo';
|
|
13
|
+
import { sitemapPlugin } from '@vuepress/plugin-sitemap';
|
|
10
14
|
import { themeDataPlugin } from '@vuepress/plugin-theme-data';
|
|
15
|
+
import { isPlainObject } from 'vuepress/shared';
|
|
11
16
|
import { fs, getDirname, path } from 'vuepress/utils';
|
|
12
17
|
import { assignDefaultLocaleOptions, resolveContainerPluginOptions, } from './utils/index.js';
|
|
13
18
|
const __dirname = getDirname(import.meta.url);
|
|
14
|
-
export const defaultTheme = ({ themePlugins = {}, ...localeOptions } = {}) => {
|
|
19
|
+
export const defaultTheme = ({ hostname, themePlugins = {}, ...localeOptions } = {}) => {
|
|
15
20
|
assignDefaultLocaleOptions(localeOptions);
|
|
16
21
|
return {
|
|
17
22
|
name: '@vuepress/theme-default',
|
|
@@ -44,7 +49,17 @@ export const defaultTheme = ({ themePlugins = {}, ...localeOptions } = {}) => {
|
|
|
44
49
|
})
|
|
45
50
|
: [],
|
|
46
51
|
// @vuepress/plugin-back-to-top
|
|
47
|
-
themePlugins.backToTop !== false
|
|
52
|
+
themePlugins.backToTop !== false
|
|
53
|
+
? backToTopPlugin(isPlainObject(themePlugins.backToTop) ? themePlugins.backToTop : {})
|
|
54
|
+
: [],
|
|
55
|
+
// @vuepress/plugin-copy-code
|
|
56
|
+
themePlugins.copyCode !== false
|
|
57
|
+
? copyCodePlugin({
|
|
58
|
+
...(isPlainObject(themePlugins.copyCode)
|
|
59
|
+
? themePlugins.copyCode
|
|
60
|
+
: {}),
|
|
61
|
+
})
|
|
62
|
+
: [],
|
|
48
63
|
// @vuepress/plugin-container
|
|
49
64
|
themePlugins.container?.tip !== false
|
|
50
65
|
? containerPlugin(resolveContainerPluginOptions(localeOptions, 'tip'))
|
|
@@ -95,6 +110,12 @@ export const defaultTheme = ({ themePlugins = {}, ...localeOptions } = {}) => {
|
|
|
95
110
|
contributors: localeOptions.contributors !== false,
|
|
96
111
|
})
|
|
97
112
|
: [],
|
|
113
|
+
// @vuepress/plugin-links-check
|
|
114
|
+
themePlugins.linksCheck !== false
|
|
115
|
+
? linksCheckPlugin(isPlainObject(themePlugins.linksCheck)
|
|
116
|
+
? themePlugins.linksCheck
|
|
117
|
+
: {})
|
|
118
|
+
: [],
|
|
98
119
|
// @vuepress/plugin-medium-zoom
|
|
99
120
|
themePlugins.mediumZoom !== false
|
|
100
121
|
? mediumZoomPlugin({
|
|
@@ -110,6 +131,22 @@ export const defaultTheme = ({ themePlugins = {}, ...localeOptions } = {}) => {
|
|
|
110
131
|
palettePlugin({ preset: 'sass' }),
|
|
111
132
|
// @vuepress/plugin-prismjs
|
|
112
133
|
themePlugins.prismjs !== false ? prismjsPlugin() : [],
|
|
134
|
+
// @vuepress/plugin-seo
|
|
135
|
+
hostname && themePlugins.seo !== false
|
|
136
|
+
? seoPlugin({
|
|
137
|
+
hostname,
|
|
138
|
+
...(isPlainObject(themePlugins.seo) ? themePlugins.seo : {}),
|
|
139
|
+
})
|
|
140
|
+
: [],
|
|
141
|
+
// @vuepress/plugin-sitemap
|
|
142
|
+
hostname && themePlugins.sitemap !== false
|
|
143
|
+
? sitemapPlugin({
|
|
144
|
+
hostname,
|
|
145
|
+
...(isPlainObject(themePlugins.sitemap)
|
|
146
|
+
? themePlugins.sitemap
|
|
147
|
+
: {}),
|
|
148
|
+
})
|
|
149
|
+
: [],
|
|
113
150
|
// @vuepress/plugin-theme-data
|
|
114
151
|
themeDataPlugin({ themeData: localeOptions }),
|
|
115
152
|
],
|
package/lib/node/index.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { defaultTheme } from './defaultTheme.js';
|
|
2
|
-
export * from '../shared/index.js';
|
|
3
2
|
export * from './defaultTheme.js';
|
|
4
3
|
export * from './utils/index.js';
|
|
4
|
+
export type * from '../shared/index.js';
|
|
5
|
+
/** @deprecated Use named export instead */
|
|
5
6
|
export default defaultTheme;
|
package/lib/node/index.js
CHANGED
package/lib/shared/nav.d.ts
CHANGED
|
@@ -35,7 +35,8 @@ export type SidebarGroup = SidebarItem & NavGroup<SidebarItem | SidebarGroup | s
|
|
|
35
35
|
collapsible?: boolean;
|
|
36
36
|
};
|
|
37
37
|
export type SidebarConfigArray = (SidebarItem | SidebarGroup | string)[];
|
|
38
|
-
export type
|
|
38
|
+
export type SidebarConfigObjectItem = SidebarConfigArray | 'heading';
|
|
39
|
+
export type SidebarConfigObject = Record<string, SidebarConfigObjectItem>;
|
|
39
40
|
export type SidebarConfig = SidebarConfigArray | SidebarConfigObject;
|
|
40
41
|
export type ResolvedSidebarItem = SidebarItem & Partial<NavGroup<ResolvedSidebarItem>> & {
|
|
41
42
|
collapsible?: boolean;
|
package/lib/shared/options.d.ts
CHANGED
|
@@ -1,3 +1,8 @@
|
|
|
1
|
+
import type { BackToTopPluginOptions } from '@vuepress/plugin-back-to-top';
|
|
2
|
+
import type { CopyCodePluginOptions } from '@vuepress/plugin-copy-code';
|
|
3
|
+
import type { LinksCheckPluginOptions } from '@vuepress/plugin-links-check';
|
|
4
|
+
import type { SeoPluginOptions } from '@vuepress/plugin-seo';
|
|
5
|
+
import type { SitemapPluginOptions } from '@vuepress/plugin-sitemap';
|
|
1
6
|
import type { ThemeData } from '@vuepress/plugin-theme-data';
|
|
2
7
|
import type { LocaleData } from 'vuepress/shared';
|
|
3
8
|
import type { NavbarConfig, SidebarConfig } from './nav.js';
|
|
@@ -9,7 +14,7 @@ export interface DefaultThemePluginsOptions {
|
|
|
9
14
|
/**
|
|
10
15
|
* Enable @vuepress/plugin-back-to-top or not
|
|
11
16
|
*/
|
|
12
|
-
backToTop?: boolean;
|
|
17
|
+
backToTop?: BackToTopPluginOptions | boolean;
|
|
13
18
|
/**
|
|
14
19
|
* Enable @vuepress/plugin-container or not
|
|
15
20
|
*/
|
|
@@ -21,6 +26,10 @@ export interface DefaultThemePluginsOptions {
|
|
|
21
26
|
codeGroup?: boolean;
|
|
22
27
|
codeGroupItem?: boolean;
|
|
23
28
|
};
|
|
29
|
+
/**
|
|
30
|
+
* Enable @vuepress/plugin-copy-code or not
|
|
31
|
+
*/
|
|
32
|
+
copyCode?: CopyCodePluginOptions | boolean;
|
|
24
33
|
/**
|
|
25
34
|
* Enable @vuepress/plugin-external-link-icon or not
|
|
26
35
|
*/
|
|
@@ -29,6 +38,10 @@ export interface DefaultThemePluginsOptions {
|
|
|
29
38
|
* Enable @vuepress/plugin-git or not
|
|
30
39
|
*/
|
|
31
40
|
git?: boolean;
|
|
41
|
+
/**
|
|
42
|
+
* Enable @vuepress/plugin-links-check or not
|
|
43
|
+
*/
|
|
44
|
+
linksCheck?: LinksCheckPluginOptions | boolean;
|
|
32
45
|
/**
|
|
33
46
|
* Enable @vuepress/plugin-medium-zoom or not
|
|
34
47
|
*/
|
|
@@ -41,6 +54,14 @@ export interface DefaultThemePluginsOptions {
|
|
|
41
54
|
* Enable @vuepress/plugin-prismjs or not
|
|
42
55
|
*/
|
|
43
56
|
prismjs?: boolean;
|
|
57
|
+
/**
|
|
58
|
+
* Enable @vuepress/plugin-seo or not
|
|
59
|
+
*/
|
|
60
|
+
seo?: Partial<SeoPluginOptions> | boolean;
|
|
61
|
+
/**
|
|
62
|
+
* Enable @vuepress/plugin-sitemap or not
|
|
63
|
+
*/
|
|
64
|
+
sitemap?: Partial<SitemapPluginOptions> | boolean;
|
|
44
65
|
}
|
|
45
66
|
export type DefaultThemeLocaleOptions = DefaultThemeData;
|
|
46
67
|
export type DefaultThemeData = ThemeData<DefaultThemeLocaleData>;
|
|
@@ -69,6 +90,14 @@ export interface DefaultThemeLocaleData extends LocaleData {
|
|
|
69
90
|
* Set to `false` to disable navbar in current locale
|
|
70
91
|
*/
|
|
71
92
|
navbar?: false | NavbarConfig;
|
|
93
|
+
/**
|
|
94
|
+
* Navbar label used for screen readers using the `aria-label` attribute
|
|
95
|
+
*/
|
|
96
|
+
navbarLabel?: null | string;
|
|
97
|
+
/**
|
|
98
|
+
* Page navbar label used for screen readers using the `aria-label` attribute
|
|
99
|
+
*/
|
|
100
|
+
pageNavbarLabel?: null | string;
|
|
72
101
|
/**
|
|
73
102
|
* Navbar logo config
|
|
74
103
|
*
|
|
@@ -81,6 +110,13 @@ export interface DefaultThemeLocaleData extends LocaleData {
|
|
|
81
110
|
* Logo to display in navbar in dark mode
|
|
82
111
|
*/
|
|
83
112
|
logoDark?: null | string;
|
|
113
|
+
/**
|
|
114
|
+
* The alt text of navbar logo.
|
|
115
|
+
* Defaults to the site title if not specified.
|
|
116
|
+
* If the value is the same as the site title, the site title rendered in the navbar will be
|
|
117
|
+
* hidden from screen readers to avoid duplication.
|
|
118
|
+
*/
|
|
119
|
+
logoAlt?: null | string;
|
|
84
120
|
/**
|
|
85
121
|
* Navbar repository config
|
|
86
122
|
*
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vuepress/theme-default",
|
|
3
|
-
"version": "2.0.0-rc.
|
|
3
|
+
"version": "2.0.0-rc.20",
|
|
4
4
|
"description": "Default theme of VuePress",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"vuepress-theme",
|
|
@@ -8,13 +8,14 @@
|
|
|
8
8
|
"theme",
|
|
9
9
|
"default"
|
|
10
10
|
],
|
|
11
|
-
"homepage": "https://
|
|
11
|
+
"homepage": "https://ecosystem.vuejs.press/themes/default/",
|
|
12
12
|
"bugs": {
|
|
13
13
|
"url": "https://github.com/vuepress/ecosystem/issues"
|
|
14
14
|
},
|
|
15
15
|
"repository": {
|
|
16
16
|
"type": "git",
|
|
17
|
-
"url": "git+https://github.com/vuepress/ecosystem.git"
|
|
17
|
+
"url": "git+https://github.com/vuepress/ecosystem.git",
|
|
18
|
+
"directory": "themes/theme-default"
|
|
18
19
|
},
|
|
19
20
|
"license": "MIT",
|
|
20
21
|
"author": "meteorlxy",
|
|
@@ -37,28 +38,32 @@
|
|
|
37
38
|
],
|
|
38
39
|
"scripts": {
|
|
39
40
|
"build": "tsc -b tsconfig.build.json",
|
|
40
|
-
"clean": "rimraf lib
|
|
41
|
+
"clean": "rimraf --glob ./lib ./*.tsbuildinfo",
|
|
41
42
|
"copy": "cpx \"src/**/*.{d.ts,vue,scss}\" lib"
|
|
42
43
|
},
|
|
43
44
|
"dependencies": {
|
|
44
|
-
"@vuepress/
|
|
45
|
-
"@vuepress/plugin-
|
|
46
|
-
"@vuepress/plugin-
|
|
47
|
-
"@vuepress/plugin-
|
|
48
|
-
"@vuepress/plugin-
|
|
49
|
-
"@vuepress/plugin-
|
|
50
|
-
"@vuepress/plugin-
|
|
51
|
-
"@vuepress/plugin-
|
|
52
|
-
"@vuepress/plugin-
|
|
53
|
-
"@vuepress/plugin-
|
|
54
|
-
"@
|
|
55
|
-
"
|
|
56
|
-
"
|
|
57
|
-
"
|
|
45
|
+
"@vuepress/helper": "~2.0.0-rc.19",
|
|
46
|
+
"@vuepress/plugin-active-header-links": "~2.0.0-rc.18",
|
|
47
|
+
"@vuepress/plugin-back-to-top": "~2.0.0-rc.19",
|
|
48
|
+
"@vuepress/plugin-container": "~2.0.0-rc.15",
|
|
49
|
+
"@vuepress/plugin-copy-code": "~2.0.0-rc.19",
|
|
50
|
+
"@vuepress/plugin-external-link-icon": "~2.0.0-rc.18",
|
|
51
|
+
"@vuepress/plugin-git": "~2.0.0-rc.15",
|
|
52
|
+
"@vuepress/plugin-links-check": "~2.0.0-rc.19",
|
|
53
|
+
"@vuepress/plugin-medium-zoom": "~2.0.0-rc.19",
|
|
54
|
+
"@vuepress/plugin-nprogress": "~2.0.0-rc.18",
|
|
55
|
+
"@vuepress/plugin-palette": "~2.0.0-rc.15",
|
|
56
|
+
"@vuepress/plugin-prismjs": "~2.0.0-rc.15",
|
|
57
|
+
"@vuepress/plugin-seo": "~2.0.0-rc.19",
|
|
58
|
+
"@vuepress/plugin-sitemap": "~2.0.0-rc.19",
|
|
59
|
+
"@vuepress/plugin-theme-data": "~2.0.0-rc.18",
|
|
60
|
+
"@vueuse/core": "^10.9.0",
|
|
61
|
+
"sass": "^1.71.1",
|
|
62
|
+
"vue": "^3.4.21"
|
|
58
63
|
},
|
|
59
64
|
"peerDependencies": {
|
|
60
65
|
"sass-loader": "^14.0.0",
|
|
61
|
-
"vuepress": "2.0.0-rc.
|
|
66
|
+
"vuepress": "2.0.0-rc.8"
|
|
62
67
|
},
|
|
63
68
|
"peerDependenciesMeta": {
|
|
64
69
|
"sass-loader": {
|
|
@@ -68,5 +73,5 @@
|
|
|
68
73
|
"publishConfig": {
|
|
69
74
|
"access": "public"
|
|
70
75
|
},
|
|
71
|
-
"gitHead": "
|
|
76
|
+
"gitHead": "7042b2665c01b45c39a511efe059aed11b77c6f3"
|
|
72
77
|
}
|
package/templates/build.html
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
<!
|
|
1
|
+
<!doctype html>
|
|
2
2
|
<html lang="{{ lang }}">
|
|
3
3
|
<head>
|
|
4
|
-
<meta charset="utf-8"
|
|
5
|
-
<meta name="viewport" content="width=device-width,initial-scale=1"
|
|
6
|
-
<meta name="generator" content="VuePress {{ version }}"
|
|
4
|
+
<meta charset="utf-8" />
|
|
5
|
+
<meta name="viewport" content="width=device-width,initial-scale=1" />
|
|
6
|
+
<meta name="generator" content="VuePress {{ version }}" />
|
|
7
7
|
<style>
|
|
8
8
|
:root {
|
|
9
9
|
--c-bg: #fff;
|
|
@@ -11,16 +11,19 @@
|
|
|
11
11
|
html.dark {
|
|
12
12
|
--c-bg: #22272e;
|
|
13
13
|
}
|
|
14
|
-
html,
|
|
14
|
+
html,
|
|
15
|
+
body {
|
|
15
16
|
background-color: var(--c-bg);
|
|
16
17
|
}
|
|
17
18
|
</style>
|
|
18
19
|
<script>
|
|
19
|
-
const userMode = localStorage.getItem('vuepress-color-scheme')
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
20
|
+
const userMode = localStorage.getItem('vuepress-color-scheme')
|
|
21
|
+
const systemDarkMode =
|
|
22
|
+
window.matchMedia &&
|
|
23
|
+
window.matchMedia('(prefers-color-scheme: dark)').matches
|
|
24
|
+
if (userMode === 'dark' || (userMode !== 'light' && systemDarkMode)) {
|
|
25
|
+
document.documentElement.classList.toggle('dark', true)
|
|
26
|
+
}
|
|
24
27
|
</script>
|
|
25
28
|
<!--vuepress-ssr-head-->
|
|
26
29
|
<!--vuepress-ssr-styles-->
|
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
import type { Router } from 'vue-router';
|
|
2
|
-
/**
|
|
3
|
-
* Resolve a route with redirection
|
|
4
|
-
*/
|
|
5
|
-
export declare const getResolveRouteWithRedirect: (router: Router, to: import("vue-router").RouteLocationRaw, currentLocation?: import("vue-router").RouteLocationNormalizedLoaded | undefined) => ReturnType<Router['resolve']>;
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import { isFunction, isString } from 'vuepress/shared';
|
|
2
|
-
/**
|
|
3
|
-
* Resolve a route with redirection
|
|
4
|
-
*/
|
|
5
|
-
export const getResolveRouteWithRedirect = (router, ...args) => {
|
|
6
|
-
const route = router.resolve(...args);
|
|
7
|
-
const lastMatched = route.matched[route.matched.length - 1];
|
|
8
|
-
if (!lastMatched?.redirect) {
|
|
9
|
-
return route;
|
|
10
|
-
}
|
|
11
|
-
const { redirect } = lastMatched;
|
|
12
|
-
const resolvedRedirect = isFunction(redirect) ? redirect(route) : redirect;
|
|
13
|
-
const resolvedRedirectObj = isString(resolvedRedirect)
|
|
14
|
-
? { path: resolvedRedirect }
|
|
15
|
-
: resolvedRedirect;
|
|
16
|
-
return getResolveRouteWithRedirect(router, {
|
|
17
|
-
hash: route.hash,
|
|
18
|
-
query: route.query,
|
|
19
|
-
params: route.params,
|
|
20
|
-
...resolvedRedirectObj,
|
|
21
|
-
});
|
|
22
|
-
};
|