@vuepress/theme-default 2.0.0-rc.3 → 2.0.0-rc.30
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/HomeHero.vue +2 -2
- package/lib/client/components/Navbar.vue +10 -9
- package/lib/client/components/NavbarBrand.vue +3 -2
- package/lib/client/components/NavbarDropdown.vue +4 -5
- package/lib/client/components/NavbarItems.vue +36 -37
- package/lib/client/components/PageMeta.vue +123 -27
- package/lib/client/components/PageNav.vue +133 -27
- package/lib/client/components/SidebarItem.vue +2 -3
- package/lib/client/components/SidebarItems.vue +1 -1
- package/lib/client/composables/index.d.ts +1 -0
- package/lib/client/composables/index.js +1 -0
- package/lib/client/composables/useNavigate.d.ts +1 -0
- package/lib/client/composables/useNavigate.js +25 -0
- package/lib/client/composables/useSidebarItems.d.ts +3 -4
- package/lib/client/composables/useSidebarItems.js +10 -12
- package/lib/client/composables/useUpdateDeviceStatus.js +3 -2
- package/lib/client/config.js +7 -11
- package/lib/client/index.d.ts +1 -1
- package/lib/client/index.js +0 -1
- package/lib/client/layouts/Layout.vue +8 -2
- package/lib/client/layouts/NotFound.vue +2 -2
- package/lib/client/styles/arrow.scss +18 -24
- package/lib/client/styles/custom-container.scss +4 -8
- package/lib/client/styles/external-link-icon.scss +33 -0
- package/lib/client/styles/index.scss +1 -0
- 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/page.scss +0 -76
- package/lib/client/styles/sidebar.scss +1 -1
- package/lib/client/styles/vars-dark.scss +7 -0
- package/lib/client/styles/vars.scss +63 -14
- package/lib/client/utils/getNavLink.d.ts +3 -9
- package/lib/client/utils/getNavLink.js +10 -11
- 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/client/utils/resolveEditLink.d.ts +1 -1
- package/lib/node/defaultTheme.js +28 -22
- package/lib/node/index.d.ts +2 -1
- package/lib/node/index.js +1 -1
- package/lib/node/utils/resolveContainerPluginOptions.d.ts +3 -3
- package/lib/node/utils/resolveContainerPluginOptions.js +2 -2
- package/lib/shared/nav.d.ts +3 -11
- package/lib/shared/options.d.ts +25 -4
- package/lib/shared/page.d.ts +5 -3
- package/package.json +21 -20
- package/templates/build.html +13 -10
- package/lib/client/components/AutoLink.vue +0 -113
- package/lib/client/utils/getResolveRouteWithRedirect.d.ts +0 -5
- package/lib/client/utils/getResolveRouteWithRedirect.js +0 -22
|
@@ -1,15 +1,9 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
import type { NavLink } from '../../shared/index.js';
|
|
3
|
-
declare module 'vue-router' {
|
|
4
|
-
interface RouteMeta {
|
|
5
|
-
title?: string;
|
|
6
|
-
}
|
|
7
|
-
}
|
|
1
|
+
import type { AutoLinkConfig } from 'vuepress/client';
|
|
8
2
|
/**
|
|
9
|
-
* Resolve
|
|
3
|
+
* Resolve AutoLink props from string
|
|
10
4
|
*
|
|
11
5
|
* @example
|
|
12
6
|
* - Input: '/README.md'
|
|
13
7
|
* - Output: { text: 'Home', link: '/' }
|
|
14
8
|
*/
|
|
15
|
-
export declare const
|
|
9
|
+
export declare const getAutoLink: (config: string) => AutoLinkConfig;
|
|
@@ -1,18 +1,17 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { resolveRoute } from 'vuepress/client';
|
|
2
2
|
/**
|
|
3
|
-
* Resolve
|
|
3
|
+
* Resolve AutoLink props from string
|
|
4
4
|
*
|
|
5
5
|
* @example
|
|
6
6
|
* - Input: '/README.md'
|
|
7
7
|
* - Output: { text: 'Home', link: '/' }
|
|
8
8
|
*/
|
|
9
|
-
export const
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
};
|
|
9
|
+
export const getAutoLink = (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;
|
package/lib/node/defaultTheme.js
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { activeHeaderLinksPlugin } from '@vuepress/plugin-active-header-links';
|
|
2
2
|
import { backToTopPlugin } from '@vuepress/plugin-back-to-top';
|
|
3
|
-
import {
|
|
4
|
-
import { externalLinkIconPlugin } from '@vuepress/plugin-external-link-icon';
|
|
3
|
+
import { copyCodePlugin } from '@vuepress/plugin-copy-code';
|
|
5
4
|
import { gitPlugin } from '@vuepress/plugin-git';
|
|
5
|
+
import { linksCheckPlugin } from '@vuepress/plugin-links-check';
|
|
6
|
+
import { markdownContainerPlugin } from '@vuepress/plugin-markdown-container';
|
|
6
7
|
import { mediumZoomPlugin } from '@vuepress/plugin-medium-zoom';
|
|
7
8
|
import { nprogressPlugin } from '@vuepress/plugin-nprogress';
|
|
8
9
|
import { palettePlugin } from '@vuepress/plugin-palette';
|
|
@@ -12,7 +13,7 @@ import { sitemapPlugin } from '@vuepress/plugin-sitemap';
|
|
|
12
13
|
import { themeDataPlugin } from '@vuepress/plugin-theme-data';
|
|
13
14
|
import { isPlainObject } from 'vuepress/shared';
|
|
14
15
|
import { fs, getDirname, path } from 'vuepress/utils';
|
|
15
|
-
import { assignDefaultLocaleOptions,
|
|
16
|
+
import { assignDefaultLocaleOptions, resolveMarkdownContainerPluginOptions, } from './utils/index.js';
|
|
16
17
|
const __dirname = getDirname(import.meta.url);
|
|
17
18
|
export const defaultTheme = ({ hostname, themePlugins = {}, ...localeOptions } = {}) => {
|
|
18
19
|
assignDefaultLocaleOptions(localeOptions);
|
|
@@ -47,49 +48,48 @@ export const defaultTheme = ({ hostname, themePlugins = {}, ...localeOptions } =
|
|
|
47
48
|
})
|
|
48
49
|
: [],
|
|
49
50
|
// @vuepress/plugin-back-to-top
|
|
50
|
-
themePlugins.backToTop !== false
|
|
51
|
-
|
|
51
|
+
themePlugins.backToTop !== false
|
|
52
|
+
? backToTopPlugin(isPlainObject(themePlugins.backToTop) ? themePlugins.backToTop : {})
|
|
53
|
+
: [],
|
|
54
|
+
// @vuepress/plugin-copy-code
|
|
55
|
+
themePlugins.copyCode !== false
|
|
56
|
+
? copyCodePlugin({
|
|
57
|
+
...(isPlainObject(themePlugins.copyCode)
|
|
58
|
+
? themePlugins.copyCode
|
|
59
|
+
: {}),
|
|
60
|
+
})
|
|
61
|
+
: [],
|
|
62
|
+
// @vuepress/plugin-markdown-container
|
|
52
63
|
themePlugins.container?.tip !== false
|
|
53
|
-
?
|
|
64
|
+
? markdownContainerPlugin(resolveMarkdownContainerPluginOptions(localeOptions, 'tip'))
|
|
54
65
|
: [],
|
|
55
66
|
themePlugins.container?.warning !== false
|
|
56
|
-
?
|
|
67
|
+
? markdownContainerPlugin(resolveMarkdownContainerPluginOptions(localeOptions, 'warning'))
|
|
57
68
|
: [],
|
|
58
69
|
themePlugins.container?.danger !== false
|
|
59
|
-
?
|
|
70
|
+
? markdownContainerPlugin(resolveMarkdownContainerPluginOptions(localeOptions, 'danger'))
|
|
60
71
|
: [],
|
|
61
72
|
themePlugins.container?.details !== false
|
|
62
|
-
?
|
|
73
|
+
? markdownContainerPlugin({
|
|
63
74
|
type: 'details',
|
|
64
75
|
before: (info) => `<details class="custom-container details">${info ? `<summary>${info}</summary>` : ''}\n`,
|
|
65
76
|
after: () => '</details>\n',
|
|
66
77
|
})
|
|
67
78
|
: [],
|
|
68
79
|
themePlugins.container?.codeGroup !== false
|
|
69
|
-
?
|
|
80
|
+
? markdownContainerPlugin({
|
|
70
81
|
type: 'code-group',
|
|
71
82
|
before: () => `<CodeGroup>\n`,
|
|
72
83
|
after: () => '</CodeGroup>\n',
|
|
73
84
|
})
|
|
74
85
|
: [],
|
|
75
86
|
themePlugins.container?.codeGroupItem !== false
|
|
76
|
-
?
|
|
87
|
+
? markdownContainerPlugin({
|
|
77
88
|
type: 'code-group-item',
|
|
78
89
|
before: (info) => `<CodeGroupItem title="${info}">\n`,
|
|
79
90
|
after: () => '</CodeGroupItem>\n',
|
|
80
91
|
})
|
|
81
92
|
: [],
|
|
82
|
-
// @vuepress/plugin-external-link-icon
|
|
83
|
-
themePlugins.externalLinkIcon !== false
|
|
84
|
-
? externalLinkIconPlugin({
|
|
85
|
-
locales: Object.entries(localeOptions.locales || {}).reduce((result, [key, value]) => {
|
|
86
|
-
result[key] = {
|
|
87
|
-
openInNewWindow: value.openInNewWindow ?? localeOptions.openInNewWindow,
|
|
88
|
-
};
|
|
89
|
-
return result;
|
|
90
|
-
}, {}),
|
|
91
|
-
})
|
|
92
|
-
: [],
|
|
93
93
|
// @vuepress/plugin-git
|
|
94
94
|
themePlugins.git !== false
|
|
95
95
|
? gitPlugin({
|
|
@@ -98,6 +98,12 @@ export const defaultTheme = ({ hostname, themePlugins = {}, ...localeOptions } =
|
|
|
98
98
|
contributors: localeOptions.contributors !== false,
|
|
99
99
|
})
|
|
100
100
|
: [],
|
|
101
|
+
// @vuepress/plugin-links-check
|
|
102
|
+
themePlugins.linksCheck !== false
|
|
103
|
+
? linksCheckPlugin(isPlainObject(themePlugins.linksCheck)
|
|
104
|
+
? themePlugins.linksCheck
|
|
105
|
+
: {})
|
|
106
|
+
: [],
|
|
101
107
|
// @vuepress/plugin-medium-zoom
|
|
102
108
|
themePlugins.mediumZoom !== false
|
|
103
109
|
? mediumZoomPlugin({
|
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
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { MarkdownContainerPluginOptions } from '@vuepress/plugin-markdown-container';
|
|
2
2
|
import type { DefaultThemeData } from '../../shared/index.js';
|
|
3
3
|
/**
|
|
4
|
-
* Resolve options for @vuepress/plugin-container
|
|
4
|
+
* Resolve options for @vuepress/plugin-markdown-container
|
|
5
5
|
*
|
|
6
6
|
* For custom containers default title
|
|
7
7
|
*/
|
|
8
|
-
export declare const
|
|
8
|
+
export declare const resolveMarkdownContainerPluginOptions: (localeOptions: DefaultThemeData, type: 'tip' | 'warning' | 'danger') => MarkdownContainerPluginOptions;
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Resolve options for @vuepress/plugin-container
|
|
2
|
+
* Resolve options for @vuepress/plugin-markdown-container
|
|
3
3
|
*
|
|
4
4
|
* For custom containers default title
|
|
5
5
|
*/
|
|
6
|
-
export const
|
|
6
|
+
export const resolveMarkdownContainerPluginOptions = (localeOptions, type) => {
|
|
7
7
|
const locales = Object.entries(localeOptions.locales || {}).reduce((result, [key, value]) => {
|
|
8
8
|
result[key] = {
|
|
9
9
|
defaultInfo: value?.[type] ?? localeOptions[type],
|
package/lib/shared/nav.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { AutoLinkConfig } from 'vuepress/client';
|
|
1
2
|
/**
|
|
2
3
|
* Base nav item, displayed as text
|
|
3
4
|
*/
|
|
@@ -11,26 +12,17 @@ export interface NavItem {
|
|
|
11
12
|
export interface NavGroup<T> extends NavItem {
|
|
12
13
|
children: T[];
|
|
13
14
|
}
|
|
14
|
-
/**
|
|
15
|
-
* Props for `<AutoLink>`
|
|
16
|
-
*/
|
|
17
|
-
export interface NavLink extends NavItem {
|
|
18
|
-
link: string;
|
|
19
|
-
rel?: string;
|
|
20
|
-
target?: string;
|
|
21
|
-
activeMatch?: string;
|
|
22
|
-
}
|
|
23
15
|
/**
|
|
24
16
|
* Navbar types
|
|
25
17
|
*/
|
|
26
|
-
export type NavbarItem =
|
|
18
|
+
export type NavbarItem = AutoLinkConfig;
|
|
27
19
|
export type NavbarGroup = NavGroup<NavbarGroup | NavbarItem | string>;
|
|
28
20
|
export type NavbarConfig = (NavbarItem | NavbarGroup | string)[];
|
|
29
21
|
export type ResolvedNavbarItem = NavbarItem | NavGroup<ResolvedNavbarItem>;
|
|
30
22
|
/**
|
|
31
23
|
* Sidebar types
|
|
32
24
|
*/
|
|
33
|
-
export type SidebarItem = NavItem & Partial<
|
|
25
|
+
export type SidebarItem = NavItem & Partial<AutoLinkConfig>;
|
|
34
26
|
export type SidebarGroup = SidebarItem & NavGroup<SidebarItem | SidebarGroup | string> & {
|
|
35
27
|
collapsible?: boolean;
|
|
36
28
|
};
|
package/lib/shared/options.d.ts
CHANGED
|
@@ -1,3 +1,6 @@
|
|
|
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';
|
|
1
4
|
import type { SeoPluginOptions } from '@vuepress/plugin-seo';
|
|
2
5
|
import type { SitemapPluginOptions } from '@vuepress/plugin-sitemap';
|
|
3
6
|
import type { ThemeData } from '@vuepress/plugin-theme-data';
|
|
@@ -11,9 +14,9 @@ export interface DefaultThemePluginsOptions {
|
|
|
11
14
|
/**
|
|
12
15
|
* Enable @vuepress/plugin-back-to-top or not
|
|
13
16
|
*/
|
|
14
|
-
backToTop?: boolean;
|
|
17
|
+
backToTop?: BackToTopPluginOptions | boolean;
|
|
15
18
|
/**
|
|
16
|
-
* Enable @vuepress/plugin-container or not
|
|
19
|
+
* Enable @vuepress/plugin-markdown-container or not
|
|
17
20
|
*/
|
|
18
21
|
container?: {
|
|
19
22
|
tip?: boolean;
|
|
@@ -24,13 +27,17 @@ export interface DefaultThemePluginsOptions {
|
|
|
24
27
|
codeGroupItem?: boolean;
|
|
25
28
|
};
|
|
26
29
|
/**
|
|
27
|
-
* Enable @vuepress/plugin-
|
|
30
|
+
* Enable @vuepress/plugin-copy-code or not
|
|
28
31
|
*/
|
|
29
|
-
|
|
32
|
+
copyCode?: CopyCodePluginOptions | boolean;
|
|
30
33
|
/**
|
|
31
34
|
* Enable @vuepress/plugin-git or not
|
|
32
35
|
*/
|
|
33
36
|
git?: boolean;
|
|
37
|
+
/**
|
|
38
|
+
* Enable @vuepress/plugin-links-check or not
|
|
39
|
+
*/
|
|
40
|
+
linksCheck?: LinksCheckPluginOptions | boolean;
|
|
34
41
|
/**
|
|
35
42
|
* Enable @vuepress/plugin-medium-zoom or not
|
|
36
43
|
*/
|
|
@@ -67,6 +74,12 @@ export interface DefaultThemeLocaleData extends LocaleData {
|
|
|
67
74
|
* @default true
|
|
68
75
|
*/
|
|
69
76
|
colorModeSwitch?: boolean;
|
|
77
|
+
/**
|
|
78
|
+
* Whether show external link icon
|
|
79
|
+
*
|
|
80
|
+
* @default true
|
|
81
|
+
*/
|
|
82
|
+
externalLinkIcon?: boolean;
|
|
70
83
|
/**
|
|
71
84
|
* Home path of current locale
|
|
72
85
|
*
|
|
@@ -265,4 +278,12 @@ export interface DefaultThemeLocaleData extends LocaleData {
|
|
|
265
278
|
* A11y text for sidebar toggle button
|
|
266
279
|
*/
|
|
267
280
|
toggleSidebar?: string;
|
|
281
|
+
/**
|
|
282
|
+
* text for prev link
|
|
283
|
+
*/
|
|
284
|
+
prev?: string;
|
|
285
|
+
/**
|
|
286
|
+
* text for next link
|
|
287
|
+
*/
|
|
288
|
+
next?: string;
|
|
268
289
|
}
|
package/lib/shared/page.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { GitPluginPageData } from '@vuepress/plugin-git';
|
|
2
|
-
import type {
|
|
2
|
+
import type { AutoLinkConfig } from 'vuepress/client';
|
|
3
|
+
import type { SidebarConfig } from './nav.js';
|
|
3
4
|
export interface DefaultThemePageData extends GitPluginPageData {
|
|
4
5
|
filePathRelative: string | null;
|
|
5
6
|
}
|
|
@@ -7,6 +8,7 @@ export interface DefaultThemePageFrontmatter {
|
|
|
7
8
|
home?: boolean;
|
|
8
9
|
navbar?: boolean;
|
|
9
10
|
pageClass?: string;
|
|
11
|
+
externalLinkIcon?: boolean;
|
|
10
12
|
}
|
|
11
13
|
export interface DefaultThemeHomePageFrontmatter extends DefaultThemePageFrontmatter {
|
|
12
14
|
home: true;
|
|
@@ -36,6 +38,6 @@ export interface DefaultThemeNormalPageFrontmatter extends DefaultThemePageFront
|
|
|
36
38
|
contributors?: boolean;
|
|
37
39
|
sidebar?: 'auto' | false | SidebarConfig;
|
|
38
40
|
sidebarDepth?: number;
|
|
39
|
-
prev?: string |
|
|
40
|
-
next?: string |
|
|
41
|
+
prev?: string | AutoLinkConfig;
|
|
42
|
+
next?: string | AutoLinkConfig;
|
|
41
43
|
}
|
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.30",
|
|
4
4
|
"description": "Default theme of VuePress",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"vuepress-theme",
|
|
@@ -8,7 +8,7 @@
|
|
|
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
|
},
|
|
@@ -42,26 +42,27 @@
|
|
|
42
42
|
"copy": "cpx \"src/**/*.{d.ts,vue,scss}\" lib"
|
|
43
43
|
},
|
|
44
44
|
"dependencies": {
|
|
45
|
-
"@vuepress/
|
|
46
|
-
"@vuepress/plugin-
|
|
47
|
-
"@vuepress/plugin-
|
|
48
|
-
"@vuepress/plugin-
|
|
49
|
-
"@vuepress/plugin-git": "2.0.0-rc.
|
|
50
|
-
"@vuepress/plugin-
|
|
51
|
-
"@vuepress/plugin-
|
|
52
|
-
"@vuepress/plugin-
|
|
53
|
-
"@vuepress/plugin-
|
|
54
|
-
"@vuepress/plugin-
|
|
55
|
-
"@vuepress/plugin-
|
|
56
|
-
"@vuepress/plugin-
|
|
57
|
-
"@
|
|
58
|
-
"
|
|
59
|
-
"
|
|
60
|
-
"
|
|
45
|
+
"@vuepress/helper": "~2.0.0-rc.30",
|
|
46
|
+
"@vuepress/plugin-active-header-links": "~2.0.0-rc.30",
|
|
47
|
+
"@vuepress/plugin-back-to-top": "~2.0.0-rc.30",
|
|
48
|
+
"@vuepress/plugin-copy-code": "~2.0.0-rc.30",
|
|
49
|
+
"@vuepress/plugin-git": "~2.0.0-rc.30",
|
|
50
|
+
"@vuepress/plugin-links-check": "~2.0.0-rc.30",
|
|
51
|
+
"@vuepress/plugin-markdown-container": "~2.0.0-rc.30",
|
|
52
|
+
"@vuepress/plugin-medium-zoom": "~2.0.0-rc.30",
|
|
53
|
+
"@vuepress/plugin-nprogress": "~2.0.0-rc.30",
|
|
54
|
+
"@vuepress/plugin-palette": "~2.0.0-rc.30",
|
|
55
|
+
"@vuepress/plugin-prismjs": "~2.0.0-rc.30",
|
|
56
|
+
"@vuepress/plugin-seo": "~2.0.0-rc.30",
|
|
57
|
+
"@vuepress/plugin-sitemap": "~2.0.0-rc.30",
|
|
58
|
+
"@vuepress/plugin-theme-data": "~2.0.0-rc.30",
|
|
59
|
+
"@vueuse/core": "^10.9.0",
|
|
60
|
+
"sass": "^1.77.1",
|
|
61
|
+
"vue": "^3.4.27"
|
|
61
62
|
},
|
|
62
63
|
"peerDependencies": {
|
|
63
64
|
"sass-loader": "^14.0.0",
|
|
64
|
-
"vuepress": "2.0.0-rc.
|
|
65
|
+
"vuepress": "2.0.0-rc.11"
|
|
65
66
|
},
|
|
66
67
|
"peerDependenciesMeta": {
|
|
67
68
|
"sass-loader": {
|
|
@@ -71,5 +72,5 @@
|
|
|
71
72
|
"publishConfig": {
|
|
72
73
|
"access": "public"
|
|
73
74
|
},
|
|
74
|
-
"gitHead": "
|
|
75
|
+
"gitHead": "e84a9e154e119525784f6934f06a795029798f8f"
|
|
75
76
|
}
|
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,113 +0,0 @@
|
|
|
1
|
-
<script setup lang="ts">
|
|
2
|
-
import { computed, toRefs } from 'vue'
|
|
3
|
-
import type { PropType } from 'vue'
|
|
4
|
-
import { useRoute } from 'vue-router'
|
|
5
|
-
import { useSiteData } from 'vuepress/client'
|
|
6
|
-
import { isLinkHttp, isLinkWithProtocol } from 'vuepress/shared'
|
|
7
|
-
import type { NavLink } from '../../shared/index.js'
|
|
8
|
-
|
|
9
|
-
defineOptions({
|
|
10
|
-
inheritAttrs: false,
|
|
11
|
-
})
|
|
12
|
-
|
|
13
|
-
const props = defineProps({
|
|
14
|
-
item: {
|
|
15
|
-
type: Object as PropType<NavLink>,
|
|
16
|
-
required: true,
|
|
17
|
-
},
|
|
18
|
-
})
|
|
19
|
-
|
|
20
|
-
defineSlots<{
|
|
21
|
-
before?: (props: Record<never, never>) => any
|
|
22
|
-
after?: (props: Record<never, never>) => any
|
|
23
|
-
}>()
|
|
24
|
-
|
|
25
|
-
const route = useRoute()
|
|
26
|
-
const site = useSiteData()
|
|
27
|
-
const { item } = toRefs(props)
|
|
28
|
-
|
|
29
|
-
// if the link has http protocol
|
|
30
|
-
const hasHttpProtocol = computed(() => isLinkHttp(item.value.link))
|
|
31
|
-
// if the link has non-http protocol
|
|
32
|
-
const hasNonHttpProtocol = computed(
|
|
33
|
-
() => !hasHttpProtocol.value && isLinkWithProtocol(item.value.link),
|
|
34
|
-
)
|
|
35
|
-
// resolve the `target` attr
|
|
36
|
-
const linkTarget = computed(() => {
|
|
37
|
-
if (hasNonHttpProtocol.value) return undefined
|
|
38
|
-
if (item.value.target) return item.value.target
|
|
39
|
-
if (hasHttpProtocol.value) return '_blank'
|
|
40
|
-
return undefined
|
|
41
|
-
})
|
|
42
|
-
// if the `target` attr is '_blank'
|
|
43
|
-
const isBlankTarget = computed(() => linkTarget.value === '_blank')
|
|
44
|
-
// is `<RouterLink>` or not
|
|
45
|
-
const isRouterLink = computed(
|
|
46
|
-
() =>
|
|
47
|
-
!hasHttpProtocol.value && !hasNonHttpProtocol.value && !isBlankTarget.value,
|
|
48
|
-
)
|
|
49
|
-
// resolve the `rel` attr
|
|
50
|
-
const linkRel = computed(() => {
|
|
51
|
-
if (hasNonHttpProtocol.value) return undefined
|
|
52
|
-
if (item.value.rel) return item.value.rel
|
|
53
|
-
if (isBlankTarget.value) return 'noopener noreferrer'
|
|
54
|
-
return undefined
|
|
55
|
-
})
|
|
56
|
-
// resolve the `aria-label` attr
|
|
57
|
-
const linkAriaLabel = computed(() => item.value.ariaLabel || item.value.text)
|
|
58
|
-
|
|
59
|
-
// should be active when current route is a subpath of this link
|
|
60
|
-
const shouldBeActiveInSubpath = computed(() => {
|
|
61
|
-
const localeKeys = Object.keys(site.value.locales)
|
|
62
|
-
if (localeKeys.length) {
|
|
63
|
-
return !localeKeys.some((key) => key === item.value.link)
|
|
64
|
-
}
|
|
65
|
-
return item.value.link !== '/'
|
|
66
|
-
})
|
|
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
|
-
|
|
75
|
-
// if this link is active
|
|
76
|
-
const isActive = computed(() => {
|
|
77
|
-
if (!isRouterLink.value) {
|
|
78
|
-
return false
|
|
79
|
-
}
|
|
80
|
-
if (item.value.activeMatch) {
|
|
81
|
-
return new RegExp(item.value.activeMatch).test(route.path)
|
|
82
|
-
}
|
|
83
|
-
return isActiveInSubpath.value
|
|
84
|
-
})
|
|
85
|
-
</script>
|
|
86
|
-
|
|
87
|
-
<template>
|
|
88
|
-
<RouterLink
|
|
89
|
-
v-if="isRouterLink"
|
|
90
|
-
:class="{ 'router-link-active': isActive }"
|
|
91
|
-
:to="item.link"
|
|
92
|
-
:aria-label="linkAriaLabel"
|
|
93
|
-
v-bind="$attrs"
|
|
94
|
-
>
|
|
95
|
-
<slot name="before" />
|
|
96
|
-
{{ item.text }}
|
|
97
|
-
<slot name="after" />
|
|
98
|
-
</RouterLink>
|
|
99
|
-
<a
|
|
100
|
-
v-else
|
|
101
|
-
class="external-link"
|
|
102
|
-
:href="item.link"
|
|
103
|
-
:rel="linkRel"
|
|
104
|
-
:target="linkTarget"
|
|
105
|
-
:aria-label="linkAriaLabel"
|
|
106
|
-
v-bind="$attrs"
|
|
107
|
-
>
|
|
108
|
-
<slot name="before" />
|
|
109
|
-
{{ item.text }}
|
|
110
|
-
<AutoLinkExternalIcon v-if="isBlankTarget" />
|
|
111
|
-
<slot name="after" />
|
|
112
|
-
</a>
|
|
113
|
-
</template>
|
|
@@ -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
|
-
};
|