@vuepress/theme-default 2.0.0-rc.4 → 2.0.0-rc.40
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/VPDarkIcon.vue +8 -0
- package/lib/client/components/{DropdownTransition.vue → VPDropdownTransition.vue} +10 -1
- package/lib/client/components/VPEditIcon.vue +12 -0
- package/lib/client/components/VPHome.vue +38 -0
- package/lib/client/components/VPHomeFeatures.vue +68 -0
- package/lib/client/components/{HomeFooter.vue → VPHomeFooter.vue} +16 -2
- package/lib/client/components/{HomeHero.vue → VPHomeHero.vue} +108 -7
- package/lib/client/components/VPLightIcon.vue +28 -0
- package/lib/client/components/VPNavbar.vue +125 -0
- package/lib/client/components/{NavbarBrand.vue → VPNavbarBrand.vue} +39 -6
- package/lib/client/components/VPNavbarDropdown.vue +320 -0
- package/lib/client/components/VPNavbarItems.vue +110 -0
- package/lib/client/components/VPPage.vue +69 -0
- package/lib/client/components/VPPageMeta.vue +132 -0
- package/lib/client/components/VPPageNav.vue +118 -0
- package/lib/client/components/VPSidebar.vue +112 -0
- package/lib/client/components/VPSidebarItem.vue +167 -0
- package/lib/client/components/{SidebarItems.vue → VPSidebarItems.vue} +31 -7
- package/lib/client/components/VPToggleColorModeButton.vue +54 -0
- package/lib/client/components/VPToggleSidebarButton.vue +92 -0
- package/lib/client/components/global/Badge.vue +60 -18
- package/lib/client/components/global/CodeGroup.d.ts +1 -0
- package/lib/client/components/global/CodeGroup.js +4 -3
- package/lib/client/components/global/CodeGroupItem.vue +5 -16
- package/lib/client/composables/index.d.ts +8 -0
- package/lib/client/composables/index.js +8 -0
- package/lib/client/composables/useContributors.d.ts +3 -0
- package/lib/client/composables/useContributors.js +14 -0
- package/lib/client/composables/useDarkMode.d.ts +0 -1
- package/lib/client/composables/useDarkMode.js +14 -13
- package/lib/client/composables/useEditLink.d.ts +3 -0
- package/lib/client/composables/useEditLink.js +31 -0
- package/lib/client/composables/useLastUpdated.d.ts +2 -0
- package/lib/client/composables/useLastUpdated.js +17 -0
- package/lib/client/composables/useNavbarConfig.d.ts +3 -0
- package/lib/client/composables/useNavbarConfig.js +25 -0
- package/lib/client/composables/useNavbarRepo.d.ts +6 -0
- package/lib/client/composables/useNavbarRepo.js +38 -0
- package/lib/client/composables/useNavbarSelectLanguage.d.ts +6 -0
- package/lib/client/composables/useNavbarSelectLanguage.js +58 -0
- package/lib/client/composables/useNavigate.d.ts +1 -0
- package/lib/client/composables/useNavigate.js +22 -0
- package/lib/client/composables/useRelatedLinks.d.ts +8 -0
- package/lib/client/composables/useRelatedLinks.js +91 -0
- package/lib/client/composables/useSidebarItems.d.ts +17 -12
- package/lib/client/composables/useSidebarItems.js +87 -52
- package/lib/client/composables/useUpdateDeviceStatus.js +5 -4
- package/lib/client/config.d.ts +2 -2
- package/lib/client/config.js +12 -13
- package/lib/client/index.d.ts +2 -1
- package/lib/client/index.js +1 -1
- package/lib/client/layouts/Layout.vue +121 -20
- package/lib/client/layouts/NotFound.vue +18 -4
- package/lib/client/shim.d.ts +3 -3
- package/lib/client/styles/_mixins.scss +4 -4
- package/lib/client/styles/_variables.module.scss +1 -1
- package/lib/client/styles/_variables.scss +1 -0
- package/lib/client/styles/arrow.scss +18 -24
- package/lib/client/styles/code-group.scss +32 -29
- package/lib/client/styles/content/code.scss +23 -0
- package/lib/client/styles/{custom-container.scss → content/custom-container.scss} +13 -13
- package/lib/client/styles/content/index.scss +4 -0
- package/lib/client/styles/content/normalize.scss +39 -0
- package/lib/client/styles/{toc.scss → content/toc.scss} +1 -1
- package/lib/client/styles/external-link-icon.scss +37 -0
- package/lib/client/styles/index.scss +3 -13
- package/lib/client/styles/layout.scss +3 -199
- package/lib/client/styles/normalize.scss +20 -148
- package/lib/client/styles/plugins.scss +20 -0
- package/lib/client/styles/vars-dark.scss +17 -12
- package/lib/client/styles/vars.scss +71 -33
- package/lib/client/typings.d.ts +13 -0
- package/lib/client/typings.js +1 -0
- package/lib/client/utils/getAutoLink.d.ts +9 -0
- package/lib/client/utils/getAutoLink.js +17 -0
- package/lib/client/utils/index.d.ts +3 -2
- package/lib/client/utils/index.js +3 -2
- package/lib/client/utils/isActiveSidebarItem.d.ts +3 -3
- package/lib/client/utils/isActiveSidebarItem.js +3 -3
- package/lib/client/utils/isLinkInternal.d.ts +1 -0
- package/lib/client/utils/isLinkInternal.js +2 -0
- package/lib/client/utils/resolveEditLink.d.ts +1 -1
- package/lib/client/utils/resolvePrefix.d.ts +1 -0
- package/lib/client/utils/resolvePrefix.js +4 -0
- package/lib/node/defaultTheme.js +83 -24
- package/lib/node/index.d.ts +2 -1
- package/lib/node/index.js +1 -1
- package/lib/node/utils/assignDefaultLocaleOptions.js +1 -1
- package/lib/node/utils/resolveContainerPluginOptions.d.ts +3 -3
- package/lib/node/utils/resolveContainerPluginOptions.js +2 -2
- package/lib/shared/index.d.ts +2 -0
- package/lib/shared/index.js +2 -0
- package/lib/shared/nav.d.ts +19 -30
- package/lib/shared/navbar.d.ts +21 -0
- package/lib/shared/navbar.js +1 -0
- package/lib/shared/options.d.ts +31 -8
- package/lib/shared/page.d.ts +6 -4
- package/lib/shared/sidebar.d.ts +26 -0
- package/lib/shared/sidebar.js +1 -0
- package/package.json +22 -26
- package/templates/build.html +19 -10
- package/lib/client/components/AutoLink.vue +0 -113
- package/lib/client/components/Home.vue +0 -15
- package/lib/client/components/HomeContent.vue +0 -5
- package/lib/client/components/HomeFeatures.vue +0 -22
- package/lib/client/components/Navbar.vue +0 -79
- package/lib/client/components/NavbarDropdown.vue +0 -126
- package/lib/client/components/NavbarItems.vue +0 -199
- package/lib/client/components/Page.vue +0 -31
- package/lib/client/components/PageMeta.vue +0 -124
- package/lib/client/components/PageNav.vue +0 -122
- package/lib/client/components/Sidebar.vue +0 -18
- package/lib/client/components/SidebarItem.vue +0 -87
- package/lib/client/components/ToggleColorModeButton.vue +0 -57
- package/lib/client/components/ToggleSidebarButton.vue +0 -24
- package/lib/client/styles/badge.scss +0 -36
- package/lib/client/styles/code.scss +0 -263
- package/lib/client/styles/home.scss +0 -168
- package/lib/client/styles/navbar-dropdown.scss +0 -183
- package/lib/client/styles/navbar.scss +0 -197
- package/lib/client/styles/page.scss +0 -87
- package/lib/client/styles/sidebar.scss +0 -134
- package/lib/client/styles/transitions.scss +0 -22
- package/lib/client/utils/getNavLink.d.ts +0 -15
- package/lib/client/utils/getNavLink.js +0 -18
- package/lib/client/utils/getResolveRouteWithRedirect.d.ts +0 -5
- package/lib/client/utils/getResolveRouteWithRedirect.js +0 -22
|
@@ -1,9 +1,37 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
1
|
+
import { useThemeLocaleData } from '@theme/useThemeData';
|
|
2
|
+
import { getHeaders, keys, startsWith } from '@vuepress/helper/client';
|
|
3
|
+
import { computed, inject, onMounted, provide, ref, watch } from 'vue';
|
|
4
|
+
import { usePageData, usePageFrontmatter, useRoute, useRouteLocale, useRouter, } from 'vuepress/client';
|
|
5
|
+
import { isPlainObject, isString } from 'vuepress/shared';
|
|
6
|
+
import { getAutoLink, isLinkInternal, resolvePrefix } from '../utils/index.js';
|
|
7
|
+
export const headersRef = ref([]);
|
|
8
|
+
export const setupHeaders = () => {
|
|
9
|
+
const router = useRouter();
|
|
10
|
+
const themeLocale = useThemeLocaleData();
|
|
11
|
+
const frontmatter = usePageFrontmatter();
|
|
12
|
+
const levels = computed(() => frontmatter.value.sidebarDepth ?? themeLocale.value.sidebarDepth ?? 2);
|
|
13
|
+
router.beforeEach((to, from) => {
|
|
14
|
+
if (to.path !== from.path) {
|
|
15
|
+
headersRef.value = [];
|
|
16
|
+
}
|
|
17
|
+
});
|
|
18
|
+
const updateHeaders = () => {
|
|
19
|
+
if (levels.value <= 0) {
|
|
20
|
+
headersRef.value = [];
|
|
21
|
+
return;
|
|
22
|
+
}
|
|
23
|
+
headersRef.value = getHeaders({
|
|
24
|
+
selector: [...new Array(6)]
|
|
25
|
+
.map((_, i) => `.theme-default-content h${i + 1}`)
|
|
26
|
+
.join(','),
|
|
27
|
+
levels: [2, levels.value + 1],
|
|
28
|
+
ignore: ['.vp-badge'],
|
|
29
|
+
});
|
|
30
|
+
};
|
|
31
|
+
watch(levels, updateHeaders);
|
|
32
|
+
onMounted(updateHeaders);
|
|
33
|
+
};
|
|
34
|
+
export const useHeaders = () => headersRef;
|
|
7
35
|
export const sidebarItemsSymbol = Symbol('sidebarItems');
|
|
8
36
|
/**
|
|
9
37
|
* Inject sidebar items global computed
|
|
@@ -23,8 +51,12 @@ export const setupSidebarItems = () => {
|
|
|
23
51
|
const frontmatter = usePageFrontmatter();
|
|
24
52
|
const page = usePageData();
|
|
25
53
|
const route = useRoute();
|
|
26
|
-
const
|
|
27
|
-
const
|
|
54
|
+
const routeLocale = useRouteLocale();
|
|
55
|
+
const headers = useHeaders();
|
|
56
|
+
const sidebarConfig = computed(() => frontmatter.value.home
|
|
57
|
+
? false
|
|
58
|
+
: (frontmatter.value.sidebar ?? themeLocale.value.sidebar ?? 'heading'));
|
|
59
|
+
const sidebarItems = computed(() => resolveSidebarItems(sidebarConfig.value, page.value, route.path, routeLocale.value, headers.value));
|
|
28
60
|
provide(sidebarItemsSymbol, sidebarItems);
|
|
29
61
|
};
|
|
30
62
|
/**
|
|
@@ -32,87 +64,90 @@ export const setupSidebarItems = () => {
|
|
|
32
64
|
*
|
|
33
65
|
* It should only be resolved and provided once
|
|
34
66
|
*/
|
|
35
|
-
export const resolveSidebarItems = (
|
|
36
|
-
// get sidebar config from frontmatter > theme data
|
|
37
|
-
const sidebarConfig = frontmatter.sidebar ?? themeLocale.sidebar ?? 'auto';
|
|
38
|
-
const sidebarDepth = frontmatter.sidebarDepth ?? themeLocale.sidebarDepth ?? 2;
|
|
67
|
+
export const resolveSidebarItems = (sidebarConfig, page, path, routeLocale, headers) => {
|
|
39
68
|
// resolve sidebar items according to the config
|
|
40
|
-
if (
|
|
69
|
+
if (sidebarConfig === false) {
|
|
41
70
|
return [];
|
|
42
71
|
}
|
|
43
|
-
if (sidebarConfig === '
|
|
44
|
-
return
|
|
72
|
+
if (sidebarConfig === 'heading') {
|
|
73
|
+
return resolveSidebarHeadingItem(page, headers);
|
|
45
74
|
}
|
|
46
75
|
if (Array.isArray(sidebarConfig)) {
|
|
47
|
-
return resolveArraySidebarItems(
|
|
76
|
+
return resolveArraySidebarItems(sidebarConfig, headers, path, routeLocale);
|
|
48
77
|
}
|
|
49
78
|
if (isPlainObject(sidebarConfig)) {
|
|
50
|
-
return resolveMultiSidebarItems(page,
|
|
79
|
+
return resolveMultiSidebarItems(sidebarConfig, page, headers, path);
|
|
51
80
|
}
|
|
52
81
|
return [];
|
|
53
82
|
};
|
|
54
83
|
/**
|
|
55
84
|
* Util to transform page header to sidebar item
|
|
56
85
|
*/
|
|
57
|
-
export const
|
|
86
|
+
export const resolveSidebarHeaderItem = (header) => ({
|
|
58
87
|
text: header.title,
|
|
59
88
|
link: header.link,
|
|
60
|
-
children:
|
|
89
|
+
children: resolveSidebarHeaderItems(header.children),
|
|
61
90
|
});
|
|
62
|
-
export const
|
|
63
|
-
? headers.map((header) => headerToSidebarItem(header, sidebarDepth - 1))
|
|
64
|
-
: [];
|
|
91
|
+
export const resolveSidebarHeaderItems = (headers) => headers ? headers.map((header) => resolveSidebarHeaderItem(header)) : [];
|
|
65
92
|
/**
|
|
66
|
-
* Resolve sidebar items if the config is `
|
|
93
|
+
* Resolve current page and its header to sidebar items if the config is `heading`
|
|
67
94
|
*/
|
|
68
|
-
export const
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
];
|
|
75
|
-
};
|
|
95
|
+
export const resolveSidebarHeadingItem = (page, headers) => [
|
|
96
|
+
{
|
|
97
|
+
text: page.title,
|
|
98
|
+
children: resolveSidebarHeaderItems(headers),
|
|
99
|
+
},
|
|
100
|
+
];
|
|
76
101
|
/**
|
|
77
102
|
* Resolve sidebar items if the config is an array
|
|
78
103
|
*/
|
|
79
|
-
export const resolveArraySidebarItems = (
|
|
80
|
-
const handleChildItem = (item) => {
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
104
|
+
export const resolveArraySidebarItems = (sidebarConfig, headers, path, prefix = '') => {
|
|
105
|
+
const handleChildItem = (item, pathPrefix) => {
|
|
106
|
+
const childItem = isString(item)
|
|
107
|
+
? getAutoLink(resolvePrefix(pathPrefix, item))
|
|
108
|
+
: isString(item.link)
|
|
109
|
+
? {
|
|
110
|
+
...item,
|
|
111
|
+
link: isLinkInternal(item.link)
|
|
112
|
+
? getAutoLink(resolvePrefix(pathPrefix, item.link)).link
|
|
113
|
+
: item.link,
|
|
114
|
+
}
|
|
115
|
+
: item;
|
|
116
|
+
if ('children' in childItem) {
|
|
89
117
|
return {
|
|
90
118
|
...childItem,
|
|
91
|
-
children: childItem.children.map((item) => handleChildItem(item)),
|
|
119
|
+
children: childItem.children.map((item) => handleChildItem(item, resolvePrefix(pathPrefix, childItem.prefix))),
|
|
92
120
|
};
|
|
93
121
|
}
|
|
94
122
|
// if the sidebar item is current page and children is not set
|
|
95
123
|
// use headers of current page as children
|
|
96
124
|
if (childItem.link === path) {
|
|
97
125
|
// skip h1 header
|
|
98
|
-
const
|
|
126
|
+
const currentHeaders = headers[0]?.level === 1 ? headers[0].children : headers;
|
|
99
127
|
return {
|
|
100
128
|
...childItem,
|
|
101
|
-
children:
|
|
129
|
+
children: resolveSidebarHeaderItems(currentHeaders),
|
|
102
130
|
};
|
|
103
131
|
}
|
|
104
132
|
return childItem;
|
|
105
133
|
};
|
|
106
|
-
return sidebarConfig.map((item) => handleChildItem(item));
|
|
134
|
+
return sidebarConfig.map((item) => handleChildItem(item, prefix));
|
|
107
135
|
};
|
|
108
136
|
/**
|
|
109
137
|
* Resolve sidebar items if the config is a key -> value (path-prefix -> array) object
|
|
110
138
|
*/
|
|
111
|
-
export const resolveMultiSidebarItems = (page,
|
|
112
|
-
const
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
139
|
+
export const resolveMultiSidebarItems = (sidebarConfig, page, headers, path) => {
|
|
140
|
+
const sidebarRoutes = keys(sidebarConfig).sort((x, y) => y.length - x.length);
|
|
141
|
+
// Find matching config
|
|
142
|
+
for (const base of sidebarRoutes)
|
|
143
|
+
if (startsWith(decodeURI(path), base)) {
|
|
144
|
+
const matched = sidebarConfig[base];
|
|
145
|
+
return matched
|
|
146
|
+
? matched === 'heading'
|
|
147
|
+
? resolveSidebarHeadingItem(page, headers)
|
|
148
|
+
: resolveArraySidebarItems(matched, headers, path, base)
|
|
149
|
+
: [];
|
|
150
|
+
}
|
|
151
|
+
console.warn(`${decodeURI(path)} is missing sidebar config.`);
|
|
152
|
+
return [];
|
|
118
153
|
};
|
|
@@ -1,11 +1,12 @@
|
|
|
1
|
+
import { useEventListener } from '@vueuse/core';
|
|
1
2
|
import { onMounted } from 'vue';
|
|
2
|
-
import
|
|
3
|
+
import cssVariables from '../styles/_variables.module.scss';
|
|
3
4
|
export var DeviceType;
|
|
4
5
|
(function (DeviceType) {
|
|
5
6
|
DeviceType["MOBILE"] = "mobile";
|
|
6
7
|
})(DeviceType || (DeviceType = {}));
|
|
7
8
|
const DeviceTypeMap = {
|
|
8
|
-
[DeviceType.MOBILE]: Number.parseInt(
|
|
9
|
+
[DeviceType.MOBILE]: Number.parseInt(cssVariables.mobile.replace('px', ''), 10),
|
|
9
10
|
};
|
|
10
11
|
/**
|
|
11
12
|
* add listener to detect screen though device type
|
|
@@ -17,9 +18,9 @@ export const useUpdateDeviceStatus = (deviceType, callback) => {
|
|
|
17
18
|
throw new Error('device width must be a integer');
|
|
18
19
|
return;
|
|
19
20
|
}
|
|
21
|
+
useEventListener('orientationchange', () => callback(width), false);
|
|
22
|
+
useEventListener('resize', () => callback(width), false);
|
|
20
23
|
onMounted(() => {
|
|
21
24
|
callback(width);
|
|
22
|
-
window.addEventListener('resize', () => callback(width), false);
|
|
23
|
-
window.addEventListener('orientationchange', () => callback(width), false);
|
|
24
25
|
});
|
|
25
26
|
};
|
package/lib/client/config.d.ts
CHANGED
package/lib/client/config.js
CHANGED
|
@@ -1,25 +1,24 @@
|
|
|
1
|
+
import { setupDarkMode } from '@theme/useDarkMode';
|
|
2
|
+
import { useScrollPromise } from '@theme/useScrollPromise';
|
|
3
|
+
import { setupSidebarItems } from '@theme/useSidebarItems';
|
|
4
|
+
import { hasGlobalComponent } from '@vuepress/helper/client';
|
|
1
5
|
import { h } from 'vue';
|
|
2
6
|
import { defineClientConfig } from 'vuepress/client';
|
|
3
7
|
import { Badge, CodeGroup, CodeGroupItem } from './components/global/index.js';
|
|
4
|
-
import { setupDarkMode, setupSidebarItems, useScrollPromise, } from './composables/index.js';
|
|
5
8
|
import Layout from './layouts/Layout.vue';
|
|
6
9
|
import NotFound from './layouts/NotFound.vue';
|
|
10
|
+
import '@vuepress/helper/normalize.css';
|
|
7
11
|
import './styles/index.scss';
|
|
8
12
|
export default defineClientConfig({
|
|
9
13
|
enhance({ app, router }) {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
if (ExternalLinkIcon) {
|
|
17
|
-
return h(ExternalLinkIcon);
|
|
18
|
-
}
|
|
19
|
-
return null;
|
|
20
|
-
});
|
|
14
|
+
if (!hasGlobalComponent('Badge'))
|
|
15
|
+
app.component('Badge', Badge);
|
|
16
|
+
if (!hasGlobalComponent('CodeGroup'))
|
|
17
|
+
app.component('CodeGroup', CodeGroup);
|
|
18
|
+
if (!hasGlobalComponent('CodeGroupItem'))
|
|
19
|
+
app.component('CodeGroupItem', CodeGroupItem);
|
|
21
20
|
// compat with @vuepress/plugin-docsearch and @vuepress/plugin-search
|
|
22
|
-
app.component('
|
|
21
|
+
app.component('VPSearch', () => {
|
|
23
22
|
const SearchComponent = app.component('Docsearch') || app.component('SearchBox');
|
|
24
23
|
if (SearchComponent) {
|
|
25
24
|
return h(SearchComponent);
|
package/lib/client/index.d.ts
CHANGED
package/lib/client/index.js
CHANGED
|
@@ -1,17 +1,14 @@
|
|
|
1
1
|
<script setup lang="ts">
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
import
|
|
2
|
+
import { useScrollPromise } from '@theme/useScrollPromise'
|
|
3
|
+
import { useSidebarItems } from '@theme/useSidebarItems'
|
|
4
|
+
import { useThemeLocaleData } from '@theme/useThemeData'
|
|
5
|
+
import VPHome from '@theme/VPHome.vue'
|
|
6
|
+
import VPNavbar from '@theme/VPNavbar.vue'
|
|
7
|
+
import VPPage from '@theme/VPPage.vue'
|
|
8
|
+
import VPSidebar from '@theme/VPSidebar.vue'
|
|
6
9
|
import { computed, onMounted, onUnmounted, ref } from 'vue'
|
|
7
|
-
import { useRouter } from '
|
|
8
|
-
import { usePageData, usePageFrontmatter } from 'vuepress/client'
|
|
10
|
+
import { usePageData, usePageFrontmatter, useRouter } from 'vuepress/client'
|
|
9
11
|
import type { DefaultThemePageFrontmatter } from '../../shared/index.js'
|
|
10
|
-
import {
|
|
11
|
-
useScrollPromise,
|
|
12
|
-
useSidebarItems,
|
|
13
|
-
useThemeLocaleData,
|
|
14
|
-
} from '../composables/index.js'
|
|
15
12
|
|
|
16
13
|
defineSlots<{
|
|
17
14
|
'navbar'?: (props: Record<never, never>) => any
|
|
@@ -60,12 +57,21 @@ const onTouchEnd = (e): void => {
|
|
|
60
57
|
}
|
|
61
58
|
}
|
|
62
59
|
|
|
60
|
+
// external-link-icon
|
|
61
|
+
const enableExternalLinkIcon = computed(
|
|
62
|
+
() =>
|
|
63
|
+
frontmatter.value.externalLinkIcon ??
|
|
64
|
+
themeLocale.value.externalLinkIcon ??
|
|
65
|
+
true,
|
|
66
|
+
)
|
|
67
|
+
|
|
63
68
|
// classes
|
|
64
69
|
const containerClass = computed(() => [
|
|
65
70
|
{
|
|
66
71
|
'no-navbar': !shouldShowNavbar.value,
|
|
67
72
|
'no-sidebar': !sidebarItems.value.length,
|
|
68
73
|
'sidebar-open': isSidebarOpen.value,
|
|
74
|
+
'external-link-icon': enableExternalLinkIcon.value,
|
|
69
75
|
},
|
|
70
76
|
frontmatter.value.pageClass,
|
|
71
77
|
])
|
|
@@ -90,37 +96,37 @@ const onBeforeLeave = scrollPromise.pending
|
|
|
90
96
|
|
|
91
97
|
<template>
|
|
92
98
|
<div
|
|
93
|
-
class="theme-container"
|
|
99
|
+
class="vp-theme-container"
|
|
94
100
|
:class="containerClass"
|
|
95
101
|
@touchstart="onTouchStart"
|
|
96
102
|
@touchend="onTouchEnd"
|
|
97
103
|
>
|
|
98
104
|
<slot name="navbar">
|
|
99
|
-
<
|
|
105
|
+
<VPNavbar v-if="shouldShowNavbar" @toggle-sidebar="toggleSidebar">
|
|
100
106
|
<template #before>
|
|
101
107
|
<slot name="navbar-before" />
|
|
102
108
|
</template>
|
|
103
109
|
<template #after>
|
|
104
110
|
<slot name="navbar-after" />
|
|
105
111
|
</template>
|
|
106
|
-
</
|
|
112
|
+
</VPNavbar>
|
|
107
113
|
</slot>
|
|
108
114
|
|
|
109
|
-
<div class="sidebar-mask" @click="toggleSidebar(false)" />
|
|
115
|
+
<div class="vp-sidebar-mask" @click="toggleSidebar(false)" />
|
|
110
116
|
|
|
111
117
|
<slot name="sidebar">
|
|
112
|
-
<
|
|
118
|
+
<VPSidebar>
|
|
113
119
|
<template #top>
|
|
114
120
|
<slot name="sidebar-top" />
|
|
115
121
|
</template>
|
|
116
122
|
<template #bottom>
|
|
117
123
|
<slot name="sidebar-bottom" />
|
|
118
124
|
</template>
|
|
119
|
-
</
|
|
125
|
+
</VPSidebar>
|
|
120
126
|
</slot>
|
|
121
127
|
|
|
122
128
|
<slot name="page">
|
|
123
|
-
<
|
|
129
|
+
<VPHome v-if="frontmatter.home" />
|
|
124
130
|
|
|
125
131
|
<Transition
|
|
126
132
|
v-else
|
|
@@ -129,7 +135,7 @@ const onBeforeLeave = scrollPromise.pending
|
|
|
129
135
|
@before-enter="onBeforeEnter"
|
|
130
136
|
@before-leave="onBeforeLeave"
|
|
131
137
|
>
|
|
132
|
-
<
|
|
138
|
+
<VPPage :key="page.path">
|
|
133
139
|
<template #top>
|
|
134
140
|
<slot name="page-top" />
|
|
135
141
|
</template>
|
|
@@ -142,8 +148,103 @@ const onBeforeLeave = scrollPromise.pending
|
|
|
142
148
|
<template #bottom>
|
|
143
149
|
<slot name="page-bottom" />
|
|
144
150
|
</template>
|
|
145
|
-
</
|
|
151
|
+
</VPPage>
|
|
146
152
|
</Transition>
|
|
147
153
|
</slot>
|
|
148
154
|
</div>
|
|
149
155
|
</template>
|
|
156
|
+
|
|
157
|
+
<style lang="scss">
|
|
158
|
+
@import '../styles/variables';
|
|
159
|
+
|
|
160
|
+
.vp-sidebar-mask {
|
|
161
|
+
position: fixed;
|
|
162
|
+
top: 0;
|
|
163
|
+
left: 0;
|
|
164
|
+
z-index: 9;
|
|
165
|
+
|
|
166
|
+
display: none;
|
|
167
|
+
|
|
168
|
+
width: 100vw;
|
|
169
|
+
height: 100vh;
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
.vp-theme-container {
|
|
173
|
+
// navbar is disabled
|
|
174
|
+
&.no-navbar {
|
|
175
|
+
.vp-sidebar {
|
|
176
|
+
top: 0;
|
|
177
|
+
|
|
178
|
+
@media (max-width: $MQMobile) {
|
|
179
|
+
padding-top: 0;
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
.vp-page {
|
|
184
|
+
padding-top: 0;
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
// adjust heading margin and padding;
|
|
188
|
+
.theme-default-content {
|
|
189
|
+
h1,
|
|
190
|
+
h2,
|
|
191
|
+
h3,
|
|
192
|
+
h4,
|
|
193
|
+
h5,
|
|
194
|
+
h6 {
|
|
195
|
+
margin-top: 1.5rem;
|
|
196
|
+
padding-top: 0;
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
&.no-sidebar {
|
|
202
|
+
// hide sidebar
|
|
203
|
+
.vp-sidebar {
|
|
204
|
+
display: none;
|
|
205
|
+
|
|
206
|
+
// show sidebar on mobile because it has navbar links
|
|
207
|
+
@media (max-width: $MQMobile) {
|
|
208
|
+
display: block;
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
.vp-page {
|
|
213
|
+
padding-left: 0;
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
&.sidebar-open {
|
|
218
|
+
@media (max-width: $MQMobile) {
|
|
219
|
+
// show sidebar
|
|
220
|
+
.vp-sidebar {
|
|
221
|
+
transform: translateX(0);
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
// show sidebar mask
|
|
225
|
+
.vp-sidebar-mask {
|
|
226
|
+
display: block;
|
|
227
|
+
}
|
|
228
|
+
}
|
|
229
|
+
}
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
/**
|
|
233
|
+
* fade-slide-y transition
|
|
234
|
+
*/
|
|
235
|
+
.fade-slide-y {
|
|
236
|
+
&-enter-active {
|
|
237
|
+
transition: all 0.2s ease;
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
&-leave-active {
|
|
241
|
+
transition: all 0.2s cubic-bezier(1, 0.5, 0.8, 1);
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
&-enter-from,
|
|
245
|
+
&-leave-to {
|
|
246
|
+
opacity: 0;
|
|
247
|
+
transform: translateY(10px);
|
|
248
|
+
}
|
|
249
|
+
}
|
|
250
|
+
</style>
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
<script setup lang="ts">
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
2
|
+
import { useThemeLocaleData } from '@theme/useThemeData'
|
|
3
|
+
import { RouteLink, useRouteLocale } from 'vuepress/client'
|
|
4
4
|
|
|
5
5
|
const routeLocale = useRouteLocale()
|
|
6
6
|
const themeLocale = useThemeLocaleData()
|
|
@@ -13,15 +13,29 @@ const homeText = themeLocale.value.backToHome ?? 'Back to home'
|
|
|
13
13
|
</script>
|
|
14
14
|
|
|
15
15
|
<template>
|
|
16
|
-
<div class="theme-container">
|
|
16
|
+
<div class="vp-theme-container">
|
|
17
17
|
<main class="page">
|
|
18
18
|
<div class="theme-default-content">
|
|
19
19
|
<h1>404</h1>
|
|
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>
|
|
27
27
|
</template>
|
|
28
|
+
|
|
29
|
+
<style scoped lang="scss">
|
|
30
|
+
.vp-theme-container {
|
|
31
|
+
max-width: 740px;
|
|
32
|
+
margin: 0 auto;
|
|
33
|
+
padding: 2rem 2.5rem;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
@media (max-width: 959px) {
|
|
37
|
+
.vp-theme-container {
|
|
38
|
+
padding: 2rem;
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
</style>
|
package/lib/client/shim.d.ts
CHANGED
|
@@ -4,7 +4,7 @@ declare module '*.vue' {
|
|
|
4
4
|
export default comp
|
|
5
5
|
}
|
|
6
6
|
|
|
7
|
-
declare module '
|
|
8
|
-
const
|
|
9
|
-
export default
|
|
7
|
+
declare module '*/styles/_variables.module.scss' {
|
|
8
|
+
const cSSVariables: Record<string, string>
|
|
9
|
+
export default cSSVariables
|
|
10
10
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
@import '
|
|
1
|
+
@import 'variables';
|
|
2
2
|
|
|
3
|
-
@mixin
|
|
3
|
+
@mixin content-wrapper {
|
|
4
4
|
max-width: var(--content-width);
|
|
5
5
|
margin: 0 auto;
|
|
6
6
|
padding: 2rem 2.5rem;
|
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
}
|
|
15
15
|
}
|
|
16
16
|
|
|
17
|
-
@mixin
|
|
18
|
-
transition: height 0.1s ease-out;
|
|
17
|
+
@mixin dropdown-wrapper {
|
|
19
18
|
overflow: hidden;
|
|
19
|
+
transition: height 0.1s ease-out;
|
|
20
20
|
}
|
|
@@ -1,37 +1,31 @@
|
|
|
1
1
|
.arrow {
|
|
2
2
|
display: inline-block;
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
3
|
+
vertical-align: middle;
|
|
4
|
+
|
|
5
|
+
width: 1em;
|
|
6
|
+
height: 1em;
|
|
7
|
+
|
|
8
|
+
background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath fill='rgba(0,0,0,0.5)' d='M7.41 15.41L12 10.83l4.59 4.58L18 14l-6-6-6 6z'/%3E%3C/svg%3E");
|
|
9
|
+
background-position: center;
|
|
10
|
+
background-repeat: no-repeat;
|
|
11
|
+
|
|
12
|
+
line-height: normal;
|
|
13
|
+
|
|
14
|
+
transition: all 0.3s;
|
|
15
|
+
|
|
16
|
+
html.dark & {
|
|
17
|
+
background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath fill='rgba(255,255,255,0.5)' d='M7.41 15.41L12 10.83l4.59 4.58L18 14l-6-6-6 6z'/%3E%3C/svg%3E");
|
|
12
18
|
}
|
|
13
19
|
|
|
14
20
|
&.down {
|
|
15
|
-
|
|
16
|
-
left: 4px solid transparent;
|
|
17
|
-
right: 4px solid transparent;
|
|
18
|
-
top: 6px solid var(--c-bg-arrow);
|
|
19
|
-
}
|
|
21
|
+
transform: rotate(180deg);
|
|
20
22
|
}
|
|
21
23
|
|
|
22
24
|
&.right {
|
|
23
|
-
|
|
24
|
-
top: 4px solid transparent;
|
|
25
|
-
bottom: 4px solid transparent;
|
|
26
|
-
left: 6px solid var(--c-bg-arrow);
|
|
27
|
-
}
|
|
25
|
+
transform: rotate(90deg);
|
|
28
26
|
}
|
|
29
27
|
|
|
30
28
|
&.left {
|
|
31
|
-
|
|
32
|
-
top: 4px solid transparent;
|
|
33
|
-
bottom: 4px solid transparent;
|
|
34
|
-
right: 6px solid var(--c-bg-arrow);
|
|
35
|
-
}
|
|
29
|
+
transform: rotate(-90deg);
|
|
36
30
|
}
|
|
37
31
|
}
|