@vuepress/theme-default 2.0.0-beta.41 → 2.0.0-beta.42
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/global/CodeGroup.js +1 -2
- package/lib/client/composables/useDarkMode.js +2 -2
- package/lib/client/composables/useResolveRouteWithRedirect.js +1 -1
- package/lib/client/composables/useScrollPromise.js +1 -1
- package/lib/client/composables/useSidebarItems.js +4 -7
- package/lib/node/defaultTheme.js +7 -9
- package/lib/node/utils/resolveContainerPluginOptions.js +1 -2
- package/package.json +15 -15
|
@@ -52,9 +52,8 @@ export default defineComponent({
|
|
|
52
52
|
// NOTICE: here we put the `slots.default()` inside the render function to make
|
|
53
53
|
// the slots reactive, otherwise the slot content won't be changed once the
|
|
54
54
|
// `setup()` function of current component is called
|
|
55
|
-
var _a;
|
|
56
55
|
// get children code-group-item
|
|
57
|
-
const items = (
|
|
56
|
+
const items = (slots.default?.() || [])
|
|
58
57
|
.filter((vnode) => vnode.type.name === 'CodeGroupItem')
|
|
59
58
|
.map((vnode) => {
|
|
60
59
|
if (vnode.props === null) {
|
|
@@ -47,8 +47,8 @@ export const setupDarkMode = () => {
|
|
|
47
47
|
export const updateHtmlDarkClass = (isDarkMode) => {
|
|
48
48
|
const update = (value = isDarkMode.value) => {
|
|
49
49
|
// set `class="dark"` on `<html>` element
|
|
50
|
-
const htmlEl = window
|
|
51
|
-
htmlEl
|
|
50
|
+
const htmlEl = window?.document.querySelector('html');
|
|
51
|
+
htmlEl?.classList.toggle('dark', value);
|
|
52
52
|
};
|
|
53
53
|
onMounted(() => {
|
|
54
54
|
watch(isDarkMode, update, { immediate: true });
|
|
@@ -7,7 +7,7 @@ export const useResolveRouteWithRedirect = (...args) => {
|
|
|
7
7
|
const router = useRouter();
|
|
8
8
|
const route = router.resolve(...args);
|
|
9
9
|
const lastMatched = route.matched[route.matched.length - 1];
|
|
10
|
-
if (!
|
|
10
|
+
if (!lastMatched?.redirect) {
|
|
11
11
|
return route;
|
|
12
12
|
}
|
|
13
13
|
const { redirect } = lastMatched;
|
|
@@ -6,7 +6,7 @@ const scrollPromise = {
|
|
|
6
6
|
promise = new Promise((resolve) => (promiseResolve = resolve));
|
|
7
7
|
},
|
|
8
8
|
resolve: () => {
|
|
9
|
-
promiseResolve
|
|
9
|
+
promiseResolve?.();
|
|
10
10
|
promise = null;
|
|
11
11
|
promiseResolve = null;
|
|
12
12
|
},
|
|
@@ -29,10 +29,9 @@ export const setupSidebarItems = () => {
|
|
|
29
29
|
* It should only be resolved and provided once
|
|
30
30
|
*/
|
|
31
31
|
export const resolveSidebarItems = (frontmatter, themeLocale) => {
|
|
32
|
-
var _a, _b, _c, _d;
|
|
33
32
|
// get sidebar config from frontmatter > theme data
|
|
34
|
-
const sidebarConfig =
|
|
35
|
-
const sidebarDepth =
|
|
33
|
+
const sidebarConfig = frontmatter.sidebar ?? themeLocale.sidebar ?? 'auto';
|
|
34
|
+
const sidebarDepth = frontmatter.sidebarDepth ?? themeLocale.sidebarDepth ?? 2;
|
|
36
35
|
// resolve sidebar items according to the config
|
|
37
36
|
if (frontmatter.home || sidebarConfig === false) {
|
|
38
37
|
return [];
|
|
@@ -78,7 +77,6 @@ export const resolveArraySidebarItems = (sidebarConfig, sidebarDepth) => {
|
|
|
78
77
|
const route = useRoute();
|
|
79
78
|
const page = usePageData();
|
|
80
79
|
const handleChildItem = (item) => {
|
|
81
|
-
var _a;
|
|
82
80
|
let childItem;
|
|
83
81
|
if (isString(item)) {
|
|
84
82
|
childItem = useNavLink(item);
|
|
@@ -96,7 +94,7 @@ export const resolveArraySidebarItems = (sidebarConfig, sidebarDepth) => {
|
|
|
96
94
|
// use headers of current page as children
|
|
97
95
|
if (childItem.link === route.path) {
|
|
98
96
|
// skip h1 header
|
|
99
|
-
const headers =
|
|
97
|
+
const headers = page.value.headers[0]?.level === 1
|
|
100
98
|
? page.value.headers[0].children
|
|
101
99
|
: page.value.headers;
|
|
102
100
|
return {
|
|
@@ -112,9 +110,8 @@ export const resolveArraySidebarItems = (sidebarConfig, sidebarDepth) => {
|
|
|
112
110
|
* Resolve sidebar items if the config is a key -> value (path-prefix -> array) object
|
|
113
111
|
*/
|
|
114
112
|
export const resolveMultiSidebarItems = (sidebarConfig, sidebarDepth) => {
|
|
115
|
-
var _a;
|
|
116
113
|
const route = useRoute();
|
|
117
114
|
const sidebarPath = resolveLocalePath(sidebarConfig, route.path);
|
|
118
|
-
const matchedSidebarConfig =
|
|
115
|
+
const matchedSidebarConfig = sidebarConfig[sidebarPath] ?? [];
|
|
119
116
|
return resolveArraySidebarItems(matchedSidebarConfig, sidebarDepth);
|
|
120
117
|
};
|
package/lib/node/defaultTheme.js
CHANGED
|
@@ -14,7 +14,6 @@ const plugin_theme_data_1 = require("@vuepress/plugin-theme-data");
|
|
|
14
14
|
const utils_1 = require("@vuepress/utils");
|
|
15
15
|
const utils_2 = require("./utils");
|
|
16
16
|
const defaultTheme = ({ themePlugins = {}, ...localeOptions } = {}) => {
|
|
17
|
-
var _a, _b, _c, _d, _e, _f;
|
|
18
17
|
(0, utils_2.assignDefaultLocaleOptions)(localeOptions);
|
|
19
18
|
return {
|
|
20
19
|
name: '@vuepress/theme-default',
|
|
@@ -49,30 +48,30 @@ const defaultTheme = ({ themePlugins = {}, ...localeOptions } = {}) => {
|
|
|
49
48
|
// @vuepress/plugin-back-to-top
|
|
50
49
|
themePlugins.backToTop !== false ? (0, plugin_back_to_top_1.backToTopPlugin)() : [],
|
|
51
50
|
// @vuepress/plugin-container
|
|
52
|
-
|
|
51
|
+
themePlugins.container?.tip !== false
|
|
53
52
|
? (0, plugin_container_1.containerPlugin)((0, utils_2.resolveContainerPluginOptions)(localeOptions, 'tip'))
|
|
54
53
|
: [],
|
|
55
|
-
|
|
54
|
+
themePlugins.container?.warning !== false
|
|
56
55
|
? (0, plugin_container_1.containerPlugin)((0, utils_2.resolveContainerPluginOptions)(localeOptions, 'warning'))
|
|
57
56
|
: [],
|
|
58
|
-
|
|
57
|
+
themePlugins.container?.danger !== false
|
|
59
58
|
? (0, plugin_container_1.containerPlugin)((0, utils_2.resolveContainerPluginOptions)(localeOptions, 'danger'))
|
|
60
59
|
: [],
|
|
61
|
-
|
|
60
|
+
themePlugins.container?.details !== false
|
|
62
61
|
? (0, plugin_container_1.containerPlugin)({
|
|
63
62
|
type: 'details',
|
|
64
63
|
before: (info) => `<details class="custom-container details">${info ? `<summary>${info}</summary>` : ''}\n`,
|
|
65
64
|
after: () => '</details>\n',
|
|
66
65
|
})
|
|
67
66
|
: [],
|
|
68
|
-
|
|
67
|
+
themePlugins.container?.codeGroup !== false
|
|
69
68
|
? (0, plugin_container_1.containerPlugin)({
|
|
70
69
|
type: 'code-group',
|
|
71
70
|
before: () => `<CodeGroup>\n`,
|
|
72
71
|
after: () => '</CodeGroup>\n',
|
|
73
72
|
})
|
|
74
73
|
: [],
|
|
75
|
-
|
|
74
|
+
themePlugins.container?.codeGroupItem !== false
|
|
76
75
|
? (0, plugin_container_1.containerPlugin)({
|
|
77
76
|
type: 'code-group-item',
|
|
78
77
|
before: (info) => `<CodeGroupItem title="${info}">\n`,
|
|
@@ -83,9 +82,8 @@ const defaultTheme = ({ themePlugins = {}, ...localeOptions } = {}) => {
|
|
|
83
82
|
themePlugins.externalLinkIcon !== false
|
|
84
83
|
? (0, plugin_external_link_icon_1.externalLinkIconPlugin)({
|
|
85
84
|
locales: Object.entries(localeOptions.locales || {}).reduce((result, [key, value]) => {
|
|
86
|
-
var _a;
|
|
87
85
|
result[key] = {
|
|
88
|
-
openInNewWindow:
|
|
86
|
+
openInNewWindow: value.openInNewWindow ?? localeOptions.openInNewWindow,
|
|
89
87
|
};
|
|
90
88
|
return result;
|
|
91
89
|
}, {}),
|
|
@@ -8,9 +8,8 @@ exports.resolveContainerPluginOptions = void 0;
|
|
|
8
8
|
*/
|
|
9
9
|
const resolveContainerPluginOptions = (localeOptions, type) => {
|
|
10
10
|
const locales = Object.entries(localeOptions.locales || {}).reduce((result, [key, value]) => {
|
|
11
|
-
var _a;
|
|
12
11
|
result[key] = {
|
|
13
|
-
defaultInfo:
|
|
12
|
+
defaultInfo: value?.[type] ?? localeOptions[type],
|
|
14
13
|
};
|
|
15
14
|
return result;
|
|
16
15
|
}, {});
|
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.42",
|
|
4
4
|
"description": "Default theme of VuePress",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"vuepress-theme",
|
|
@@ -25,20 +25,20 @@
|
|
|
25
25
|
"templates"
|
|
26
26
|
],
|
|
27
27
|
"dependencies": {
|
|
28
|
-
"@vuepress/client": "2.0.0-beta.
|
|
29
|
-
"@vuepress/core": "2.0.0-beta.
|
|
30
|
-
"@vuepress/plugin-active-header-links": "2.0.0-beta.
|
|
31
|
-
"@vuepress/plugin-back-to-top": "2.0.0-beta.
|
|
32
|
-
"@vuepress/plugin-container": "2.0.0-beta.
|
|
33
|
-
"@vuepress/plugin-external-link-icon": "2.0.0-beta.
|
|
34
|
-
"@vuepress/plugin-git": "2.0.0-beta.
|
|
35
|
-
"@vuepress/plugin-medium-zoom": "2.0.0-beta.
|
|
36
|
-
"@vuepress/plugin-nprogress": "2.0.0-beta.
|
|
37
|
-
"@vuepress/plugin-palette": "2.0.0-beta.
|
|
38
|
-
"@vuepress/plugin-prismjs": "2.0.0-beta.
|
|
39
|
-
"@vuepress/plugin-theme-data": "2.0.0-beta.
|
|
40
|
-
"@vuepress/shared": "2.0.0-beta.
|
|
41
|
-
"@vuepress/utils": "2.0.0-beta.
|
|
28
|
+
"@vuepress/client": "2.0.0-beta.42",
|
|
29
|
+
"@vuepress/core": "2.0.0-beta.42",
|
|
30
|
+
"@vuepress/plugin-active-header-links": "2.0.0-beta.42",
|
|
31
|
+
"@vuepress/plugin-back-to-top": "2.0.0-beta.42",
|
|
32
|
+
"@vuepress/plugin-container": "2.0.0-beta.42",
|
|
33
|
+
"@vuepress/plugin-external-link-icon": "2.0.0-beta.42",
|
|
34
|
+
"@vuepress/plugin-git": "2.0.0-beta.42",
|
|
35
|
+
"@vuepress/plugin-medium-zoom": "2.0.0-beta.42",
|
|
36
|
+
"@vuepress/plugin-nprogress": "2.0.0-beta.42",
|
|
37
|
+
"@vuepress/plugin-palette": "2.0.0-beta.42",
|
|
38
|
+
"@vuepress/plugin-prismjs": "2.0.0-beta.42",
|
|
39
|
+
"@vuepress/plugin-theme-data": "2.0.0-beta.42",
|
|
40
|
+
"@vuepress/shared": "2.0.0-beta.42",
|
|
41
|
+
"@vuepress/utils": "2.0.0-beta.42",
|
|
42
42
|
"@vueuse/core": "^8.2.1",
|
|
43
43
|
"sass": "^1.49.10",
|
|
44
44
|
"vue": "^3.2.33",
|