@vuepress/theme-default 2.0.0-rc.2 → 2.0.0-rc.3
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/NavbarBrand.vue +10 -1
- package/lib/client/components/NavbarItems.vue +6 -1
- package/lib/client/components/PageNav.vue +11 -2
- package/lib/client/composables/useSidebarItems.js +3 -0
- package/lib/node/defaultTheme.d.ts +5 -1
- package/lib/node/defaultTheme.js +20 -1
- package/lib/shared/nav.d.ts +2 -1
- package/lib/shared/options.d.ts +25 -0
- package/package.json +17 -14
|
@@ -24,12 +24,20 @@ const navbarBrandLogo = computed(() => {
|
|
|
24
24
|
}
|
|
25
25
|
return themeLocale.value.logo
|
|
26
26
|
})
|
|
27
|
+
const navbarBrandLogoAlt = computed(
|
|
28
|
+
() => themeLocale.value.logoAlt ?? navbarBrandTitle.value,
|
|
29
|
+
)
|
|
30
|
+
const navBarLogoAltMatchesTitle = computed(
|
|
31
|
+
() =>
|
|
32
|
+
navbarBrandTitle.value.toLocaleUpperCase().trim() ===
|
|
33
|
+
navbarBrandLogoAlt.value.toLocaleUpperCase().trim(),
|
|
34
|
+
)
|
|
27
35
|
const NavbarBrandLogo: FunctionalComponent = () => {
|
|
28
36
|
if (!navbarBrandLogo.value) return null
|
|
29
37
|
const img = h('img', {
|
|
30
38
|
class: 'logo',
|
|
31
39
|
src: withBase(navbarBrandLogo.value),
|
|
32
|
-
alt:
|
|
40
|
+
alt: navbarBrandLogoAlt.value,
|
|
33
41
|
})
|
|
34
42
|
if (themeLocale.value.logoDark === undefined) {
|
|
35
43
|
return img
|
|
@@ -48,6 +56,7 @@ const NavbarBrandLogo: FunctionalComponent = () => {
|
|
|
48
56
|
v-if="navbarBrandTitle"
|
|
49
57
|
class="site-name"
|
|
50
58
|
:class="{ 'can-hide': navbarBrandLogo }"
|
|
59
|
+
:aria-hidden="navBarLogoAltMatchesTitle"
|
|
51
60
|
>
|
|
52
61
|
{{ navbarBrandTitle }}
|
|
53
62
|
</span>
|
|
@@ -178,10 +178,15 @@ useUpdateDeviceStatus(
|
|
|
178
178
|
}
|
|
179
179
|
},
|
|
180
180
|
)
|
|
181
|
+
|
|
182
|
+
const navbarLabel = computed(() => {
|
|
183
|
+
const themeLocale = useThemeLocaleData()
|
|
184
|
+
return themeLocale.value.navbarLabel ?? 'site navigation'
|
|
185
|
+
})
|
|
181
186
|
</script>
|
|
182
187
|
|
|
183
188
|
<template>
|
|
184
|
-
<nav v-if="navbarLinks.length" class="navbar-items">
|
|
189
|
+
<nav v-if="navbarLinks.length" class="navbar-items" :aria-label="navbarLabel">
|
|
185
190
|
<div v-for="item in navbarLinks" :key="item.text" class="navbar-item">
|
|
186
191
|
<NavbarDropdown
|
|
187
192
|
v-if="item.children"
|
|
@@ -10,7 +10,7 @@ import type {
|
|
|
10
10
|
NavLink,
|
|
11
11
|
ResolvedSidebarItem,
|
|
12
12
|
} from '../../shared/index.js'
|
|
13
|
-
import { useSidebarItems } from '../composables/index.js'
|
|
13
|
+
import { useSidebarItems, useThemeLocaleData } from '../composables/index.js'
|
|
14
14
|
import { getNavLink } from '../utils/index.js'
|
|
15
15
|
|
|
16
16
|
/**
|
|
@@ -96,10 +96,19 @@ const nextNavLink = computed(() => {
|
|
|
96
96
|
|
|
97
97
|
return resolveFromSidebarItems(sidebarItems.value, route.path, 1)
|
|
98
98
|
})
|
|
99
|
+
|
|
100
|
+
const navbarLabel = computed(() => {
|
|
101
|
+
const themeLocale = useThemeLocaleData()
|
|
102
|
+
return themeLocale.value.pageNavbarLabel ?? 'page navigation'
|
|
103
|
+
})
|
|
99
104
|
</script>
|
|
100
105
|
|
|
101
106
|
<template>
|
|
102
|
-
<nav
|
|
107
|
+
<nav
|
|
108
|
+
v-if="prevNavLink || nextNavLink"
|
|
109
|
+
class="page-nav"
|
|
110
|
+
:aria-label="navbarLabel"
|
|
111
|
+
>
|
|
103
112
|
<p class="inner">
|
|
104
113
|
<span v-if="prevNavLink" class="prev">
|
|
105
114
|
<AutoLink :item="prevNavLink" />
|
|
@@ -111,5 +111,8 @@ export const resolveArraySidebarItems = (page, router, path, sidebarConfig, side
|
|
|
111
111
|
export const resolveMultiSidebarItems = (page, router, path, sidebarConfig, sidebarDepth) => {
|
|
112
112
|
const sidebarPath = resolveLocalePath(sidebarConfig, path);
|
|
113
113
|
const matchedSidebarConfig = sidebarConfig[sidebarPath] ?? [];
|
|
114
|
+
if (matchedSidebarConfig === 'heading') {
|
|
115
|
+
return resolveAutoSidebarItems(page, sidebarDepth);
|
|
116
|
+
}
|
|
114
117
|
return resolveArraySidebarItems(page, router, path, matchedSidebarConfig, sidebarDepth);
|
|
115
118
|
};
|
|
@@ -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
|
@@ -7,11 +7,14 @@ import { mediumZoomPlugin } from '@vuepress/plugin-medium-zoom';
|
|
|
7
7
|
import { nprogressPlugin } from '@vuepress/plugin-nprogress';
|
|
8
8
|
import { palettePlugin } from '@vuepress/plugin-palette';
|
|
9
9
|
import { prismjsPlugin } from '@vuepress/plugin-prismjs';
|
|
10
|
+
import { seoPlugin } from '@vuepress/plugin-seo';
|
|
11
|
+
import { sitemapPlugin } from '@vuepress/plugin-sitemap';
|
|
10
12
|
import { themeDataPlugin } from '@vuepress/plugin-theme-data';
|
|
13
|
+
import { isPlainObject } from 'vuepress/shared';
|
|
11
14
|
import { fs, getDirname, path } from 'vuepress/utils';
|
|
12
15
|
import { assignDefaultLocaleOptions, resolveContainerPluginOptions, } from './utils/index.js';
|
|
13
16
|
const __dirname = getDirname(import.meta.url);
|
|
14
|
-
export const defaultTheme = ({ themePlugins = {}, ...localeOptions } = {}) => {
|
|
17
|
+
export const defaultTheme = ({ hostname, themePlugins = {}, ...localeOptions } = {}) => {
|
|
15
18
|
assignDefaultLocaleOptions(localeOptions);
|
|
16
19
|
return {
|
|
17
20
|
name: '@vuepress/theme-default',
|
|
@@ -110,6 +113,22 @@ export const defaultTheme = ({ themePlugins = {}, ...localeOptions } = {}) => {
|
|
|
110
113
|
palettePlugin({ preset: 'sass' }),
|
|
111
114
|
// @vuepress/plugin-prismjs
|
|
112
115
|
themePlugins.prismjs !== false ? prismjsPlugin() : [],
|
|
116
|
+
// @vuepress/plugin-seo
|
|
117
|
+
hostname && themePlugins.seo !== false
|
|
118
|
+
? seoPlugin({
|
|
119
|
+
hostname,
|
|
120
|
+
...(isPlainObject(themePlugins.seo) ? themePlugins.seo : {}),
|
|
121
|
+
})
|
|
122
|
+
: [],
|
|
123
|
+
// @vuepress/plugin-sitemap
|
|
124
|
+
hostname && themePlugins.sitemap !== false
|
|
125
|
+
? sitemapPlugin({
|
|
126
|
+
hostname,
|
|
127
|
+
...(isPlainObject(themePlugins.sitemap)
|
|
128
|
+
? themePlugins.sitemap
|
|
129
|
+
: {}),
|
|
130
|
+
})
|
|
131
|
+
: [],
|
|
113
132
|
// @vuepress/plugin-theme-data
|
|
114
133
|
themeDataPlugin({ themeData: localeOptions }),
|
|
115
134
|
],
|
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,5 @@
|
|
|
1
|
+
import type { SeoPluginOptions } from '@vuepress/plugin-seo';
|
|
2
|
+
import type { SitemapPluginOptions } from '@vuepress/plugin-sitemap';
|
|
1
3
|
import type { ThemeData } from '@vuepress/plugin-theme-data';
|
|
2
4
|
import type { LocaleData } from 'vuepress/shared';
|
|
3
5
|
import type { NavbarConfig, SidebarConfig } from './nav.js';
|
|
@@ -41,6 +43,14 @@ export interface DefaultThemePluginsOptions {
|
|
|
41
43
|
* Enable @vuepress/plugin-prismjs or not
|
|
42
44
|
*/
|
|
43
45
|
prismjs?: boolean;
|
|
46
|
+
/**
|
|
47
|
+
* Enable @vuepress/plugin-seo or not
|
|
48
|
+
*/
|
|
49
|
+
seo?: Partial<SeoPluginOptions> | boolean;
|
|
50
|
+
/**
|
|
51
|
+
* Enable @vuepress/plugin-sitemap or not
|
|
52
|
+
*/
|
|
53
|
+
sitemap?: Partial<SitemapPluginOptions> | boolean;
|
|
44
54
|
}
|
|
45
55
|
export type DefaultThemeLocaleOptions = DefaultThemeData;
|
|
46
56
|
export type DefaultThemeData = ThemeData<DefaultThemeLocaleData>;
|
|
@@ -69,6 +79,14 @@ export interface DefaultThemeLocaleData extends LocaleData {
|
|
|
69
79
|
* Set to `false` to disable navbar in current locale
|
|
70
80
|
*/
|
|
71
81
|
navbar?: false | NavbarConfig;
|
|
82
|
+
/**
|
|
83
|
+
* Navbar label used for screen readers using the `aria-label` attribute
|
|
84
|
+
*/
|
|
85
|
+
navbarLabel?: null | string;
|
|
86
|
+
/**
|
|
87
|
+
* Page navbar label used for screen readers using the `aria-label` attribute
|
|
88
|
+
*/
|
|
89
|
+
pageNavbarLabel?: null | string;
|
|
72
90
|
/**
|
|
73
91
|
* Navbar logo config
|
|
74
92
|
*
|
|
@@ -81,6 +99,13 @@ export interface DefaultThemeLocaleData extends LocaleData {
|
|
|
81
99
|
* Logo to display in navbar in dark mode
|
|
82
100
|
*/
|
|
83
101
|
logoDark?: null | string;
|
|
102
|
+
/**
|
|
103
|
+
* The alt text of navbar logo.
|
|
104
|
+
* Defaults to the site title if not specified.
|
|
105
|
+
* If the value is the same as the site title, the site title rendered in the navbar will be
|
|
106
|
+
* hidden from screen readers to avoid duplication.
|
|
107
|
+
*/
|
|
108
|
+
logoAlt?: null | string;
|
|
84
109
|
/**
|
|
85
110
|
* Navbar repository config
|
|
86
111
|
*
|
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.3",
|
|
4
4
|
"description": "Default theme of VuePress",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"vuepress-theme",
|
|
@@ -14,7 +14,8 @@
|
|
|
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,20 +38,22 @@
|
|
|
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/plugin-active-header-links": "2.0.0-rc.
|
|
45
|
-
"@vuepress/plugin-back-to-top": "2.0.0-rc.
|
|
46
|
-
"@vuepress/plugin-container": "2.0.0-rc.
|
|
47
|
-
"@vuepress/plugin-external-link-icon": "2.0.0-rc.
|
|
48
|
-
"@vuepress/plugin-git": "2.0.0-rc.
|
|
49
|
-
"@vuepress/plugin-medium-zoom": "2.0.0-rc.
|
|
50
|
-
"@vuepress/plugin-nprogress": "2.0.0-rc.
|
|
51
|
-
"@vuepress/plugin-palette": "2.0.0-rc.
|
|
52
|
-
"@vuepress/plugin-prismjs": "2.0.0-rc.
|
|
53
|
-
"@vuepress/plugin-
|
|
45
|
+
"@vuepress/plugin-active-header-links": "2.0.0-rc.3",
|
|
46
|
+
"@vuepress/plugin-back-to-top": "2.0.0-rc.3",
|
|
47
|
+
"@vuepress/plugin-container": "2.0.0-rc.3",
|
|
48
|
+
"@vuepress/plugin-external-link-icon": "2.0.0-rc.3",
|
|
49
|
+
"@vuepress/plugin-git": "2.0.0-rc.3",
|
|
50
|
+
"@vuepress/plugin-medium-zoom": "2.0.0-rc.3",
|
|
51
|
+
"@vuepress/plugin-nprogress": "2.0.0-rc.3",
|
|
52
|
+
"@vuepress/plugin-palette": "2.0.0-rc.3",
|
|
53
|
+
"@vuepress/plugin-prismjs": "2.0.0-rc.3",
|
|
54
|
+
"@vuepress/plugin-seo": "2.0.0-rc.3",
|
|
55
|
+
"@vuepress/plugin-sitemap": "2.0.0-rc.3",
|
|
56
|
+
"@vuepress/plugin-theme-data": "2.0.0-rc.3",
|
|
54
57
|
"@vueuse/core": "^10.7.2",
|
|
55
58
|
"sass": "^1.70.0",
|
|
56
59
|
"vue": "^3.4.15",
|
|
@@ -68,5 +71,5 @@
|
|
|
68
71
|
"publishConfig": {
|
|
69
72
|
"access": "public"
|
|
70
73
|
},
|
|
71
|
-
"gitHead": "
|
|
74
|
+
"gitHead": "7247c765f50c3b2d5a622e0f7cf22bfb13a463c4"
|
|
72
75
|
}
|