@vuepress/theme-default 2.0.0-rc.122 → 2.0.0-rc.123
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/VPHomeHero.vue +2 -0
- package/lib/client/components/VPNavbarDropdown.vue +4 -2
- package/lib/client/components/VPNavbarItems.vue +3 -3
- package/lib/client/components/VPPageNav.vue +3 -5
- package/lib/client/components/VPSidebarItem.vue +3 -3
- package/lib/client/composables/useDarkMode.d.ts +4 -0
- package/lib/client/composables/useDarkMode.js +11 -7
- package/lib/client/composables/useHeaders.d.ts +4 -0
- package/lib/client/composables/useHeaders.js +4 -0
- package/lib/client/composables/useNavbarConfig.js +1 -3
- package/lib/client/composables/useNavbarRepo.d.ts +3 -1
- package/lib/client/composables/useNavbarRepo.js +4 -2
- package/lib/client/composables/useNavbarSelectLanguage.d.ts +2 -0
- package/lib/client/composables/useNavbarSelectLanguage.js +2 -1
- package/lib/client/composables/useNavigate.js +2 -2
- package/lib/client/composables/useRelatedLinks.js +5 -0
- package/lib/client/composables/useSidebarItems.d.ts +38 -0
- package/lib/client/composables/useSidebarItems.js +43 -6
- package/lib/client/composables/useUpdateDeviceStatus.d.ts +3 -0
- package/lib/client/composables/useUpdateDeviceStatus.js +4 -0
- package/lib/client/config.js +2 -0
- package/lib/client/layouts/Layout.vue +7 -7
- package/lib/client/utils/resolveAutoLink.d.ts +6 -0
- package/lib/client/utils/resolveAutoLink.js +6 -0
- package/lib/client/utils/resolveEditLink.js +1 -1
- package/lib/node/typings.d.ts +12 -12
- package/lib/node/utils/resolveMarkdownHintLocales.d.ts +4 -1
- package/lib/node/utils/resolveMarkdownHintLocales.js +4 -1
- package/package.json +35 -35
|
@@ -11,12 +11,14 @@ const { frontmatter, siteLocale } = useData<DefaultThemeHomePageFrontmatter>()
|
|
|
11
11
|
const isDarkMode = useDarkMode()
|
|
12
12
|
|
|
13
13
|
const heroText = computed(() => {
|
|
14
|
+
// oxlint-disable-next-line eqeqeq
|
|
14
15
|
if (frontmatter.value.heroText === null) {
|
|
15
16
|
return null
|
|
16
17
|
}
|
|
17
18
|
return frontmatter.value.heroText || siteLocale.value.title || 'Hello'
|
|
18
19
|
})
|
|
19
20
|
const tagline = computed(() => {
|
|
21
|
+
// oxlint-disable-next-line eqeqeq
|
|
20
22
|
if (frontmatter.value.tagline === null) {
|
|
21
23
|
return null
|
|
22
24
|
}
|
|
@@ -27,9 +27,11 @@ const isLastItemOfArray = (arrayItem: unknown, array: unknown[]): boolean =>
|
|
|
27
27
|
* The Tab + Click is UIEvent > KeyboardEvent, so the detail is 0.
|
|
28
28
|
*
|
|
29
29
|
* @see https://developer.mozilla.org/en-US/docs/Web/API/UIEvent/detail
|
|
30
|
+
*
|
|
31
|
+
* @param event - The UIEvent triggered by the click
|
|
30
32
|
*/
|
|
31
|
-
const handleDropdown = (
|
|
32
|
-
if (
|
|
33
|
+
const handleDropdown = (event: UIEvent): void => {
|
|
34
|
+
if (event.detail === 0) toggleOpen()
|
|
33
35
|
else toggleOpen(false)
|
|
34
36
|
}
|
|
35
37
|
|
|
@@ -15,9 +15,9 @@ const navbarRepo = useNavbarRepo()
|
|
|
15
15
|
|
|
16
16
|
const isMobile = ref(false)
|
|
17
17
|
|
|
18
|
-
const navbarLabel = computed(
|
|
19
|
-
|
|
20
|
-
|
|
18
|
+
const navbarLabel = computed(
|
|
19
|
+
() => themeLocale.value.navbarLabel ?? 'site navigation',
|
|
20
|
+
)
|
|
21
21
|
|
|
22
22
|
const navbarLinks = computed(() => [
|
|
23
23
|
...navbarConfig.value,
|
|
@@ -22,11 +22,9 @@ useEventListener('keydown', (event): void => {
|
|
|
22
22
|
navigate(nextLink.value.link)
|
|
23
23
|
event.preventDefault()
|
|
24
24
|
}
|
|
25
|
-
} else if (event.key === 'ArrowLeft') {
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
event.preventDefault()
|
|
29
|
-
}
|
|
25
|
+
} else if (event.key === 'ArrowLeft' && prevLink.value) {
|
|
26
|
+
navigate(prevLink.value.link)
|
|
27
|
+
event.preventDefault()
|
|
30
28
|
}
|
|
31
29
|
}
|
|
32
30
|
})
|
|
@@ -33,11 +33,11 @@ const itemClass = computed(() => ({
|
|
|
33
33
|
const isOpenDefault = computed(() =>
|
|
34
34
|
collapsible.value ? isActive.value : true,
|
|
35
35
|
)
|
|
36
|
-
|
|
36
|
+
|
|
37
37
|
const [isOpen, toggleIsOpen] = useToggle(isOpenDefault.value)
|
|
38
|
-
const onClick = (
|
|
38
|
+
const onClick = (event: Event): void => {
|
|
39
39
|
if (collapsible.value) {
|
|
40
|
-
|
|
40
|
+
event.preventDefault()
|
|
41
41
|
// toggle open status on click
|
|
42
42
|
toggleIsOpen()
|
|
43
43
|
}
|
|
@@ -2,6 +2,10 @@ import type { WritableComputedRef } from 'vue';
|
|
|
2
2
|
export type DarkModeRef = WritableComputedRef<boolean>;
|
|
3
3
|
/**
|
|
4
4
|
* Inject dark mode global computed
|
|
5
|
+
*
|
|
6
|
+
* 注入暗色模式全局计算属性
|
|
7
|
+
*
|
|
8
|
+
* @returns Dark mode ref / 暗色模式引用
|
|
5
9
|
*/
|
|
6
10
|
export declare const useDarkMode: () => DarkModeRef;
|
|
7
11
|
/**
|
|
@@ -2,22 +2,26 @@ import { useData } from '@theme/useData';
|
|
|
2
2
|
import { darkModeSymbol } from '@vuepress/helper/client';
|
|
3
3
|
import { usePreferredDark, useStorage, watchImmediate } from '@vueuse/core';
|
|
4
4
|
import { computed, inject, onMounted, onUnmounted, provide } from 'vue';
|
|
5
|
+
const update = (value) => {
|
|
6
|
+
// set `class="dark"` on `<html>` element
|
|
7
|
+
const el = globalThis.document.documentElement;
|
|
8
|
+
// set `data-theme="light|dark"` on `<html>` element
|
|
9
|
+
el.dataset.theme = value ? 'dark' : 'light';
|
|
10
|
+
};
|
|
5
11
|
const applyDarkModeToHTML = (isDarkMode) => {
|
|
6
|
-
const update = (value = isDarkMode.value) => {
|
|
7
|
-
// set `class="dark"` on `<html>` element
|
|
8
|
-
const el = window.document.documentElement;
|
|
9
|
-
// set `data-theme="light|dark"` on `<html>` element
|
|
10
|
-
el.dataset.theme = value ? 'dark' : 'light';
|
|
11
|
-
};
|
|
12
12
|
onMounted(() => {
|
|
13
13
|
watchImmediate(isDarkMode, update);
|
|
14
14
|
});
|
|
15
15
|
onUnmounted(() => {
|
|
16
|
-
update();
|
|
16
|
+
update(isDarkMode.value);
|
|
17
17
|
});
|
|
18
18
|
};
|
|
19
19
|
/**
|
|
20
20
|
* Inject dark mode global computed
|
|
21
|
+
*
|
|
22
|
+
* 注入暗色模式全局计算属性
|
|
23
|
+
*
|
|
24
|
+
* @returns Dark mode ref / 暗色模式引用
|
|
21
25
|
*/
|
|
22
26
|
export const useDarkMode = () => {
|
|
23
27
|
const isDarkMode = inject(darkModeSymbol);
|
|
@@ -4,6 +4,10 @@ export type HeadersRef = Ref<HeaderItem[]>;
|
|
|
4
4
|
export declare const headersSymbol: InjectionKey<HeadersRef>;
|
|
5
5
|
/**
|
|
6
6
|
* Inject headers
|
|
7
|
+
*
|
|
8
|
+
* 注入标题
|
|
9
|
+
*
|
|
10
|
+
* @returns Headers ref / 标题引用
|
|
7
11
|
*/
|
|
8
12
|
export declare const useHeaders: () => HeadersRef;
|
|
9
13
|
export declare const setupHeaders: () => void;
|
|
@@ -6,6 +6,10 @@ import { onContentUpdated } from 'vuepress/client';
|
|
|
6
6
|
export const headersSymbol = Symbol('headers');
|
|
7
7
|
/**
|
|
8
8
|
* Inject headers
|
|
9
|
+
*
|
|
10
|
+
* 注入标题
|
|
11
|
+
*
|
|
12
|
+
* @returns Headers ref / 标题引用
|
|
9
13
|
*/
|
|
10
14
|
export const useHeaders = () => {
|
|
11
15
|
const headers = injectLocal(headersSymbol);
|
|
@@ -23,7 +23,5 @@ const resolveNavbarItem = (item, prefix = '') => {
|
|
|
23
23
|
};
|
|
24
24
|
export const useNavbarConfig = () => {
|
|
25
25
|
const { themeLocale } = useData();
|
|
26
|
-
return computed(() =>
|
|
27
|
-
// eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing
|
|
28
|
-
(themeLocale.value.navbar || []).map((item) => resolveNavbarItem(item)));
|
|
26
|
+
return computed(() => (themeLocale.value.navbar || []).map((item) => resolveNavbarItem(item)));
|
|
29
27
|
};
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import type { ComputedRef } from 'vue';
|
|
2
2
|
import type { NavbarItem } from '../typings.js';
|
|
3
3
|
/**
|
|
4
|
-
*
|
|
4
|
+
* Repository link in navbar
|
|
5
|
+
*
|
|
6
|
+
* @returns Navbar config of repository link / 仓库链接的导航栏配置
|
|
5
7
|
*/
|
|
6
8
|
export declare const useNavbarRepo: () => ComputedRef<NavbarItem[]>;
|
|
@@ -3,7 +3,9 @@ import { useData } from '@theme/useData';
|
|
|
3
3
|
import { computed } from 'vue';
|
|
4
4
|
import { isLinkHttp } from 'vuepress/shared';
|
|
5
5
|
/**
|
|
6
|
-
*
|
|
6
|
+
* Repository link in navbar
|
|
7
|
+
*
|
|
8
|
+
* @returns Navbar config of repository link / 仓库链接的导航栏配置
|
|
7
9
|
*/
|
|
8
10
|
export const useNavbarRepo = () => {
|
|
9
11
|
const { themeLocale } = useData();
|
|
@@ -20,7 +22,7 @@ export const useNavbarRepo = () => {
|
|
|
20
22
|
return null;
|
|
21
23
|
if (themeLocale.value.repoLabel)
|
|
22
24
|
return themeLocale.value.repoLabel;
|
|
23
|
-
if (repoType.value
|
|
25
|
+
if (repoType.value == null)
|
|
24
26
|
return 'Source';
|
|
25
27
|
return repoType.value;
|
|
26
28
|
});
|
|
@@ -2,5 +2,7 @@ import type { ComputedRef } from 'vue';
|
|
|
2
2
|
import type { NavbarItem } from '../typings.js';
|
|
3
3
|
/**
|
|
4
4
|
* Get navbar config of select language dropdown
|
|
5
|
+
*
|
|
6
|
+
* @returns Navbar config of select language dropdown
|
|
5
7
|
*/
|
|
6
8
|
export declare const useNavbarSelectLanguage: () => ComputedRef<NavbarItem[]>;
|
|
@@ -5,6 +5,8 @@ import { computed } from 'vue';
|
|
|
5
5
|
import { useRoute } from 'vuepress/client';
|
|
6
6
|
/**
|
|
7
7
|
* Get navbar config of select language dropdown
|
|
8
|
+
*
|
|
9
|
+
* @returns Navbar config of select language dropdown
|
|
8
10
|
*/
|
|
9
11
|
export const useNavbarSelectLanguage = () => {
|
|
10
12
|
const route = useRoute();
|
|
@@ -25,7 +27,6 @@ export const useNavbarSelectLanguage = () => {
|
|
|
25
27
|
themeLocale.value.selectLanguageText}`,
|
|
26
28
|
children: localePaths.map((targetLocalePath) => {
|
|
27
29
|
// target locale config of this language link
|
|
28
|
-
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
|
|
29
30
|
const targetSiteLocale = site.value.locales?.[targetLocalePath] ?? {};
|
|
30
31
|
const targetThemeLocale = theme.value.locales?.[targetLocalePath] ?? {};
|
|
31
32
|
const targetLang = `${targetSiteLocale.lang}`;
|
|
@@ -8,7 +8,7 @@ export const useNavigate = () => {
|
|
|
8
8
|
if (isLinkAbsolute(url)) {
|
|
9
9
|
// Inner absolute path
|
|
10
10
|
if (route.fullPath !== url)
|
|
11
|
-
router.push(url);
|
|
11
|
+
void router.push(url);
|
|
12
12
|
}
|
|
13
13
|
else if (isLinkWithProtocol(url)) {
|
|
14
14
|
// external url
|
|
@@ -16,7 +16,7 @@ export const useNavigate = () => {
|
|
|
16
16
|
}
|
|
17
17
|
else {
|
|
18
18
|
// relative url
|
|
19
|
-
router.push(encodeURI(url));
|
|
19
|
+
void router.push(encodeURI(url));
|
|
20
20
|
}
|
|
21
21
|
};
|
|
22
22
|
};
|
|
@@ -21,6 +21,11 @@ const resolveFromFrontmatterConfig = (config, currentPath) => {
|
|
|
21
21
|
};
|
|
22
22
|
/**
|
|
23
23
|
* Resolve `prev` or `next` config from sidebar items
|
|
24
|
+
*
|
|
25
|
+
* @param sidebarItems - Sidebar items / 侧边栏配置项
|
|
26
|
+
* @param currentPath - Current route path / 当前路由路径
|
|
27
|
+
* @param offset - The offset to find the target link, -1 for `prev` and 1 for `next` / 查找目标链接的偏移量,-1 表示查找 `prev`,1 表示查找 `next`
|
|
28
|
+
* @returns Resolved link or null if not found
|
|
24
29
|
*/
|
|
25
30
|
const resolveFromSidebarItems = (sidebarItems, currentPath, offset) => {
|
|
26
31
|
const linkIndex = sidebarItems.findIndex((item) => item.link === currentPath);
|
|
@@ -4,31 +4,69 @@ import type { SidebarArrayOptions, SidebarObjectOptions, SidebarOptions } from '
|
|
|
4
4
|
import type { SidebarHeaderItem, SidebarItem } from '../typings.js';
|
|
5
5
|
/**
|
|
6
6
|
* Util to transform page header to sidebar item
|
|
7
|
+
*
|
|
8
|
+
* @param header page header
|
|
9
|
+
* @returns sidebar item from header
|
|
7
10
|
*/
|
|
8
11
|
export declare const resolveSidebarPageHeader: (header: PageHeader) => SidebarHeaderItem;
|
|
12
|
+
/**
|
|
13
|
+
* get sidebar header items from page headers
|
|
14
|
+
*
|
|
15
|
+
* @param headers page headers
|
|
16
|
+
* @returns sidebar header items
|
|
17
|
+
*/
|
|
9
18
|
export declare const resolveSidebarPageHeaders: (headers?: PageHeader[]) => SidebarHeaderItem[];
|
|
10
19
|
/**
|
|
11
20
|
* Resolve current page and its header to sidebar items if the config is `heading`
|
|
21
|
+
*
|
|
22
|
+
* @param page current page data
|
|
23
|
+
* @param headers current page headers
|
|
24
|
+
*
|
|
25
|
+
* @returns sidebar items
|
|
12
26
|
*/
|
|
13
27
|
export declare const resolveSidebarHeadingItem: (page: PageData, headers: PageHeader[]) => SidebarItem[];
|
|
14
28
|
/**
|
|
15
29
|
* Resolve sidebar items if the config is an array
|
|
30
|
+
*
|
|
31
|
+
* @param sidebarConfig sidebar config array
|
|
32
|
+
* @param headers current page headers
|
|
33
|
+
* @param path current page path
|
|
34
|
+
* @param prefix path prefix
|
|
35
|
+
*
|
|
36
|
+
* @returns resolved sidebar items
|
|
16
37
|
*/
|
|
17
38
|
export declare const resolveArraySidebarItems: (sidebarConfig: SidebarArrayOptions, headers: PageHeader[], path: string, prefix?: string) => SidebarItem[];
|
|
18
39
|
/**
|
|
19
40
|
* Resolve sidebar items if the config is a key -> value (path-prefix -> array) object
|
|
41
|
+
*
|
|
42
|
+
* @param sidebarConfig sidebar config object
|
|
43
|
+
* @param page current page data
|
|
44
|
+
* @param headers current page headers
|
|
45
|
+
* @param path current page path
|
|
46
|
+
*
|
|
47
|
+
* @returns resolved sidebar items
|
|
20
48
|
*/
|
|
21
49
|
export declare const resolveMultiSidebarItems: (sidebarConfig: SidebarObjectOptions, page: PageData, headers: PageHeader[], path: string) => SidebarItem[];
|
|
22
50
|
export type SidebarItemsRef = ComputedRef<SidebarItem[]>;
|
|
23
51
|
export declare const sidebarItemsSymbol: InjectionKey<SidebarItemsRef>;
|
|
24
52
|
/**
|
|
25
53
|
* Inject sidebar items global computed
|
|
54
|
+
*
|
|
55
|
+
* @returns sidebar items global computed
|
|
26
56
|
*/
|
|
27
57
|
export declare const useSidebarItems: () => SidebarItemsRef;
|
|
28
58
|
/**
|
|
29
59
|
* Resolve sidebar items global computed
|
|
30
60
|
*
|
|
31
61
|
* It should only be resolved and provided once
|
|
62
|
+
*
|
|
63
|
+
* @param sidebarConfig sidebar config
|
|
64
|
+
* @param page current page data
|
|
65
|
+
* @param path current page path
|
|
66
|
+
* @param routeLocale current route locale
|
|
67
|
+
* @param headers current page headers
|
|
68
|
+
*
|
|
69
|
+
* @returns resolved sidebar items
|
|
32
70
|
*/
|
|
33
71
|
export declare const resolveSidebarItems: (sidebarConfig: SidebarOptions | false, page: PageData, path: string, routeLocale: string, headers: PageHeader[]) => SidebarItem[];
|
|
34
72
|
/**
|
|
@@ -8,16 +8,29 @@ import { useRoutePath } from 'vuepress/client';
|
|
|
8
8
|
import { isPlainObject, isString } from 'vuepress/shared';
|
|
9
9
|
/**
|
|
10
10
|
* Util to transform page header to sidebar item
|
|
11
|
+
*
|
|
12
|
+
* @param header page header
|
|
13
|
+
* @returns sidebar item from header
|
|
11
14
|
*/
|
|
12
15
|
export const resolveSidebarPageHeader = (header) => ({
|
|
13
16
|
text: header.title,
|
|
14
17
|
link: header.link,
|
|
15
|
-
// eslint-disable-next-line @typescript-eslint/no-use-before-define
|
|
16
18
|
children: resolveSidebarPageHeaders(header.children),
|
|
17
19
|
});
|
|
20
|
+
/**
|
|
21
|
+
* get sidebar header items from page headers
|
|
22
|
+
*
|
|
23
|
+
* @param headers page headers
|
|
24
|
+
* @returns sidebar header items
|
|
25
|
+
*/
|
|
18
26
|
export const resolveSidebarPageHeaders = (headers) => headers ? headers.map((header) => resolveSidebarPageHeader(header)) : [];
|
|
19
27
|
/**
|
|
20
28
|
* Resolve current page and its header to sidebar items if the config is `heading`
|
|
29
|
+
*
|
|
30
|
+
* @param page current page data
|
|
31
|
+
* @param headers current page headers
|
|
32
|
+
*
|
|
33
|
+
* @returns sidebar items
|
|
21
34
|
*/
|
|
22
35
|
export const resolveSidebarHeadingItem = (page, headers) => [
|
|
23
36
|
{
|
|
@@ -27,6 +40,13 @@ export const resolveSidebarHeadingItem = (page, headers) => [
|
|
|
27
40
|
];
|
|
28
41
|
/**
|
|
29
42
|
* Resolve sidebar items if the config is an array
|
|
43
|
+
*
|
|
44
|
+
* @param sidebarConfig sidebar config array
|
|
45
|
+
* @param headers current page headers
|
|
46
|
+
* @param path current page path
|
|
47
|
+
* @param prefix path prefix
|
|
48
|
+
*
|
|
49
|
+
* @returns resolved sidebar items
|
|
30
50
|
*/
|
|
31
51
|
export const resolveArraySidebarItems = (sidebarConfig, headers, path, prefix = '') => {
|
|
32
52
|
const handleChildItem = (item, pathPrefix) => {
|
|
@@ -62,18 +82,25 @@ export const resolveArraySidebarItems = (sidebarConfig, headers, path, prefix =
|
|
|
62
82
|
};
|
|
63
83
|
/**
|
|
64
84
|
* Resolve sidebar items if the config is a key -> value (path-prefix -> array) object
|
|
85
|
+
*
|
|
86
|
+
* @param sidebarConfig sidebar config object
|
|
87
|
+
* @param page current page data
|
|
88
|
+
* @param headers current page headers
|
|
89
|
+
* @param path current page path
|
|
90
|
+
*
|
|
91
|
+
* @returns resolved sidebar items
|
|
65
92
|
*/
|
|
66
93
|
export const resolveMultiSidebarItems = (sidebarConfig, page, headers, path) => {
|
|
67
|
-
const sidebarRoutes = keys(sidebarConfig).sort((
|
|
94
|
+
const sidebarRoutes = keys(sidebarConfig).sort((a, b) => b.length - a.length);
|
|
68
95
|
// Find matching config
|
|
69
96
|
for (const base of sidebarRoutes)
|
|
70
97
|
if (startsWith(decodeURI(path), base)) {
|
|
71
98
|
const matched = sidebarConfig[base];
|
|
72
|
-
return matched
|
|
73
|
-
?
|
|
99
|
+
return matched === false
|
|
100
|
+
? []
|
|
101
|
+
: matched === 'heading'
|
|
74
102
|
? resolveSidebarHeadingItem(page, headers)
|
|
75
|
-
: resolveArraySidebarItems(matched, headers, path, base)
|
|
76
|
-
: [];
|
|
103
|
+
: resolveArraySidebarItems(matched, headers, path, base);
|
|
77
104
|
}
|
|
78
105
|
// eslint-disable-next-line no-console
|
|
79
106
|
console.warn(`${decodeURI(path)} is missing sidebar config.`);
|
|
@@ -82,6 +109,8 @@ export const resolveMultiSidebarItems = (sidebarConfig, page, headers, path) =>
|
|
|
82
109
|
export const sidebarItemsSymbol = Symbol('sidebarItems');
|
|
83
110
|
/**
|
|
84
111
|
* Inject sidebar items global computed
|
|
112
|
+
*
|
|
113
|
+
* @returns sidebar items global computed
|
|
85
114
|
*/
|
|
86
115
|
export const useSidebarItems = () => {
|
|
87
116
|
const sidebarItems = inject(sidebarItemsSymbol);
|
|
@@ -94,6 +123,14 @@ export const useSidebarItems = () => {
|
|
|
94
123
|
* Resolve sidebar items global computed
|
|
95
124
|
*
|
|
96
125
|
* It should only be resolved and provided once
|
|
126
|
+
*
|
|
127
|
+
* @param sidebarConfig sidebar config
|
|
128
|
+
* @param page current page data
|
|
129
|
+
* @param path current page path
|
|
130
|
+
* @param routeLocale current route locale
|
|
131
|
+
* @param headers current page headers
|
|
132
|
+
*
|
|
133
|
+
* @returns resolved sidebar items
|
|
97
134
|
*/
|
|
98
135
|
export const resolveSidebarItems = (sidebarConfig, page, path, routeLocale, headers) => {
|
|
99
136
|
// resolve sidebar items according to the config
|
|
@@ -3,5 +3,8 @@ export declare enum DeviceType {
|
|
|
3
3
|
}
|
|
4
4
|
/**
|
|
5
5
|
* add listener to detect screen though device type
|
|
6
|
+
*
|
|
7
|
+
* @param deviceType - Device type to detect / 要检测的设备类型
|
|
8
|
+
* @param callback - Callback function to call when device status changes / 设备状态改变时调用的回调函数
|
|
6
9
|
*/
|
|
7
10
|
export declare const useUpdateDeviceStatus: (deviceType: DeviceType, callback: (width: number) => void) => void;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
// oxlint-disable promise/prefer-await-to-callbacks
|
|
1
2
|
import { useEventListener } from '@vueuse/core';
|
|
2
3
|
import { onMounted } from 'vue';
|
|
3
4
|
import cssVariables from '../styles/_variables.module.scss';
|
|
@@ -10,6 +11,9 @@ const DeviceTypeMap = {
|
|
|
10
11
|
};
|
|
11
12
|
/**
|
|
12
13
|
* add listener to detect screen though device type
|
|
14
|
+
*
|
|
15
|
+
* @param deviceType - Device type to detect / 要检测的设备类型
|
|
16
|
+
* @param callback - Callback function to call when device status changes / 设备状态改变时调用的回调函数
|
|
13
17
|
*/
|
|
14
18
|
export const useUpdateDeviceStatus = (deviceType, callback) => {
|
|
15
19
|
const width = DeviceTypeMap[deviceType];
|
package/lib/client/config.js
CHANGED
|
@@ -16,6 +16,8 @@ export default defineClientConfig({
|
|
|
16
16
|
app.component('Badge', Badge);
|
|
17
17
|
// handle scrollBehavior with transition
|
|
18
18
|
const scrollBehavior = router.options.scrollBehavior;
|
|
19
|
+
// scrollBehavior is a bit hard to typed here
|
|
20
|
+
// oxlint-disable-next-line typescript/explicit-function-return-type
|
|
19
21
|
router.options.scrollBehavior = async (...args) => {
|
|
20
22
|
await useScrollPromise().wait();
|
|
21
23
|
return scrollBehavior(...args);
|
|
@@ -39,13 +39,13 @@ const toggleSidebar = (to?: boolean): void => {
|
|
|
39
39
|
isSidebarOpen.value = typeof to === 'boolean' ? to : !isSidebarOpen.value
|
|
40
40
|
}
|
|
41
41
|
const touchStart = { x: 0, y: 0 }
|
|
42
|
-
const onTouchStart = (
|
|
43
|
-
touchStart.x =
|
|
44
|
-
touchStart.y =
|
|
42
|
+
const onTouchStart = ({ changedTouches }: TouchEvent): void => {
|
|
43
|
+
touchStart.x = changedTouches[0].clientX
|
|
44
|
+
touchStart.y = changedTouches[0].clientY
|
|
45
45
|
}
|
|
46
|
-
const onTouchEnd = (
|
|
47
|
-
const dx =
|
|
48
|
-
const dy =
|
|
46
|
+
const onTouchEnd = ({ changedTouches }: TouchEvent): void => {
|
|
47
|
+
const dx = changedTouches[0].clientX - touchStart.x
|
|
48
|
+
const dy = changedTouches[0].clientY - touchStart.y
|
|
49
49
|
if (Math.abs(dx) > Math.abs(dy) && Math.abs(dx) > 40) {
|
|
50
50
|
if (dx > 0 && touchStart.x <= 80) {
|
|
51
51
|
toggleSidebar(true)
|
|
@@ -67,7 +67,7 @@ const enableExternalLinkIcon = computed(
|
|
|
67
67
|
const containerClass = computed(() => [
|
|
68
68
|
{
|
|
69
69
|
'no-navbar': !shouldShowNavbar.value,
|
|
70
|
-
'no-sidebar':
|
|
70
|
+
'no-sidebar': sidebarItems.value.length === 0,
|
|
71
71
|
'sidebar-open': isSidebarOpen.value,
|
|
72
72
|
'external-link-icon': enableExternalLinkIcon.value,
|
|
73
73
|
},
|
|
@@ -2,6 +2,12 @@ import type { AutoLinkOptions } from '../../shared/index.js';
|
|
|
2
2
|
/**
|
|
3
3
|
* Resolve AutoLink props from string
|
|
4
4
|
*
|
|
5
|
+
* 从字符串解析 AutoLink 属性
|
|
6
|
+
*
|
|
7
|
+
* @param config - The string to resolve / 要解析的字符串
|
|
8
|
+
* @param currentPath - The current route path / 当前路由路径
|
|
9
|
+
* @returns Resolved AutoLink options / 解析后的 AutoLink 选项
|
|
10
|
+
*
|
|
5
11
|
* @example
|
|
6
12
|
* - Input: '/README.md'
|
|
7
13
|
* - Output: { text: 'Home', link: '/' }
|
|
@@ -2,6 +2,12 @@ import { resolveRoute } from 'vuepress/client';
|
|
|
2
2
|
/**
|
|
3
3
|
* Resolve AutoLink props from string
|
|
4
4
|
*
|
|
5
|
+
* 从字符串解析 AutoLink 属性
|
|
6
|
+
*
|
|
7
|
+
* @param config - The string to resolve / 要解析的字符串
|
|
8
|
+
* @param currentPath - The current route path / 当前路由路径
|
|
9
|
+
* @returns Resolved AutoLink options / 解析后的 AutoLink 选项
|
|
10
|
+
*
|
|
5
11
|
* @example
|
|
6
12
|
* - Input: '/README.md'
|
|
7
13
|
* - Output: { text: 'Home', link: '/' }
|
|
@@ -11,7 +11,7 @@ const resolveEditLinkPatterns = ({ docsRepo, editLinkPattern, }) => {
|
|
|
11
11
|
return editLinkPattern;
|
|
12
12
|
}
|
|
13
13
|
const repoType = resolveRepoType(docsRepo);
|
|
14
|
-
if (repoType
|
|
14
|
+
if (repoType != null) {
|
|
15
15
|
return EDIT_LINK_PATTERNS[repoType];
|
|
16
16
|
}
|
|
17
17
|
return null;
|
package/lib/node/typings.d.ts
CHANGED
|
@@ -9,51 +9,51 @@ import type { SeoPluginOptions } from '@vuepress/plugin-seo';
|
|
|
9
9
|
import type { SitemapPluginOptions } from '@vuepress/plugin-sitemap';
|
|
10
10
|
export interface DefaultThemePluginsOptions {
|
|
11
11
|
/**
|
|
12
|
-
* Enable
|
|
12
|
+
* Enable `@vuepress/plugin-active-header-links` or not
|
|
13
13
|
*/
|
|
14
14
|
activeHeaderLinks?: boolean;
|
|
15
15
|
/**
|
|
16
|
-
* Enable
|
|
16
|
+
* Enable `@vuepress/plugin-back-to-top` or not
|
|
17
17
|
*/
|
|
18
18
|
backToTop?: BackToTopPluginOptions | boolean;
|
|
19
19
|
/**
|
|
20
|
-
* Enable
|
|
20
|
+
* Enable `@vuepress/plugin-copy-code` or not
|
|
21
21
|
*/
|
|
22
22
|
copyCode?: CopyCodePluginOptions | boolean;
|
|
23
23
|
/**
|
|
24
|
-
* Enable
|
|
24
|
+
* Enable `@vuepress/plugin-git` or not
|
|
25
25
|
*/
|
|
26
26
|
git?: GitPluginOptions | boolean;
|
|
27
27
|
/**
|
|
28
|
-
* Enable
|
|
28
|
+
* Enable `@vuepress/plugin-markdown-hint` or not
|
|
29
29
|
*/
|
|
30
30
|
hint?: MarkdownHintPluginOptions | boolean;
|
|
31
31
|
/**
|
|
32
|
-
* Enable
|
|
32
|
+
* Enable `@vuepress/plugin-links-check` or not
|
|
33
33
|
*/
|
|
34
34
|
linksCheck?: LinksCheckPluginOptions | boolean;
|
|
35
35
|
/**
|
|
36
|
-
* Enable
|
|
36
|
+
* Enable `@vuepress/plugin-medium-zoom` or not
|
|
37
37
|
*/
|
|
38
38
|
mediumZoom?: boolean;
|
|
39
39
|
/**
|
|
40
|
-
* Enable
|
|
40
|
+
* Enable `@vuepress/plugin-nprogress` or not
|
|
41
41
|
*/
|
|
42
42
|
nprogress?: boolean;
|
|
43
43
|
/**
|
|
44
|
-
* Enable
|
|
44
|
+
* Enable `@vuepress/plugin-prismjs` or not
|
|
45
45
|
*/
|
|
46
46
|
prismjs?: PrismjsPluginOptions | boolean;
|
|
47
47
|
/**
|
|
48
|
-
* Enable
|
|
48
|
+
* Enable `@vuepress/plugin-seo` or not
|
|
49
49
|
*/
|
|
50
50
|
seo?: Partial<SeoPluginOptions> | boolean;
|
|
51
51
|
/**
|
|
52
|
-
* Enable
|
|
52
|
+
* Enable `@vuepress/plugin-sitemap` or not
|
|
53
53
|
*/
|
|
54
54
|
sitemap?: Partial<SitemapPluginOptions> | boolean;
|
|
55
55
|
/**
|
|
56
|
-
* Enable
|
|
56
|
+
* Enable `@vuepress/plugin-markdown-tab` or not
|
|
57
57
|
*/
|
|
58
58
|
tab?: MarkdownTabPluginOptions | boolean;
|
|
59
59
|
}
|
|
@@ -2,8 +2,11 @@ import type { MarkdownHintPluginLocaleData } from '@vuepress/plugin-markdown-hin
|
|
|
2
2
|
import type { LocaleConfig } from 'vuepress/shared';
|
|
3
3
|
import type { DefaultThemeData } from '../../shared/index.js';
|
|
4
4
|
/**
|
|
5
|
-
* Resolve options for
|
|
5
|
+
* Resolve options for `@vuepress/plugin-markdown-container`
|
|
6
6
|
*
|
|
7
7
|
* For custom containers default title
|
|
8
|
+
*
|
|
9
|
+
* @param localeOptions - Locales config from theme options
|
|
10
|
+
* @returns Locales config for `@vuepress/plugin-markdown-container`
|
|
8
11
|
*/
|
|
9
12
|
export declare const resolveMarkdownHintLocales: (localeOptions: DefaultThemeData) => LocaleConfig<MarkdownHintPluginLocaleData>;
|
|
@@ -1,7 +1,10 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Resolve options for
|
|
2
|
+
* Resolve options for `@vuepress/plugin-markdown-container`
|
|
3
3
|
*
|
|
4
4
|
* For custom containers default title
|
|
5
|
+
*
|
|
6
|
+
* @param localeOptions - Locales config from theme options
|
|
7
|
+
* @returns Locales config for `@vuepress/plugin-markdown-container`
|
|
5
8
|
*/
|
|
6
9
|
export const resolveMarkdownHintLocales = (localeOptions) => Object.entries(localeOptions.locales ?? {}).reduce((result, [key, value]) => {
|
|
7
10
|
result[key] = {};
|
package/package.json
CHANGED
|
@@ -1,30 +1,36 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vuepress/theme-default",
|
|
3
|
-
"version": "2.0.0-rc.
|
|
3
|
+
"version": "2.0.0-rc.123",
|
|
4
4
|
"description": "Default theme of VuePress",
|
|
5
5
|
"keywords": [
|
|
6
|
-
"
|
|
7
|
-
"vuepress",
|
|
6
|
+
"default",
|
|
8
7
|
"theme",
|
|
9
|
-
"
|
|
8
|
+
"vuepress",
|
|
9
|
+
"vuepress-theme"
|
|
10
10
|
],
|
|
11
11
|
"homepage": "https://ecosystem.vuejs.press/themes/default/",
|
|
12
12
|
"bugs": {
|
|
13
13
|
"url": "https://github.com/vuepress/ecosystem/issues"
|
|
14
14
|
},
|
|
15
|
+
"license": "MIT",
|
|
16
|
+
"author": "meteorlxy",
|
|
15
17
|
"repository": {
|
|
16
18
|
"type": "git",
|
|
17
19
|
"url": "git+https://github.com/vuepress/ecosystem.git",
|
|
18
20
|
"directory": "themes/theme-default"
|
|
19
21
|
},
|
|
20
|
-
"
|
|
21
|
-
|
|
22
|
+
"files": [
|
|
23
|
+
"lib",
|
|
24
|
+
"templates"
|
|
25
|
+
],
|
|
26
|
+
"type": "module",
|
|
22
27
|
"sideEffects": [
|
|
23
28
|
"./lib/client/components/**/*.vue",
|
|
24
29
|
"./lib/client/layouts/*.vue",
|
|
25
30
|
"./lib/client/styles/*.scss"
|
|
26
31
|
],
|
|
27
|
-
"
|
|
32
|
+
"main": "./lib/node/index.js",
|
|
33
|
+
"types": "./lib/node/index.d.ts",
|
|
28
34
|
"exports": {
|
|
29
35
|
".": "./lib/node/index.js",
|
|
30
36
|
"./client": "./lib/client/index.js",
|
|
@@ -35,35 +41,32 @@
|
|
|
35
41
|
"./lib/*": "./lib/*",
|
|
36
42
|
"./package.json": "./package.json"
|
|
37
43
|
},
|
|
38
|
-
"
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
"lib",
|
|
42
|
-
"templates"
|
|
43
|
-
],
|
|
44
|
+
"publishConfig": {
|
|
45
|
+
"access": "public"
|
|
46
|
+
},
|
|
44
47
|
"dependencies": {
|
|
45
|
-
"@vuepress/helper": "2.0.0-rc.
|
|
46
|
-
"@vuepress/plugin-active-header-links": "2.0.0-rc.
|
|
47
|
-
"@vuepress/plugin-back-to-top": "2.0.0-rc.
|
|
48
|
-
"@vuepress/plugin-copy-code": "2.0.0-rc.
|
|
49
|
-
"@vuepress/plugin-git": "2.0.0-rc.
|
|
50
|
-
"@vuepress/plugin-links-check": "2.0.0-rc.
|
|
51
|
-
"@vuepress/plugin-markdown-hint": "2.0.0-rc.
|
|
52
|
-
"@vuepress/plugin-markdown-tab": "2.0.0-rc.
|
|
53
|
-
"@vuepress/plugin-medium-zoom": "2.0.0-rc.
|
|
54
|
-
"@vuepress/plugin-nprogress": "2.0.0-rc.
|
|
55
|
-
"@vuepress/plugin-palette": "2.0.0-rc.
|
|
56
|
-
"@vuepress/plugin-prismjs": "2.0.0-rc.
|
|
57
|
-
"@vuepress/plugin-seo": "2.0.0-rc.
|
|
58
|
-
"@vuepress/plugin-sitemap": "2.0.0-rc.
|
|
59
|
-
"@vuepress/plugin-theme-data": "2.0.0-rc.
|
|
60
|
-
"@vueuse/core": "^14.2.
|
|
61
|
-
"vue": "^3.5.
|
|
48
|
+
"@vuepress/helper": "2.0.0-rc.123",
|
|
49
|
+
"@vuepress/plugin-active-header-links": "2.0.0-rc.123",
|
|
50
|
+
"@vuepress/plugin-back-to-top": "2.0.0-rc.123",
|
|
51
|
+
"@vuepress/plugin-copy-code": "2.0.0-rc.123",
|
|
52
|
+
"@vuepress/plugin-git": "2.0.0-rc.123",
|
|
53
|
+
"@vuepress/plugin-links-check": "2.0.0-rc.123",
|
|
54
|
+
"@vuepress/plugin-markdown-hint": "2.0.0-rc.123",
|
|
55
|
+
"@vuepress/plugin-markdown-tab": "2.0.0-rc.123",
|
|
56
|
+
"@vuepress/plugin-medium-zoom": "2.0.0-rc.123",
|
|
57
|
+
"@vuepress/plugin-nprogress": "2.0.0-rc.123",
|
|
58
|
+
"@vuepress/plugin-palette": "2.0.0-rc.123",
|
|
59
|
+
"@vuepress/plugin-prismjs": "2.0.0-rc.123",
|
|
60
|
+
"@vuepress/plugin-seo": "2.0.0-rc.123",
|
|
61
|
+
"@vuepress/plugin-sitemap": "2.0.0-rc.123",
|
|
62
|
+
"@vuepress/plugin-theme-data": "2.0.0-rc.123",
|
|
63
|
+
"@vueuse/core": "^14.2.1",
|
|
64
|
+
"vue": "^3.5.28"
|
|
62
65
|
},
|
|
63
66
|
"peerDependencies": {
|
|
64
67
|
"sass": "^1.97.3",
|
|
65
68
|
"sass-embedded": "^1.97.3",
|
|
66
|
-
"sass-loader": "^16.0.
|
|
69
|
+
"sass-loader": "^16.0.7",
|
|
67
70
|
"vuepress": "2.0.0-rc.26"
|
|
68
71
|
},
|
|
69
72
|
"peerDependenciesMeta": {
|
|
@@ -77,8 +80,5 @@
|
|
|
77
80
|
"optional": true
|
|
78
81
|
}
|
|
79
82
|
},
|
|
80
|
-
"
|
|
81
|
-
"access": "public"
|
|
82
|
-
},
|
|
83
|
-
"gitHead": "5dfd2d24f8335f718182701995420907b0a00905"
|
|
83
|
+
"gitHead": "4d944d5826c6ed0487caa973516f9db0194dc934"
|
|
84
84
|
}
|