@vuepress/theme-default 2.0.0-beta.6 → 2.0.0-beta.60
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/AutoLink.vue +114 -0
- package/lib/client/components/DropdownTransition.vue +21 -0
- package/lib/client/components/Home.vue +15 -0
- 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 +98 -0
- package/lib/client/components/Navbar.vue +75 -0
- package/lib/client/components/NavbarBrand.vue +55 -0
- package/lib/client/components/NavbarDropdown.vue +126 -0
- package/lib/{components/NavbarLinks.vue → client/components/NavbarItems.vue} +61 -50
- package/lib/{components → client/components}/Page.vue +9 -15
- package/lib/{components → client/components}/PageMeta.vue +51 -66
- package/lib/{components → client/components}/PageNav.vue +44 -57
- package/lib/client/components/Sidebar.vue +13 -0
- package/lib/client/components/SidebarItem.vue +87 -0
- package/lib/client/components/SidebarItems.vue +57 -0
- package/lib/client/components/ToggleColorModeButton.vue +57 -0
- package/lib/client/components/ToggleSidebarButton.vue +24 -0
- package/lib/client/components/global/Badge.vue +31 -0
- package/lib/client/components/global/CodeGroup.d.ts +4 -0
- package/lib/client/components/global/CodeGroup.js +106 -0
- package/lib/client/components/global/CodeGroupItem.vue +31 -0
- package/lib/client/components/global/index.d.ts +4 -0
- package/lib/client/components/global/index.js +4 -0
- package/lib/client/composables/index.d.ts +6 -0
- package/lib/client/composables/index.js +6 -0
- package/lib/client/composables/useDarkMode.d.ts +12 -0
- package/lib/client/composables/useDarkMode.js +57 -0
- package/lib/{composables → client/composables}/useNavLink.d.ts +6 -1
- package/lib/{composables → client/composables}/useNavLink.js +5 -2
- package/lib/{composables → client/composables}/useResolveRouteWithRedirect.d.ts +1 -1
- package/lib/{composables → client/composables}/useResolveRouteWithRedirect.js +2 -2
- package/lib/{composables → client/composables}/useScrollPromise.d.ts +0 -0
- package/lib/{composables → client/composables}/useScrollPromise.js +1 -1
- package/lib/client/composables/useSidebarItems.d.ts +36 -0
- package/lib/client/composables/useSidebarItems.js +118 -0
- package/lib/{composables → client/composables}/useThemeData.d.ts +2 -2
- package/lib/{composables → client/composables}/useThemeData.js +1 -1
- package/lib/client/config.d.ts +3 -0
- package/lib/client/config.js +44 -0
- package/lib/client/index.d.ts +3 -0
- package/lib/client/index.js +3 -0
- package/lib/client/layouts/Layout.vue +134 -0
- package/lib/client/layouts/NotFound.vue +27 -0
- package/lib/{shim.d.ts → client/shim.d.ts} +0 -0
- package/lib/{styles/_wrapper.scss → client/styles/_mixins.scss} +7 -2
- package/lib/client/styles/_variables.scss +6 -0
- package/lib/{styles → client/styles}/arrow.scss +4 -6
- package/lib/client/styles/badge.scss +34 -0
- package/lib/{styles → client/styles}/code-group.scss +9 -2
- package/lib/{styles → client/styles}/code.scss +35 -49
- package/lib/client/styles/custom-container.scss +140 -0
- package/lib/{styles → client/styles}/home.scss +32 -24
- package/lib/{styles → client/styles}/index.scss +4 -4
- package/lib/client/styles/layout.scss +199 -0
- package/lib/{styles/dropdown.scss → client/styles/navbar-dropdown.scss} +36 -50
- package/lib/client/styles/navbar.scss +193 -0
- package/lib/client/styles/normalize.scss +200 -0
- package/lib/{styles → client/styles}/page.scss +24 -8
- package/lib/client/styles/sidebar.scss +134 -0
- package/lib/{styles → client/styles}/toc.scss +0 -0
- package/lib/client/styles/transitions.scss +22 -0
- package/lib/client/styles/vars-dark.scss +68 -0
- package/lib/client/styles/vars.scss +149 -0
- package/lib/client/utils/index.d.ts +3 -0
- package/lib/client/utils/index.js +3 -0
- package/lib/client/utils/isActiveSidebarItem.d.ts +3 -0
- package/lib/client/utils/isActiveSidebarItem.js +20 -0
- package/lib/{utils → client/utils}/resolveEditLink.d.ts +2 -2
- package/lib/{utils → client/utils}/resolveEditLink.js +15 -9
- package/lib/client/utils/resolveRepoType.d.ts +2 -0
- package/lib/{utils → client/utils}/resolveRepoType.js +3 -1
- package/lib/node/defaultTheme.d.ts +10 -0
- package/lib/node/defaultTheme.js +117 -0
- package/lib/node/index.d.ts +5 -5
- package/lib/node/index.js +5 -17
- package/lib/node/utils/assignDefaultLocaleOptions.d.ts +7 -0
- package/lib/node/{assignDefaultLocaleOptions.js → utils/assignDefaultLocaleOptions.js} +13 -13
- package/lib/node/utils/index.d.ts +2 -0
- package/lib/node/utils/index.js +2 -0
- package/lib/node/utils/resolveContainerPluginOptions.d.ts +8 -0
- package/lib/node/utils/resolveContainerPluginOptions.js +17 -0
- package/lib/shared/index.d.ts +3 -0
- package/lib/shared/index.js +3 -0
- package/lib/shared/nav.d.ts +42 -0
- package/lib/shared/nav.js +1 -0
- package/lib/{types → shared}/options.d.ts +51 -13
- package/lib/shared/options.js +1 -0
- package/lib/{types → shared}/page.d.ts +15 -6
- package/lib/shared/page.js +1 -0
- package/package.json +49 -29
- package/templates/build.html +33 -0
- package/CHANGELOG.md +0 -376
- package/lib/clientAppEnhance.d.ts +0 -3
- package/lib/clientAppEnhance.js +0 -30
- package/lib/clientAppSetup.d.ts +0 -2
- package/lib/clientAppSetup.js +0 -11
- package/lib/components/DropdownLink.vue +0 -141
- package/lib/components/DropdownTransition.vue +0 -34
- package/lib/components/Home.vue +0 -133
- package/lib/components/NavLink.vue +0 -115
- package/lib/components/Navbar.vue +0 -114
- package/lib/components/Sidebar.vue +0 -38
- package/lib/components/SidebarChild.d.ts +0 -6
- package/lib/components/SidebarChild.js +0 -91
- package/lib/components/ToggleSidebarButton.vue +0 -27
- package/lib/components/global/Badge.vue +0 -37
- package/lib/components/global/CodeGroup.d.ts +0 -5
- package/lib/components/global/CodeGroup.js +0 -52
- package/lib/components/global/CodeGroupItem.vue +0 -25
- package/lib/components/global/OutboundLink.vue +0 -30
- package/lib/composables/index.d.ts +0 -5
- package/lib/composables/index.js +0 -5
- package/lib/composables/useSidebarItems.d.ts +0 -31
- package/lib/composables/useSidebarItems.js +0 -114
- package/lib/index.d.ts +0 -6
- package/lib/index.js +0 -67
- package/lib/layouts/404.vue +0 -38
- package/lib/layouts/Layout.vue +0 -152
- package/lib/node/assignDefaultLocaleOptions.d.ts +0 -5
- package/lib/node/resolveActiveHeaderLinksPluginOptions.d.ts +0 -6
- package/lib/node/resolveActiveHeaderLinksPluginOptions.js +0 -16
- package/lib/node/resolveContainerPluginOptions.d.ts +0 -26
- package/lib/node/resolveContainerPluginOptions.js +0 -79
- package/lib/node/resolveGitPluginOptions.d.ts +0 -6
- package/lib/node/resolveGitPluginOptions.js +0 -22
- package/lib/node/resolveMediumZoomPluginOptions.d.ts +0 -6
- package/lib/node/resolveMediumZoomPluginOptions.js +0 -17
- package/lib/styles/_normalize.scss +0 -148
- package/lib/styles/_variables.scss +0 -34
- package/lib/styles/badge.scss +0 -33
- package/lib/styles/custom-container.scss +0 -78
- package/lib/styles/layout.scss +0 -194
- package/lib/styles/navbar.scss +0 -141
- package/lib/styles/plugins.scss +0 -18
- package/lib/styles/sidebar.scss +0 -152
- package/lib/styles/sr-only.scss +0 -12
- package/lib/styles/transitions.scss +0 -13
- package/lib/types/index.d.ts +0 -3
- package/lib/types/index.js +0 -15
- package/lib/types/nav.d.ts +0 -44
- package/lib/types/nav.js +0 -2
- package/lib/types/options.js +0 -2
- package/lib/types/page.js +0 -2
- package/lib/utils/index.d.ts +0 -2
- package/lib/utils/index.js +0 -2
- package/lib/utils/resolveRepoType.d.ts +0 -2
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
import type { ComputedRef, InjectionKey } from 'vue';
|
|
2
|
-
import type { PageHeader } from '@vuepress/client';
|
|
3
|
-
import type { DefaultThemeData, DefaultThemePageFrontmatter, SidebarConfigArray, SidebarConfigObject, ResolvedSidebarItem } from '../types';
|
|
4
|
-
export declare type SidebarItemsRef = ComputedRef<ResolvedSidebarItem[]>;
|
|
5
|
-
export declare const sidebarItemsSymbol: InjectionKey<SidebarItemsRef>;
|
|
6
|
-
/**
|
|
7
|
-
* Inject sidebar items global computed
|
|
8
|
-
*/
|
|
9
|
-
export declare const useSidebarItems: () => SidebarItemsRef;
|
|
10
|
-
/**
|
|
11
|
-
* Resolve sidebar items global computed
|
|
12
|
-
*
|
|
13
|
-
* It should only be resolved and provided once
|
|
14
|
-
*/
|
|
15
|
-
export declare const resolveSidebarItems: (frontmatter: DefaultThemePageFrontmatter, themeLocale: DefaultThemeData) => ResolvedSidebarItem[];
|
|
16
|
-
/**
|
|
17
|
-
* Util to transform page header to sidebar item
|
|
18
|
-
*/
|
|
19
|
-
export declare const headerToSidebarItem: (header: PageHeader) => ResolvedSidebarItem;
|
|
20
|
-
/**
|
|
21
|
-
* Resolve sidebar items if the config is `auto`
|
|
22
|
-
*/
|
|
23
|
-
export declare const resolveAutoSidebarItems: () => ResolvedSidebarItem[];
|
|
24
|
-
/**
|
|
25
|
-
* Resolve sidebar items if the config is an array
|
|
26
|
-
*/
|
|
27
|
-
export declare const resolveArraySidebarItems: (sidebarConfig: SidebarConfigArray) => ResolvedSidebarItem[];
|
|
28
|
-
/**
|
|
29
|
-
* Resolve sidebar items if the config is a key -> value (path-prefix -> array) object
|
|
30
|
-
*/
|
|
31
|
-
export declare const resolveMultiSidebarItems: (sidebarConfig: SidebarConfigObject) => ResolvedSidebarItem[];
|
|
@@ -1,114 +0,0 @@
|
|
|
1
|
-
import { inject } from 'vue';
|
|
2
|
-
import { useRoute } from 'vue-router';
|
|
3
|
-
import { usePageData } from '@vuepress/client';
|
|
4
|
-
import { isArray, isPlainObject, isString, resolveLocalePath, } from '@vuepress/shared';
|
|
5
|
-
import { useNavLink } from './useNavLink';
|
|
6
|
-
export const sidebarItemsSymbol = Symbol('sidebarItems');
|
|
7
|
-
/**
|
|
8
|
-
* Inject sidebar items global computed
|
|
9
|
-
*/
|
|
10
|
-
export const useSidebarItems = () => {
|
|
11
|
-
const sidebarItems = inject(sidebarItemsSymbol);
|
|
12
|
-
if (!sidebarItems) {
|
|
13
|
-
throw new Error('useSidebarItems() is called without provider.');
|
|
14
|
-
}
|
|
15
|
-
return sidebarItems;
|
|
16
|
-
};
|
|
17
|
-
/**
|
|
18
|
-
* Resolve sidebar items global computed
|
|
19
|
-
*
|
|
20
|
-
* It should only be resolved and provided once
|
|
21
|
-
*/
|
|
22
|
-
export const resolveSidebarItems = (frontmatter, themeLocale) => {
|
|
23
|
-
var _a, _b;
|
|
24
|
-
// get sidebar config from frontmatter > themeConfig
|
|
25
|
-
const sidebarConfig = (_b = (_a = frontmatter.sidebar) !== null && _a !== void 0 ? _a : themeLocale.sidebar) !== null && _b !== void 0 ? _b : 'auto';
|
|
26
|
-
// resolve sidebar items according to the config
|
|
27
|
-
if (frontmatter.home === true || sidebarConfig === false) {
|
|
28
|
-
return [];
|
|
29
|
-
}
|
|
30
|
-
if (sidebarConfig === 'auto') {
|
|
31
|
-
return resolveAutoSidebarItems();
|
|
32
|
-
}
|
|
33
|
-
if (isArray(sidebarConfig)) {
|
|
34
|
-
return resolveArraySidebarItems(sidebarConfig);
|
|
35
|
-
}
|
|
36
|
-
if (isPlainObject(sidebarConfig)) {
|
|
37
|
-
return resolveMultiSidebarItems(sidebarConfig);
|
|
38
|
-
}
|
|
39
|
-
return [];
|
|
40
|
-
};
|
|
41
|
-
/**
|
|
42
|
-
* Util to transform page header to sidebar item
|
|
43
|
-
*/
|
|
44
|
-
export const headerToSidebarItem = (header) => ({
|
|
45
|
-
text: header.title,
|
|
46
|
-
link: `#${header.slug}`,
|
|
47
|
-
children: header.children.map(headerToSidebarItem),
|
|
48
|
-
});
|
|
49
|
-
/**
|
|
50
|
-
* Resolve sidebar items if the config is `auto`
|
|
51
|
-
*/
|
|
52
|
-
export const resolveAutoSidebarItems = () => {
|
|
53
|
-
const page = usePageData();
|
|
54
|
-
return [
|
|
55
|
-
{
|
|
56
|
-
isGroup: true,
|
|
57
|
-
text: page.value.title,
|
|
58
|
-
children: page.value.headers.map(headerToSidebarItem),
|
|
59
|
-
},
|
|
60
|
-
];
|
|
61
|
-
};
|
|
62
|
-
/**
|
|
63
|
-
* Resolve sidebar items if the config is an array
|
|
64
|
-
*/
|
|
65
|
-
export const resolveArraySidebarItems = (sidebarConfig) => {
|
|
66
|
-
const route = useRoute();
|
|
67
|
-
const page = usePageData();
|
|
68
|
-
const handleChildItem = (item) => {
|
|
69
|
-
let childItem;
|
|
70
|
-
if (isString(item)) {
|
|
71
|
-
childItem = useNavLink(item);
|
|
72
|
-
}
|
|
73
|
-
else {
|
|
74
|
-
childItem = item;
|
|
75
|
-
}
|
|
76
|
-
if (childItem.isGroup && childItem.children) {
|
|
77
|
-
return {
|
|
78
|
-
...childItem,
|
|
79
|
-
children: childItem.children.map(handleChildItem),
|
|
80
|
-
};
|
|
81
|
-
}
|
|
82
|
-
// if the sidebar item is current page and children is not set
|
|
83
|
-
// use headers of current page as children
|
|
84
|
-
if (childItem.link === route.path && childItem.children === undefined) {
|
|
85
|
-
return {
|
|
86
|
-
...childItem,
|
|
87
|
-
children: page.value.headers.map(headerToSidebarItem),
|
|
88
|
-
};
|
|
89
|
-
}
|
|
90
|
-
return childItem;
|
|
91
|
-
};
|
|
92
|
-
return sidebarConfig.map((item) => {
|
|
93
|
-
if (isString(item)) {
|
|
94
|
-
return useNavLink(item);
|
|
95
|
-
}
|
|
96
|
-
if (!item.isGroup) {
|
|
97
|
-
return item;
|
|
98
|
-
}
|
|
99
|
-
return {
|
|
100
|
-
...item,
|
|
101
|
-
children: item.children.map(handleChildItem),
|
|
102
|
-
};
|
|
103
|
-
});
|
|
104
|
-
};
|
|
105
|
-
/**
|
|
106
|
-
* Resolve sidebar items if the config is a key -> value (path-prefix -> array) object
|
|
107
|
-
*/
|
|
108
|
-
export const resolveMultiSidebarItems = (sidebarConfig) => {
|
|
109
|
-
var _a;
|
|
110
|
-
const route = useRoute();
|
|
111
|
-
const sidebarPath = resolveLocalePath(sidebarConfig, route.path);
|
|
112
|
-
const matchedSidebarConfig = (_a = sidebarConfig[sidebarPath]) !== null && _a !== void 0 ? _a : [];
|
|
113
|
-
return resolveArraySidebarItems(matchedSidebarConfig);
|
|
114
|
-
};
|
package/lib/index.d.ts
DELETED
package/lib/index.js
DELETED
|
@@ -1,67 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
5
|
-
}) : (function(o, m, k, k2) {
|
|
6
|
-
if (k2 === undefined) k2 = k;
|
|
7
|
-
o[k2] = m[k];
|
|
8
|
-
}));
|
|
9
|
-
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
10
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
11
|
-
};
|
|
12
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
|
-
exports.defaultTheme = void 0;
|
|
14
|
-
const utils_1 = require("@vuepress/utils");
|
|
15
|
-
const node_1 = require("./node");
|
|
16
|
-
__exportStar(require("./node"), exports);
|
|
17
|
-
__exportStar(require("./types"), exports);
|
|
18
|
-
const defaultTheme = ({ themePlugins = {}, ...localeOptions }) => {
|
|
19
|
-
node_1.assignDefaultLocaleOptions(localeOptions);
|
|
20
|
-
return {
|
|
21
|
-
name: '@vuepress/theme-default',
|
|
22
|
-
layouts: utils_1.path.resolve(__dirname, './layouts'),
|
|
23
|
-
clientAppEnhanceFiles: utils_1.path.resolve(__dirname, './clientAppEnhance.js'),
|
|
24
|
-
clientAppSetupFiles: utils_1.path.resolve(__dirname, './clientAppSetup.js'),
|
|
25
|
-
// use the relative file path to generate edit link
|
|
26
|
-
extendsPageData: ({ filePathRelative }) => ({ filePathRelative }),
|
|
27
|
-
plugins: [
|
|
28
|
-
[
|
|
29
|
-
'@vuepress/active-header-links',
|
|
30
|
-
node_1.resolveActiveHeaderLinksPluginOptions(themePlugins),
|
|
31
|
-
],
|
|
32
|
-
['@vuepress/back-to-top', themePlugins.backToTop !== false],
|
|
33
|
-
[
|
|
34
|
-
'@vuepress/container',
|
|
35
|
-
node_1.resolveContainerPluginOptions(themePlugins, localeOptions, 'tip'),
|
|
36
|
-
],
|
|
37
|
-
[
|
|
38
|
-
'@vuepress/container',
|
|
39
|
-
node_1.resolveContainerPluginOptions(themePlugins, localeOptions, 'warning'),
|
|
40
|
-
],
|
|
41
|
-
[
|
|
42
|
-
'@vuepress/container',
|
|
43
|
-
node_1.resolveContainerPluginOptions(themePlugins, localeOptions, 'danger'),
|
|
44
|
-
],
|
|
45
|
-
[
|
|
46
|
-
'@vuepress/container',
|
|
47
|
-
node_1.resolveContainerPluginOptionsForDetails(themePlugins),
|
|
48
|
-
],
|
|
49
|
-
[
|
|
50
|
-
'@vuepress/container',
|
|
51
|
-
node_1.resolveContainerPluginOptionsForCodeGroup(themePlugins),
|
|
52
|
-
],
|
|
53
|
-
[
|
|
54
|
-
'@vuepress/container',
|
|
55
|
-
node_1.resolveContainerPluginOptionsForCodeGroupItem(themePlugins),
|
|
56
|
-
],
|
|
57
|
-
['@vuepress/git', node_1.resolveGitPluginOptions(themePlugins, localeOptions)],
|
|
58
|
-
['@vuepress/medium-zoom', node_1.resolveMediumZoomPluginOptions(themePlugins)],
|
|
59
|
-
['@vuepress/nprogress', themePlugins.nprogress !== false],
|
|
60
|
-
['@vuepress/palette', { preset: 'sass' }],
|
|
61
|
-
['@vuepress/prismjs', themePlugins.prismjs !== false],
|
|
62
|
-
['@vuepress/theme-data', { themeData: localeOptions }],
|
|
63
|
-
],
|
|
64
|
-
};
|
|
65
|
-
};
|
|
66
|
-
exports.defaultTheme = defaultTheme;
|
|
67
|
-
exports.default = exports.defaultTheme;
|
package/lib/layouts/404.vue
DELETED
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
<template>
|
|
2
|
-
<div class="theme-container">
|
|
3
|
-
<div class="theme-default-content">
|
|
4
|
-
<h1>404</h1>
|
|
5
|
-
|
|
6
|
-
<blockquote>{{ getMsg() }}</blockquote>
|
|
7
|
-
|
|
8
|
-
<RouterLink :to="homeLink">{{ homeText }}</RouterLink>
|
|
9
|
-
</div>
|
|
10
|
-
</div>
|
|
11
|
-
</template>
|
|
12
|
-
|
|
13
|
-
<script lang="ts">
|
|
14
|
-
import { defineComponent } from 'vue'
|
|
15
|
-
import { useRouteLocale } from '@vuepress/client'
|
|
16
|
-
import { useThemeLocaleData } from '../composables'
|
|
17
|
-
|
|
18
|
-
export default defineComponent({
|
|
19
|
-
name: '404',
|
|
20
|
-
|
|
21
|
-
setup() {
|
|
22
|
-
const routeLocale = useRouteLocale()
|
|
23
|
-
const themeLocale = useThemeLocaleData()
|
|
24
|
-
|
|
25
|
-
const messages = themeLocale.value.notFound ?? ['Not Found']
|
|
26
|
-
const getMsg = (): string =>
|
|
27
|
-
messages[Math.floor(Math.random() * messages.length)]
|
|
28
|
-
const homeLink = themeLocale.value.home ?? routeLocale.value
|
|
29
|
-
const homeText = themeLocale.value.backToHome ?? 'Back to home'
|
|
30
|
-
|
|
31
|
-
return {
|
|
32
|
-
getMsg,
|
|
33
|
-
homeLink,
|
|
34
|
-
homeText,
|
|
35
|
-
}
|
|
36
|
-
},
|
|
37
|
-
})
|
|
38
|
-
</script>
|
package/lib/layouts/Layout.vue
DELETED
|
@@ -1,152 +0,0 @@
|
|
|
1
|
-
<template>
|
|
2
|
-
<div
|
|
3
|
-
class="theme-container"
|
|
4
|
-
:class="containerClass"
|
|
5
|
-
@touchstart="onTouchStart"
|
|
6
|
-
@touchend="onTouchEnd"
|
|
7
|
-
>
|
|
8
|
-
<Navbar v-if="shouldShowNavbar" @toggle-sidebar="toggleSidebar">
|
|
9
|
-
<template #before>
|
|
10
|
-
<slot name="navbar-before" />
|
|
11
|
-
</template>
|
|
12
|
-
<template #after>
|
|
13
|
-
<slot name="navbar-after" />
|
|
14
|
-
</template>
|
|
15
|
-
</Navbar>
|
|
16
|
-
|
|
17
|
-
<div class="sidebar-mask" @click="toggleSidebar(false)" />
|
|
18
|
-
|
|
19
|
-
<Sidebar>
|
|
20
|
-
<template #top>
|
|
21
|
-
<slot name="sidebar-top" />
|
|
22
|
-
</template>
|
|
23
|
-
<template #bottom>
|
|
24
|
-
<slot name="sidebar-bottom" />
|
|
25
|
-
</template>
|
|
26
|
-
</Sidebar>
|
|
27
|
-
|
|
28
|
-
<Home v-if="frontmatter.home" />
|
|
29
|
-
|
|
30
|
-
<Transition
|
|
31
|
-
v-else
|
|
32
|
-
name="fade-slide-y"
|
|
33
|
-
mode="out-in"
|
|
34
|
-
@before-enter="onBeforeEnter"
|
|
35
|
-
@before-leave="onBeforeLeave"
|
|
36
|
-
>
|
|
37
|
-
<Page :key="page.path">
|
|
38
|
-
<template #top>
|
|
39
|
-
<slot name="page-top" />
|
|
40
|
-
</template>
|
|
41
|
-
<template #bottom>
|
|
42
|
-
<slot name="page-bottom" />
|
|
43
|
-
</template>
|
|
44
|
-
</Page>
|
|
45
|
-
</Transition>
|
|
46
|
-
</div>
|
|
47
|
-
</template>
|
|
48
|
-
|
|
49
|
-
<script lang="ts">
|
|
50
|
-
import {
|
|
51
|
-
computed,
|
|
52
|
-
defineComponent,
|
|
53
|
-
onMounted,
|
|
54
|
-
onUnmounted,
|
|
55
|
-
ref,
|
|
56
|
-
Transition,
|
|
57
|
-
} from 'vue'
|
|
58
|
-
import { useRouter } from 'vue-router'
|
|
59
|
-
import { usePageData, usePageFrontmatter } from '@vuepress/client'
|
|
60
|
-
import Home from '../components/Home.vue'
|
|
61
|
-
import Page from '../components/Page.vue'
|
|
62
|
-
import Navbar from '../components/Navbar.vue'
|
|
63
|
-
import Sidebar from '../components/Sidebar.vue'
|
|
64
|
-
import {
|
|
65
|
-
useScrollPromise,
|
|
66
|
-
useSidebarItems,
|
|
67
|
-
useThemeLocaleData,
|
|
68
|
-
} from '../composables'
|
|
69
|
-
|
|
70
|
-
export default defineComponent({
|
|
71
|
-
name: 'Layout',
|
|
72
|
-
|
|
73
|
-
components: {
|
|
74
|
-
Home,
|
|
75
|
-
Page,
|
|
76
|
-
Navbar,
|
|
77
|
-
Sidebar,
|
|
78
|
-
Transition,
|
|
79
|
-
},
|
|
80
|
-
|
|
81
|
-
setup() {
|
|
82
|
-
const page = usePageData()
|
|
83
|
-
const frontmatter = usePageFrontmatter()
|
|
84
|
-
const themeLocale = useThemeLocaleData()
|
|
85
|
-
|
|
86
|
-
// navbar
|
|
87
|
-
const shouldShowNavbar = computed(
|
|
88
|
-
() =>
|
|
89
|
-
frontmatter.value.navbar !== false && themeLocale.value.navbar !== false
|
|
90
|
-
)
|
|
91
|
-
|
|
92
|
-
// sidebar
|
|
93
|
-
const sidebarItems = useSidebarItems()
|
|
94
|
-
const isSidebarOpen = ref(false)
|
|
95
|
-
const toggleSidebar = (to?: boolean): void => {
|
|
96
|
-
isSidebarOpen.value = typeof to === 'boolean' ? to : !isSidebarOpen.value
|
|
97
|
-
}
|
|
98
|
-
const touchStart = { x: 0, y: 0 }
|
|
99
|
-
const onTouchStart = (e): void => {
|
|
100
|
-
touchStart.x = e.changedTouches[0].clientX
|
|
101
|
-
touchStart.y = e.changedTouches[0].clientY
|
|
102
|
-
}
|
|
103
|
-
const onTouchEnd = (e): void => {
|
|
104
|
-
const dx = e.changedTouches[0].clientX - touchStart.x
|
|
105
|
-
const dy = e.changedTouches[0].clientY - touchStart.y
|
|
106
|
-
if (Math.abs(dx) > Math.abs(dy) && Math.abs(dx) > 40) {
|
|
107
|
-
if (dx > 0 && touchStart.x <= 80) {
|
|
108
|
-
toggleSidebar(true)
|
|
109
|
-
} else {
|
|
110
|
-
toggleSidebar(false)
|
|
111
|
-
}
|
|
112
|
-
}
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
// classes
|
|
116
|
-
const containerClass = computed(() => ({
|
|
117
|
-
'no-navbar': !shouldShowNavbar.value,
|
|
118
|
-
'no-sidebar': !sidebarItems.value.length,
|
|
119
|
-
'sidebar-open': isSidebarOpen.value,
|
|
120
|
-
}))
|
|
121
|
-
|
|
122
|
-
// close sidebar after navigation
|
|
123
|
-
let unregisterRouterHook
|
|
124
|
-
onMounted(() => {
|
|
125
|
-
const router = useRouter()
|
|
126
|
-
unregisterRouterHook = router.afterEach(() => {
|
|
127
|
-
toggleSidebar(false)
|
|
128
|
-
})
|
|
129
|
-
})
|
|
130
|
-
onUnmounted(() => {
|
|
131
|
-
unregisterRouterHook()
|
|
132
|
-
})
|
|
133
|
-
|
|
134
|
-
// handle scrollBehavior with transition
|
|
135
|
-
const scrollPromise = useScrollPromise()
|
|
136
|
-
const onBeforeEnter = scrollPromise.resolve
|
|
137
|
-
const onBeforeLeave = scrollPromise.pending
|
|
138
|
-
|
|
139
|
-
return {
|
|
140
|
-
frontmatter,
|
|
141
|
-
page,
|
|
142
|
-
containerClass,
|
|
143
|
-
shouldShowNavbar,
|
|
144
|
-
toggleSidebar,
|
|
145
|
-
onTouchStart,
|
|
146
|
-
onTouchEnd,
|
|
147
|
-
onBeforeEnter,
|
|
148
|
-
onBeforeLeave,
|
|
149
|
-
}
|
|
150
|
-
},
|
|
151
|
-
})
|
|
152
|
-
</script>
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
import type { ActiveHeaderLinksPluginOptions } from '@vuepress/plugin-active-header-links';
|
|
2
|
-
import type { DefaultThemePluginsOptions } from '../types';
|
|
3
|
-
/**
|
|
4
|
-
* Resolve options for @vuepress/plugin-active-header-links
|
|
5
|
-
*/
|
|
6
|
-
export declare const resolveActiveHeaderLinksPluginOptions: (themePlugins: DefaultThemePluginsOptions) => ActiveHeaderLinksPluginOptions | boolean;
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.resolveActiveHeaderLinksPluginOptions = void 0;
|
|
4
|
-
/**
|
|
5
|
-
* Resolve options for @vuepress/plugin-active-header-links
|
|
6
|
-
*/
|
|
7
|
-
const resolveActiveHeaderLinksPluginOptions = (themePlugins) => {
|
|
8
|
-
if ((themePlugins === null || themePlugins === void 0 ? void 0 : themePlugins.activeHeaderLinks) === false) {
|
|
9
|
-
return false;
|
|
10
|
-
}
|
|
11
|
-
return {
|
|
12
|
-
headerLinkSelector: '.sidebar-link',
|
|
13
|
-
headerAnchorSelector: '.header-anchor',
|
|
14
|
-
};
|
|
15
|
-
};
|
|
16
|
-
exports.resolveActiveHeaderLinksPluginOptions = resolveActiveHeaderLinksPluginOptions;
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
import type { ContainerPluginOptions } from '@vuepress/plugin-container';
|
|
2
|
-
import type { DefaultThemePluginsOptions, DefaultThemeData } from '../types';
|
|
3
|
-
/**
|
|
4
|
-
* Resolve options for @vuepress/plugin-container
|
|
5
|
-
*
|
|
6
|
-
* For custom containers default title
|
|
7
|
-
*/
|
|
8
|
-
export declare const resolveContainerPluginOptions: (themePlugins: DefaultThemePluginsOptions, localeOptions: DefaultThemeData, type: 'tip' | 'warning' | 'danger') => ContainerPluginOptions | boolean;
|
|
9
|
-
/**
|
|
10
|
-
* Resolve options for @vuepress/plugin-container
|
|
11
|
-
*
|
|
12
|
-
* For details container
|
|
13
|
-
*/
|
|
14
|
-
export declare const resolveContainerPluginOptionsForDetails: (themePlugins: DefaultThemePluginsOptions) => ContainerPluginOptions | boolean;
|
|
15
|
-
/**
|
|
16
|
-
* Resolve options for @vuepress/plugin-container
|
|
17
|
-
*
|
|
18
|
-
* For code-group container
|
|
19
|
-
*/
|
|
20
|
-
export declare const resolveContainerPluginOptionsForCodeGroup: (themePlugins: DefaultThemePluginsOptions) => ContainerPluginOptions | boolean;
|
|
21
|
-
/**
|
|
22
|
-
* Resolve options for @vuepress/plugin-container
|
|
23
|
-
*
|
|
24
|
-
* For code-group-item block
|
|
25
|
-
*/
|
|
26
|
-
export declare const resolveContainerPluginOptionsForCodeGroupItem: (themePlugins: DefaultThemePluginsOptions) => ContainerPluginOptions | boolean;
|
|
@@ -1,79 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.resolveContainerPluginOptionsForCodeGroupItem = exports.resolveContainerPluginOptionsForCodeGroup = exports.resolveContainerPluginOptionsForDetails = exports.resolveContainerPluginOptions = void 0;
|
|
4
|
-
/**
|
|
5
|
-
* Resolve options for @vuepress/plugin-container
|
|
6
|
-
*
|
|
7
|
-
* For custom containers default title
|
|
8
|
-
*/
|
|
9
|
-
const resolveContainerPluginOptions = (themePlugins, localeOptions, type) => {
|
|
10
|
-
var _a;
|
|
11
|
-
if (((_a = themePlugins === null || themePlugins === void 0 ? void 0 : themePlugins.container) === null || _a === void 0 ? void 0 : _a[type]) === false) {
|
|
12
|
-
return false;
|
|
13
|
-
}
|
|
14
|
-
const locales = Object.entries(localeOptions.locales || {}).reduce((result, [key, value]) => {
|
|
15
|
-
const defaultInfo = value === null || value === void 0 ? void 0 : value[type];
|
|
16
|
-
if (defaultInfo) {
|
|
17
|
-
result[key] = {
|
|
18
|
-
defaultInfo,
|
|
19
|
-
};
|
|
20
|
-
}
|
|
21
|
-
return result;
|
|
22
|
-
}, {});
|
|
23
|
-
return {
|
|
24
|
-
type,
|
|
25
|
-
locales,
|
|
26
|
-
};
|
|
27
|
-
};
|
|
28
|
-
exports.resolveContainerPluginOptions = resolveContainerPluginOptions;
|
|
29
|
-
/**
|
|
30
|
-
* Resolve options for @vuepress/plugin-container
|
|
31
|
-
*
|
|
32
|
-
* For details container
|
|
33
|
-
*/
|
|
34
|
-
const resolveContainerPluginOptionsForDetails = (themePlugins) => {
|
|
35
|
-
var _a;
|
|
36
|
-
if (((_a = themePlugins === null || themePlugins === void 0 ? void 0 : themePlugins.container) === null || _a === void 0 ? void 0 : _a.details) === false) {
|
|
37
|
-
return false;
|
|
38
|
-
}
|
|
39
|
-
return {
|
|
40
|
-
type: 'details',
|
|
41
|
-
before: (info) => `<details class="custom-container details">${info ? `<summary>${info}</summary>` : ''}\n`,
|
|
42
|
-
after: () => '</details>\n',
|
|
43
|
-
};
|
|
44
|
-
};
|
|
45
|
-
exports.resolveContainerPluginOptionsForDetails = resolveContainerPluginOptionsForDetails;
|
|
46
|
-
/**
|
|
47
|
-
* Resolve options for @vuepress/plugin-container
|
|
48
|
-
*
|
|
49
|
-
* For code-group container
|
|
50
|
-
*/
|
|
51
|
-
const resolveContainerPluginOptionsForCodeGroup = (themePlugins) => {
|
|
52
|
-
var _a;
|
|
53
|
-
if (((_a = themePlugins === null || themePlugins === void 0 ? void 0 : themePlugins.container) === null || _a === void 0 ? void 0 : _a.codeGroup) === false) {
|
|
54
|
-
return false;
|
|
55
|
-
}
|
|
56
|
-
return {
|
|
57
|
-
type: 'code-group',
|
|
58
|
-
before: () => `<CodeGroup>\n`,
|
|
59
|
-
after: () => '</CodeGroup>\n',
|
|
60
|
-
};
|
|
61
|
-
};
|
|
62
|
-
exports.resolveContainerPluginOptionsForCodeGroup = resolveContainerPluginOptionsForCodeGroup;
|
|
63
|
-
/**
|
|
64
|
-
* Resolve options for @vuepress/plugin-container
|
|
65
|
-
*
|
|
66
|
-
* For code-group-item block
|
|
67
|
-
*/
|
|
68
|
-
const resolveContainerPluginOptionsForCodeGroupItem = (themePlugins) => {
|
|
69
|
-
var _a;
|
|
70
|
-
if (((_a = themePlugins === null || themePlugins === void 0 ? void 0 : themePlugins.container) === null || _a === void 0 ? void 0 : _a.codeGroupItem) === false) {
|
|
71
|
-
return false;
|
|
72
|
-
}
|
|
73
|
-
return {
|
|
74
|
-
type: 'code-group-item',
|
|
75
|
-
before: (info) => `<CodeGroupItem title="${info}">\n`,
|
|
76
|
-
after: () => '</CodeGroupItem>\n',
|
|
77
|
-
};
|
|
78
|
-
};
|
|
79
|
-
exports.resolveContainerPluginOptionsForCodeGroupItem = resolveContainerPluginOptionsForCodeGroupItem;
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
import type { GitPluginOptions } from '@vuepress/plugin-git';
|
|
2
|
-
import type { DefaultThemePluginsOptions, DefaultThemeLocaleOptions } from '../types';
|
|
3
|
-
/**
|
|
4
|
-
* Resolve options for @vuepress/plugin-git
|
|
5
|
-
*/
|
|
6
|
-
export declare const resolveGitPluginOptions: (themePlugins: DefaultThemePluginsOptions, localeOptions: DefaultThemeLocaleOptions) => GitPluginOptions | boolean;
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.resolveGitPluginOptions = void 0;
|
|
4
|
-
/**
|
|
5
|
-
* Resolve options for @vuepress/plugin-git
|
|
6
|
-
*/
|
|
7
|
-
const resolveGitPluginOptions = (themePlugins, localeOptions) => {
|
|
8
|
-
if ((themePlugins === null || themePlugins === void 0 ? void 0 : themePlugins.git) === false) {
|
|
9
|
-
return false;
|
|
10
|
-
}
|
|
11
|
-
const enableUpdatedTime = localeOptions.lastUpdated !== false;
|
|
12
|
-
const enableContributors = localeOptions.contributors !== false;
|
|
13
|
-
if (!enableUpdatedTime && !enableContributors) {
|
|
14
|
-
return false;
|
|
15
|
-
}
|
|
16
|
-
return {
|
|
17
|
-
createdTime: false,
|
|
18
|
-
updatedTime: enableUpdatedTime,
|
|
19
|
-
contributors: enableContributors,
|
|
20
|
-
};
|
|
21
|
-
};
|
|
22
|
-
exports.resolveGitPluginOptions = resolveGitPluginOptions;
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
import type { MediumZoomPluginOptions } from '@vuepress/plugin-medium-zoom';
|
|
2
|
-
import type { DefaultThemePluginsOptions } from '../types';
|
|
3
|
-
/**
|
|
4
|
-
* Resolve options for @vuepress/plugin-medium-zoom
|
|
5
|
-
*/
|
|
6
|
-
export declare const resolveMediumZoomPluginOptions: (themePlugins: DefaultThemePluginsOptions) => MediumZoomPluginOptions | boolean;
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.resolveMediumZoomPluginOptions = void 0;
|
|
4
|
-
/**
|
|
5
|
-
* Resolve options for @vuepress/plugin-medium-zoom
|
|
6
|
-
*/
|
|
7
|
-
const resolveMediumZoomPluginOptions = (themePlugins) => {
|
|
8
|
-
if ((themePlugins === null || themePlugins === void 0 ? void 0 : themePlugins.mediumZoom) === false) {
|
|
9
|
-
return false;
|
|
10
|
-
}
|
|
11
|
-
return {
|
|
12
|
-
selector: '.theme-default-content :not(a) > img',
|
|
13
|
-
zoomOptions: {},
|
|
14
|
-
delay: 300,
|
|
15
|
-
};
|
|
16
|
-
};
|
|
17
|
-
exports.resolveMediumZoomPluginOptions = resolveMediumZoomPluginOptions;
|