@vuepress/theme-default 2.0.0-beta.28 → 2.0.0-beta.32
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/clientAppEnhance.js +4 -5
- package/lib/client/components/{NavLink.vue → AutoLink.vue} +28 -29
- package/lib/client/components/DropdownTransition.vue +11 -11
- package/lib/client/components/Home.vue +12 -110
- 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 +97 -0
- package/lib/client/components/Navbar.vue +24 -58
- package/lib/client/components/NavbarBrand.vue +55 -0
- package/lib/client/components/{DropdownLink.vue → NavbarDropdown.vue} +64 -64
- package/lib/client/components/{NavbarLinks.vue → NavbarItems.vue} +12 -13
- package/lib/client/components/Page.vue +5 -5
- package/lib/client/components/PageMeta.vue +33 -33
- package/lib/client/components/PageNav.vue +20 -20
- package/lib/client/components/Sidebar.vue +7 -19
- package/lib/client/components/SidebarItem.vue +74 -0
- package/lib/client/components/SidebarItems.vue +16 -0
- package/lib/client/components/ToggleDarkModeButton.vue +11 -11
- package/lib/client/components/ToggleSidebarButton.vue +8 -8
- package/lib/client/components/global/Badge.vue +12 -12
- package/lib/client/components/global/CodeGroupItem.vue +10 -10
- package/lib/client/components/global/{OutboundLink.vue → ExternalLinkIcon.vue} +7 -10
- package/lib/client/index.d.ts +2 -2
- package/lib/client/layouts/404.vue +12 -12
- package/lib/client/layouts/Layout.vue +54 -54
- package/lib/client/styles/{_wrapper.scss → _mixins.scss} +6 -1
- package/lib/client/styles/code.scss +2 -1
- package/lib/client/styles/index.scss +1 -1
- package/lib/client/styles/layout.scss +2 -2
- package/lib/client/styles/{dropdown.scss → navbar-dropdown.scss} +25 -33
- package/lib/client/styles/navbar.scss +8 -8
- package/lib/client/styles/normalize.scss +4 -0
- package/lib/client/styles/page.scss +5 -5
- package/lib/client/styles/sidebar.scss +67 -70
- package/lib/client/styles/transitions.scss +11 -2
- package/lib/client/styles/vars.scss +5 -0
- package/lib/client/utils/index.d.ts +1 -0
- package/lib/client/utils/index.js +1 -0
- package/lib/client/utils/isActiveSidebarItem.d.ts +3 -0
- package/lib/client/utils/isActiveSidebarItem.js +20 -0
- package/lib/node/defaultTheme.js +1 -0
- package/lib/node/utils/assignDefaultLocaleOptions.d.ts +3 -1
- package/lib/node/utils/assignDefaultLocaleOptions.js +5 -5
- package/lib/shared/nav.d.ts +10 -4
- package/lib/shared/options.d.ts +5 -1
- package/package.json +16 -15
- package/lib/client/components/SidebarChild.d.ts +0 -6
- package/lib/client/components/SidebarChild.js +0 -76
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
const normalizePath = (path) => decodeURI(path)
|
|
2
|
+
.replace(/#.*$/, '')
|
|
3
|
+
.replace(/(index)?\.(md|html)$/, '');
|
|
4
|
+
const isActiveLink = (link, route) => {
|
|
5
|
+
if (route.hash === link) {
|
|
6
|
+
return true;
|
|
7
|
+
}
|
|
8
|
+
const currentPath = normalizePath(route.path);
|
|
9
|
+
const targetPath = normalizePath(link);
|
|
10
|
+
return currentPath === targetPath;
|
|
11
|
+
};
|
|
12
|
+
export const isActiveSidebarItem = (item, route) => {
|
|
13
|
+
if (item.link && isActiveLink(item.link, route)) {
|
|
14
|
+
return true;
|
|
15
|
+
}
|
|
16
|
+
if (item.children) {
|
|
17
|
+
return item.children.some((child) => isActiveSidebarItem(child, route));
|
|
18
|
+
}
|
|
19
|
+
return false;
|
|
20
|
+
};
|
package/lib/node/defaultTheme.js
CHANGED
|
@@ -56,6 +56,7 @@ const defaultTheme = ({ themePlugins = {}, ...localeOptions }, app) => {
|
|
|
56
56
|
'@vuepress/container',
|
|
57
57
|
(0, utils_2.resolveContainerPluginOptionsForCodeGroupItem)(themePlugins),
|
|
58
58
|
],
|
|
59
|
+
['@vuepress/external-link-icon', themePlugins.externalLinkIcon !== false],
|
|
59
60
|
['@vuepress/git', (0, utils_2.resolveGitPluginOptions)(themePlugins, localeOptions)],
|
|
60
61
|
['@vuepress/medium-zoom', (0, utils_2.resolveMediumZoomPluginOptions)(themePlugins)],
|
|
61
62
|
['@vuepress/nprogress', themePlugins.nprogress !== false],
|
|
@@ -1,4 +1,6 @@
|
|
|
1
|
-
import type { DefaultThemeLocaleOptions } from '../../shared';
|
|
1
|
+
import type { DefaultThemeLocaleData, DefaultThemeLocaleOptions } from '../../shared';
|
|
2
|
+
export declare const DEFAULT_LOCALE_OPTIONS: DefaultThemeLocaleOptions;
|
|
3
|
+
export declare const DEFAULT_LOCALE_DATA: DefaultThemeLocaleData;
|
|
2
4
|
/**
|
|
3
5
|
* Assign default options to `themeConfig`
|
|
4
6
|
*/
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.assignDefaultLocaleOptions = void 0;
|
|
4
|
-
|
|
3
|
+
exports.assignDefaultLocaleOptions = exports.DEFAULT_LOCALE_DATA = exports.DEFAULT_LOCALE_OPTIONS = void 0;
|
|
4
|
+
exports.DEFAULT_LOCALE_OPTIONS = {
|
|
5
5
|
// navbar
|
|
6
6
|
navbar: [],
|
|
7
7
|
logo: null,
|
|
@@ -32,7 +32,7 @@ const defaultLocaleOptions = {
|
|
|
32
32
|
toggleDarkMode: 'toggle dark mode',
|
|
33
33
|
toggleSidebar: 'toggle sidebar',
|
|
34
34
|
};
|
|
35
|
-
|
|
35
|
+
exports.DEFAULT_LOCALE_DATA = {
|
|
36
36
|
// navbar
|
|
37
37
|
selectLanguageName: 'English',
|
|
38
38
|
};
|
|
@@ -47,11 +47,11 @@ const assignDefaultLocaleOptions = (localeOptions) => {
|
|
|
47
47
|
localeOptions.locales['/'] = {};
|
|
48
48
|
}
|
|
49
49
|
Object.assign(localeOptions, {
|
|
50
|
-
...
|
|
50
|
+
...exports.DEFAULT_LOCALE_OPTIONS,
|
|
51
51
|
...localeOptions,
|
|
52
52
|
});
|
|
53
53
|
Object.assign(localeOptions.locales['/'], {
|
|
54
|
-
...
|
|
54
|
+
...exports.DEFAULT_LOCALE_DATA,
|
|
55
55
|
...localeOptions.locales['/'],
|
|
56
56
|
});
|
|
57
57
|
};
|
package/lib/shared/nav.d.ts
CHANGED
|
@@ -12,7 +12,7 @@ export interface NavGroup<T> extends NavItem {
|
|
|
12
12
|
children: T[];
|
|
13
13
|
}
|
|
14
14
|
/**
|
|
15
|
-
* Props for `<
|
|
15
|
+
* Props for `<AutoLink>`
|
|
16
16
|
*/
|
|
17
17
|
export interface NavLink extends NavItem {
|
|
18
18
|
link: string;
|
|
@@ -30,8 +30,14 @@ export declare type ResolvedNavbarItem = NavbarItem | NavGroup<ResolvedNavbarIte
|
|
|
30
30
|
/**
|
|
31
31
|
* Sidebar types
|
|
32
32
|
*/
|
|
33
|
-
export declare type SidebarItem = NavItem & Partial<NavLink
|
|
34
|
-
export declare type
|
|
33
|
+
export declare type SidebarItem = NavItem & Partial<NavLink>;
|
|
34
|
+
export declare type SidebarGroup = SidebarItem & NavGroup<SidebarItem | SidebarGroup | string>;
|
|
35
|
+
export declare type SidebarGroupCollapsible = SidebarGroup & {
|
|
36
|
+
collapsible?: boolean;
|
|
37
|
+
};
|
|
38
|
+
export declare type SidebarConfigArray = (SidebarItem | SidebarGroupCollapsible | string)[];
|
|
35
39
|
export declare type SidebarConfigObject = Record<string, SidebarConfigArray>;
|
|
36
40
|
export declare type SidebarConfig = SidebarConfigArray | SidebarConfigObject;
|
|
37
|
-
export declare type ResolvedSidebarItem =
|
|
41
|
+
export declare type ResolvedSidebarItem = SidebarItem & Partial<NavGroup<ResolvedSidebarItem>> & {
|
|
42
|
+
collapsible?: boolean;
|
|
43
|
+
};
|
package/lib/shared/options.d.ts
CHANGED
|
@@ -21,6 +21,10 @@ export interface DefaultThemePluginsOptions {
|
|
|
21
21
|
codeGroup?: boolean;
|
|
22
22
|
codeGroupItem?: boolean;
|
|
23
23
|
};
|
|
24
|
+
/**
|
|
25
|
+
* Enable @vuepress/plugin-external-link-icon or not
|
|
26
|
+
*/
|
|
27
|
+
externalLinkIcon?: boolean;
|
|
24
28
|
/**
|
|
25
29
|
* Enable @vuepress/plugin-git or not
|
|
26
30
|
*/
|
|
@@ -219,7 +223,7 @@ export interface DefaultThemeLocaleData extends LocaleData {
|
|
|
219
223
|
*/
|
|
220
224
|
backToHome?: string;
|
|
221
225
|
/**
|
|
222
|
-
* A11y text for
|
|
226
|
+
* A11y text for external link icon
|
|
223
227
|
*/
|
|
224
228
|
openInNewWindow?: string;
|
|
225
229
|
/**
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vuepress/theme-default",
|
|
3
|
-
"version": "2.0.0-beta.
|
|
3
|
+
"version": "2.0.0-beta.32",
|
|
4
4
|
"description": "Default theme of VuePress",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"vuepress-theme",
|
|
@@ -29,19 +29,20 @@
|
|
|
29
29
|
"copy": "cpx \"src/**/*.{d.ts,vue,scss}\" lib"
|
|
30
30
|
},
|
|
31
31
|
"dependencies": {
|
|
32
|
-
"@vuepress/client": "2.0.0-beta.
|
|
33
|
-
"@vuepress/core": "2.0.0-beta.
|
|
34
|
-
"@vuepress/plugin-active-header-links": "2.0.0-beta.
|
|
35
|
-
"@vuepress/plugin-back-to-top": "2.0.0-beta.
|
|
36
|
-
"@vuepress/plugin-container": "2.0.0-beta.
|
|
37
|
-
"@vuepress/plugin-
|
|
38
|
-
"@vuepress/plugin-
|
|
39
|
-
"@vuepress/plugin-
|
|
40
|
-
"@vuepress/plugin-
|
|
41
|
-
"@vuepress/plugin-
|
|
42
|
-
"@vuepress/plugin-
|
|
43
|
-
"@vuepress/
|
|
44
|
-
"@vuepress/
|
|
32
|
+
"@vuepress/client": "2.0.0-beta.32",
|
|
33
|
+
"@vuepress/core": "2.0.0-beta.32",
|
|
34
|
+
"@vuepress/plugin-active-header-links": "2.0.0-beta.32",
|
|
35
|
+
"@vuepress/plugin-back-to-top": "2.0.0-beta.32",
|
|
36
|
+
"@vuepress/plugin-container": "2.0.0-beta.32",
|
|
37
|
+
"@vuepress/plugin-external-link-icon": "2.0.0-beta.32",
|
|
38
|
+
"@vuepress/plugin-git": "2.0.0-beta.32",
|
|
39
|
+
"@vuepress/plugin-medium-zoom": "2.0.0-beta.32",
|
|
40
|
+
"@vuepress/plugin-nprogress": "2.0.0-beta.32",
|
|
41
|
+
"@vuepress/plugin-palette": "2.0.0-beta.32",
|
|
42
|
+
"@vuepress/plugin-prismjs": "2.0.0-beta.32",
|
|
43
|
+
"@vuepress/plugin-theme-data": "2.0.0-beta.32",
|
|
44
|
+
"@vuepress/shared": "2.0.0-beta.32",
|
|
45
|
+
"@vuepress/utils": "2.0.0-beta.32",
|
|
45
46
|
"@vueuse/core": "^7.1.2",
|
|
46
47
|
"sass": "^1.44.0",
|
|
47
48
|
"sass-loader": "^12.4.0",
|
|
@@ -51,5 +52,5 @@
|
|
|
51
52
|
"publishConfig": {
|
|
52
53
|
"access": "public"
|
|
53
54
|
},
|
|
54
|
-
"gitHead": "
|
|
55
|
+
"gitHead": "8ffa71313607fe78f3956e3ccb886fcae0ddf5e9"
|
|
55
56
|
}
|
|
@@ -1,76 +0,0 @@
|
|
|
1
|
-
import { h } from 'vue';
|
|
2
|
-
import { useRoute } from 'vue-router';
|
|
3
|
-
import NavLink from './NavLink.vue';
|
|
4
|
-
const normalizePath = (path) => decodeURI(path)
|
|
5
|
-
.replace(/#.*$/, '')
|
|
6
|
-
.replace(/(index)?\.(md|html)$/, '');
|
|
7
|
-
const isActiveLink = (route, link) => {
|
|
8
|
-
if (link === undefined) {
|
|
9
|
-
return false;
|
|
10
|
-
}
|
|
11
|
-
if (route.hash === link) {
|
|
12
|
-
return true;
|
|
13
|
-
}
|
|
14
|
-
const currentPath = normalizePath(route.path);
|
|
15
|
-
const targetPath = normalizePath(link);
|
|
16
|
-
return currentPath === targetPath;
|
|
17
|
-
};
|
|
18
|
-
const isActiveItem = (route, item) => {
|
|
19
|
-
if (isActiveLink(route, item.link)) {
|
|
20
|
-
return true;
|
|
21
|
-
}
|
|
22
|
-
if (item.children) {
|
|
23
|
-
return item.children.some((child) => isActiveItem(route, child));
|
|
24
|
-
}
|
|
25
|
-
return false;
|
|
26
|
-
};
|
|
27
|
-
const renderItem = (item, props) => {
|
|
28
|
-
// if the item has link, render it as `<NavLink>`
|
|
29
|
-
if (item.link) {
|
|
30
|
-
return h(NavLink, {
|
|
31
|
-
...props,
|
|
32
|
-
item,
|
|
33
|
-
});
|
|
34
|
-
}
|
|
35
|
-
// if the item only has text, render it as `<p>`
|
|
36
|
-
return h('p', props, item.text);
|
|
37
|
-
};
|
|
38
|
-
const renderChildren = (item, depth) => {
|
|
39
|
-
var _a;
|
|
40
|
-
if (!((_a = item.children) === null || _a === void 0 ? void 0 : _a.length)) {
|
|
41
|
-
return null;
|
|
42
|
-
}
|
|
43
|
-
return h('ul', {
|
|
44
|
-
class: {
|
|
45
|
-
'sidebar-sub-items': depth > 0,
|
|
46
|
-
},
|
|
47
|
-
}, item.children.map((child) => h('li', h(SidebarChild, {
|
|
48
|
-
item: child,
|
|
49
|
-
depth: depth + 1,
|
|
50
|
-
}))));
|
|
51
|
-
};
|
|
52
|
-
export const SidebarChild = ({ item, depth = 0 }) => {
|
|
53
|
-
const route = useRoute();
|
|
54
|
-
const active = isActiveItem(route, item);
|
|
55
|
-
return [
|
|
56
|
-
renderItem(item, {
|
|
57
|
-
class: {
|
|
58
|
-
'sidebar-heading': depth === 0,
|
|
59
|
-
'sidebar-item': true,
|
|
60
|
-
active,
|
|
61
|
-
},
|
|
62
|
-
}),
|
|
63
|
-
renderChildren(item, depth),
|
|
64
|
-
];
|
|
65
|
-
};
|
|
66
|
-
SidebarChild.displayName = 'SidebarChild';
|
|
67
|
-
SidebarChild.props = {
|
|
68
|
-
item: {
|
|
69
|
-
type: Object,
|
|
70
|
-
required: true,
|
|
71
|
-
},
|
|
72
|
-
depth: {
|
|
73
|
-
type: Number,
|
|
74
|
-
required: false,
|
|
75
|
-
},
|
|
76
|
-
};
|