@vuepress/theme-default 2.0.0-rc.122 → 2.0.0-rc.124
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 +9 -14
- package/lib/client/components/VPNavbar.vue +8 -11
- package/lib/client/components/VPNavbarBrand.vue +4 -5
- 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/index.d.ts +12 -11
- package/lib/client/composables/index.js +1 -11
- package/lib/client/composables/useDarkMode.d.ts +13 -4
- package/lib/client/composables/useDarkMode.js +2 -60
- package/lib/client/composables/useDarkMode.js.map +1 -0
- package/lib/client/composables/useData.d.ts +12 -7
- package/lib/client/composables/useData.js +2 -7
- package/lib/client/composables/useData.js.map +1 -0
- package/lib/client/composables/useEditLink.d.ts +8 -3
- package/lib/client/composables/useEditLink.js +2 -28
- package/lib/client/composables/useEditLink.js.map +1 -0
- package/lib/client/composables/useHeaders.d.ts +15 -6
- package/lib/client/composables/useHeaders.js +2 -38
- package/lib/client/composables/useHeaders.js.map +1 -0
- package/lib/client/composables/useNavbarConfig.d.ts +8 -3
- package/lib/client/composables/useNavbarConfig.js +2 -29
- package/lib/client/composables/useNavbarConfig.js.map +1 -0
- package/lib/client/composables/useNavbarRepo.d.ts +11 -4
- package/lib/client/composables/useNavbarRepo.js +2 -38
- package/lib/client/composables/useNavbarRepo.js.map +1 -0
- package/lib/client/composables/useNavbarSelectLanguage.d.ts +10 -3
- package/lib/client/composables/useNavbarSelectLanguage.js +2 -59
- package/lib/client/composables/useNavbarSelectLanguage.js.map +1 -0
- package/lib/client/composables/useNavigate.d.ts +5 -1
- package/lib/client/composables/useNavigate.js +2 -22
- package/lib/client/composables/useNavigate.js.map +1 -0
- package/lib/client/composables/useRelatedLinks.d.ts +10 -6
- package/lib/client/composables/useRelatedLinks.js +2 -90
- package/lib/client/composables/useRelatedLinks.js.map +1 -0
- package/lib/client/composables/useScrollPromise.d.ts +9 -5
- package/lib/client/composables/useScrollPromise.js +2 -16
- package/lib/client/composables/useScrollPromise.js.map +1 -0
- package/lib/client/composables/useSidebarItems.d.ts +57 -14
- package/lib/client/composables/useSidebarItems.js +2 -127
- package/lib/client/composables/useSidebarItems.js.map +1 -0
- package/lib/client/composables/useUpdateDeviceStatus.d.ts +10 -3
- package/lib/client/composables/useUpdateDeviceStatus.js +2 -30
- package/lib/client/composables/useUpdateDeviceStatus.js.map +1 -0
- package/lib/client/config.d.ts +10 -5
- package/lib/client/config.js +2 -33
- package/lib/client/config.js.map +1 -0
- package/lib/client/index.d.ts +21 -4
- package/lib/client/index.js +1 -2
- package/lib/client/layouts/Layout.vue +9 -12
- package/lib/client/layouts/NotFound.vue +1 -2
- package/lib/client/styles/arrow.scss +1 -2
- package/lib/client/styles/vars.scss +1 -2
- package/lib/client/utils/index.d.ts +6 -5
- package/lib/client/utils/index.js +1 -5
- package/lib/client/utils/isActiveSidebarItem.d.ts +8 -3
- package/lib/client/utils/isActiveSidebarItem.js +2 -20
- package/lib/client/utils/isActiveSidebarItem.js.map +1 -0
- package/lib/client/utils/resolveAutoLink.d.ts +13 -2
- package/lib/client/utils/resolveAutoLink.js +2 -17
- package/lib/client/utils/resolveAutoLink.js.map +1 -0
- package/lib/client/utils/resolveEditLink.d.ts +19 -8
- package/lib/client/utils/resolveEditLink.js +2 -29
- package/lib/client/utils/resolveEditLink.js.map +1 -0
- package/lib/client/utils/resolvePrefix.d.ts +5 -1
- package/lib/client/utils/resolvePrefix.js +2 -4
- package/lib/client/utils/resolvePrefix.js.map +1 -0
- package/lib/client/utils/resolveRepoType.d.ts +6 -2
- package/lib/client/utils/resolveRepoType.js +2 -12
- package/lib/client/utils/resolveRepoType.js.map +1 -0
- package/lib/nav-DikslSJ_.d.ts +36 -0
- package/lib/node/index.d.ts +106 -4
- package/lib/node/index.js +2 -2
- package/lib/node/index.js.map +1 -0
- package/lib/page-F2gyvsdE.d.ts +292 -0
- package/lib/sidebar-FqrQ3PGy.d.ts +53 -0
- package/lib/typings-jKn48KwS.d.ts +19 -0
- package/package.json +47 -38
- package/lib/client/components/global/index.d.ts +0 -2
- package/lib/client/components/global/index.js +0 -2
- package/lib/client/typings.d.ts +0 -13
- package/lib/client/typings.js +0 -1
- package/lib/node/defaultTheme.d.ts +0 -15
- package/lib/node/defaultTheme.js +0 -140
- package/lib/node/typings.d.ts +0 -59
- package/lib/node/typings.js +0 -1
- package/lib/node/utils/assignDefaultLocaleOptions.d.ts +0 -7
- package/lib/node/utils/assignDefaultLocaleOptions.js +0 -51
- package/lib/node/utils/index.d.ts +0 -2
- package/lib/node/utils/index.js +0 -2
- package/lib/node/utils/resolveMarkdownHintLocales.d.ts +0 -9
- package/lib/node/utils/resolveMarkdownHintLocales.js +0 -19
- package/lib/shared/index.d.ts +0 -5
- package/lib/shared/index.js +0 -1
- package/lib/shared/nav.d.ts +0 -32
- package/lib/shared/nav.js +0 -1
- package/lib/shared/navbar.d.ts +0 -21
- package/lib/shared/navbar.js +0 -1
- package/lib/shared/options.d.ts +0 -244
- package/lib/shared/options.js +0 -1
- package/lib/shared/page.d.ts +0 -44
- package/lib/shared/page.js +0 -1
- package/lib/shared/sidebar.d.ts +0 -26
- package/lib/shared/sidebar.js +0 -1
|
@@ -11,15 +11,14 @@ const { frontmatter, siteLocale } = useData<DefaultThemeHomePageFrontmatter>()
|
|
|
11
11
|
const isDarkMode = useDarkMode()
|
|
12
12
|
|
|
13
13
|
const heroText = computed(() => {
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
14
|
+
// oxlint-disable-next-line eqeqeq
|
|
15
|
+
if (frontmatter.value.heroText === null) return null
|
|
16
|
+
|
|
17
17
|
return frontmatter.value.heroText || siteLocale.value.title || 'Hello'
|
|
18
18
|
})
|
|
19
19
|
const tagline = computed(() => {
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
}
|
|
20
|
+
// oxlint-disable-next-line eqeqeq
|
|
21
|
+
if (frontmatter.value.tagline === null) return null
|
|
23
22
|
|
|
24
23
|
return (
|
|
25
24
|
frontmatter.value.tagline ||
|
|
@@ -28,9 +27,9 @@ const tagline = computed(() => {
|
|
|
28
27
|
)
|
|
29
28
|
})
|
|
30
29
|
const heroImage = computed(() => {
|
|
31
|
-
if (isDarkMode.value && frontmatter.value.heroImageDark !== undefined)
|
|
30
|
+
if (isDarkMode.value && frontmatter.value.heroImageDark !== undefined)
|
|
32
31
|
return frontmatter.value.heroImageDark
|
|
33
|
-
|
|
32
|
+
|
|
34
33
|
return frontmatter.value.heroImage
|
|
35
34
|
})
|
|
36
35
|
const heroAlt = computed(
|
|
@@ -39,9 +38,7 @@ const heroAlt = computed(
|
|
|
39
38
|
const heroHeight = computed(() => frontmatter.value.heroHeight ?? 280)
|
|
40
39
|
|
|
41
40
|
const actions = computed(() => {
|
|
42
|
-
if (!Array.isArray(frontmatter.value.actions))
|
|
43
|
-
return []
|
|
44
|
-
}
|
|
41
|
+
if (!Array.isArray(frontmatter.value.actions)) return []
|
|
45
42
|
|
|
46
43
|
return frontmatter.value.actions.map(({ type = 'primary', ...rest }) => ({
|
|
47
44
|
type,
|
|
@@ -59,9 +56,7 @@ const HomeHeroImage: FunctionalComponent = () => {
|
|
|
59
56
|
height: heroHeight.value,
|
|
60
57
|
})
|
|
61
58
|
|
|
62
|
-
if (frontmatter.value.heroImageDark === undefined)
|
|
63
|
-
return img
|
|
64
|
-
}
|
|
59
|
+
if (frontmatter.value.heroImageDark === undefined) return img
|
|
65
60
|
|
|
66
61
|
// wrap hero image with <ClientOnly> to avoid ssr-mismatch
|
|
67
62
|
// when using a different hero image in dark mode
|
|
@@ -29,9 +29,8 @@ const navbarBrand = useTemplateRef<HTMLElement | null>('navbar-brand')
|
|
|
29
29
|
|
|
30
30
|
const linksWrapperMaxWidth = ref(0)
|
|
31
31
|
const linksWrapperStyle = computed(() => {
|
|
32
|
-
if (!linksWrapperMaxWidth.value) {
|
|
33
|
-
|
|
34
|
-
}
|
|
32
|
+
if (!linksWrapperMaxWidth.value) return {}
|
|
33
|
+
|
|
35
34
|
return {
|
|
36
35
|
maxWidth: `${linksWrapperMaxWidth.value}px`,
|
|
37
36
|
}
|
|
@@ -55,14 +54,12 @@ useUpdateDeviceStatus(
|
|
|
55
54
|
const navbarHorizontalPadding =
|
|
56
55
|
getCssValue(navbar.value, 'paddingLeft') +
|
|
57
56
|
getCssValue(navbar.value, 'paddingRight')
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
(navbarBrand.value?.offsetWidth ?? 0)
|
|
65
|
-
}
|
|
57
|
+
linksWrapperMaxWidth.value =
|
|
58
|
+
window.innerWidth < mobileDesktopBreakpoint
|
|
59
|
+
? 0
|
|
60
|
+
: navbar.value!.offsetWidth -
|
|
61
|
+
navbarHorizontalPadding -
|
|
62
|
+
(navbarBrand.value?.offsetWidth ?? 0)
|
|
66
63
|
},
|
|
67
64
|
)
|
|
68
65
|
</script>
|
|
@@ -13,9 +13,9 @@ const navbarBrandLink = computed(
|
|
|
13
13
|
)
|
|
14
14
|
const navbarBrandTitle = computed(() => siteLocale.value.title)
|
|
15
15
|
const navbarBrandLogo = computed(() => {
|
|
16
|
-
if (isDarkMode.value && themeLocale.value.logoDark !== undefined)
|
|
16
|
+
if (isDarkMode.value && themeLocale.value.logoDark !== undefined)
|
|
17
17
|
return themeLocale.value.logoDark
|
|
18
|
-
|
|
18
|
+
|
|
19
19
|
return themeLocale.value.logo
|
|
20
20
|
})
|
|
21
21
|
const navbarBrandLogoAlt = computed(
|
|
@@ -33,9 +33,8 @@ const NavbarBrandLogo: FunctionalComponent = () => {
|
|
|
33
33
|
src: withBase(navbarBrandLogo.value),
|
|
34
34
|
alt: navbarBrandLogoAlt.value,
|
|
35
35
|
})
|
|
36
|
-
if (themeLocale.value.logoDark === undefined)
|
|
37
|
-
|
|
38
|
-
}
|
|
36
|
+
if (themeLocale.value.logoDark === undefined) return img
|
|
37
|
+
|
|
39
38
|
// wrap brand logo with <ClientOnly> to avoid ssr-mismatch
|
|
40
39
|
// when using a different brand logo in dark mode
|
|
41
40
|
return h(ClientOnly, () => img)
|
|
@@ -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
|
}
|
|
@@ -1,11 +1,12 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
1
|
+
import { DarkModeRef, setupDarkMode, useDarkMode } from "./useDarkMode.js";
|
|
2
|
+
import { Data, useData } from "./useData.js";
|
|
3
|
+
import { useEditLink } from "./useEditLink.js";
|
|
4
|
+
import { useNavigate } from "./useNavigate.js";
|
|
5
|
+
import { useNavbarConfig } from "./useNavbarConfig.js";
|
|
6
|
+
import { useNavbarRepo } from "./useNavbarRepo.js";
|
|
7
|
+
import { useNavbarSelectLanguage } from "./useNavbarSelectLanguage.js";
|
|
8
|
+
import { useRelatedLinks } from "./useRelatedLinks.js";
|
|
9
|
+
import { ScrollPromise, useScrollPromise } from "./useScrollPromise.js";
|
|
10
|
+
import { SidebarItemsRef, resolveArraySidebarItems, resolveMultiSidebarItems, resolveSidebarHeadingItem, resolveSidebarItems, resolveSidebarPageHeader, resolveSidebarPageHeaders, setupSidebarItems, sidebarItemsSymbol, useSidebarItems } from "./useSidebarItems.js";
|
|
11
|
+
import { DeviceType, useUpdateDeviceStatus } from "./useUpdateDeviceStatus.js";
|
|
12
|
+
export { DarkModeRef, Data, DeviceType, ScrollPromise, SidebarItemsRef, resolveArraySidebarItems, resolveMultiSidebarItems, resolveSidebarHeadingItem, resolveSidebarItems, resolveSidebarPageHeader, resolveSidebarPageHeaders, setupDarkMode, setupSidebarItems, sidebarItemsSymbol, useDarkMode, useData, useEditLink, useNavbarConfig, useNavbarRepo, useNavbarSelectLanguage, useNavigate, useRelatedLinks, useScrollPromise, useSidebarItems, useUpdateDeviceStatus };
|
|
@@ -1,11 +1 @@
|
|
|
1
|
-
|
|
2
|
-
export * from './useData.js';
|
|
3
|
-
export * from './useEditLink.js';
|
|
4
|
-
export * from './useNavigate.js';
|
|
5
|
-
export * from './useNavbarConfig.js';
|
|
6
|
-
export * from './useNavbarRepo.js';
|
|
7
|
-
export * from './useNavbarSelectLanguage.js';
|
|
8
|
-
export * from './useRelatedLinks.js';
|
|
9
|
-
export * from './useScrollPromise.js';
|
|
10
|
-
export * from './useSidebarItems.js';
|
|
11
|
-
export * from './useUpdateDeviceStatus.js';
|
|
1
|
+
import{setupDarkMode as e,useDarkMode as t}from"./useDarkMode.js";import{useData as n}from"./useData.js";import{useEditLink as r}from"./useEditLink.js";import{useNavigate as i}from"./useNavigate.js";import{useNavbarConfig as a}from"./useNavbarConfig.js";import{useNavbarRepo as o}from"./useNavbarRepo.js";import{useNavbarSelectLanguage as s}from"./useNavbarSelectLanguage.js";import{useRelatedLinks as c}from"./useRelatedLinks.js";import{useScrollPromise as l}from"./useScrollPromise.js";import{resolveArraySidebarItems as u,resolveMultiSidebarItems as d,resolveSidebarHeadingItem as f,resolveSidebarItems as p,resolveSidebarPageHeader as m,resolveSidebarPageHeaders as h,setupSidebarItems as g,sidebarItemsSymbol as _,useSidebarItems as v}from"./useSidebarItems.js";import{DeviceType as y,useUpdateDeviceStatus as b}from"./useUpdateDeviceStatus.js";export{y as DeviceType,u as resolveArraySidebarItems,d as resolveMultiSidebarItems,f as resolveSidebarHeadingItem,p as resolveSidebarItems,m as resolveSidebarPageHeader,h as resolveSidebarPageHeaders,e as setupDarkMode,g as setupSidebarItems,_ as sidebarItemsSymbol,t as useDarkMode,n as useData,r as useEditLink,a as useNavbarConfig,o as useNavbarRepo,s as useNavbarSelectLanguage,i as useNavigate,c as useRelatedLinks,l as useScrollPromise,v as useSidebarItems,b as useUpdateDeviceStatus};
|
|
@@ -1,10 +1,19 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
1
|
+
import { WritableComputedRef } from "vue";
|
|
2
|
+
|
|
3
|
+
//#region src/client/composables/useDarkMode.d.ts
|
|
4
|
+
type DarkModeRef = WritableComputedRef<boolean>;
|
|
3
5
|
/**
|
|
4
6
|
* Inject dark mode global computed
|
|
7
|
+
*
|
|
8
|
+
* 注入暗色模式全局计算属性
|
|
9
|
+
*
|
|
10
|
+
* @returns Dark mode ref / 暗色模式引用
|
|
5
11
|
*/
|
|
6
|
-
|
|
12
|
+
declare const useDarkMode: () => DarkModeRef;
|
|
7
13
|
/**
|
|
8
14
|
* Create dark mode ref and provide as global computed in setup
|
|
9
15
|
*/
|
|
10
|
-
|
|
16
|
+
declare const setupDarkMode: () => void;
|
|
17
|
+
//#endregion
|
|
18
|
+
export { DarkModeRef, setupDarkMode, useDarkMode };
|
|
19
|
+
//# sourceMappingURL=useDarkMode.d.ts.map
|
|
@@ -1,60 +1,2 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
import { usePreferredDark, useStorage, watchImmediate } from '@vueuse/core';
|
|
4
|
-
import { computed, inject, onMounted, onUnmounted, provide } from 'vue';
|
|
5
|
-
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
|
-
onMounted(() => {
|
|
13
|
-
watchImmediate(isDarkMode, update);
|
|
14
|
-
});
|
|
15
|
-
onUnmounted(() => {
|
|
16
|
-
update();
|
|
17
|
-
});
|
|
18
|
-
};
|
|
19
|
-
/**
|
|
20
|
-
* Inject dark mode global computed
|
|
21
|
-
*/
|
|
22
|
-
export const useDarkMode = () => {
|
|
23
|
-
const isDarkMode = inject(darkModeSymbol);
|
|
24
|
-
if (!isDarkMode) {
|
|
25
|
-
throw new Error('useDarkMode() is called without provider.');
|
|
26
|
-
}
|
|
27
|
-
return isDarkMode;
|
|
28
|
-
};
|
|
29
|
-
/**
|
|
30
|
-
* Create dark mode ref and provide as global computed in setup
|
|
31
|
-
*/
|
|
32
|
-
export const setupDarkMode = () => {
|
|
33
|
-
const { themeLocale } = useData();
|
|
34
|
-
const isDarkPreferred = usePreferredDark();
|
|
35
|
-
const darkStorage = useStorage('vuepress-color-scheme', themeLocale.value.colorMode);
|
|
36
|
-
const isDarkMode = computed({
|
|
37
|
-
get() {
|
|
38
|
-
// disable color mode switching
|
|
39
|
-
if (!themeLocale.value.colorModeSwitch) {
|
|
40
|
-
return themeLocale.value.colorMode === 'dark';
|
|
41
|
-
}
|
|
42
|
-
// auto detected from prefers-color-scheme
|
|
43
|
-
if (darkStorage.value === 'auto') {
|
|
44
|
-
return isDarkPreferred.value;
|
|
45
|
-
}
|
|
46
|
-
// storage value
|
|
47
|
-
return darkStorage.value === 'dark';
|
|
48
|
-
},
|
|
49
|
-
set(val) {
|
|
50
|
-
if (val === isDarkPreferred.value) {
|
|
51
|
-
darkStorage.value = 'auto';
|
|
52
|
-
}
|
|
53
|
-
else {
|
|
54
|
-
darkStorage.value = val ? 'dark' : 'light';
|
|
55
|
-
}
|
|
56
|
-
},
|
|
57
|
-
});
|
|
58
|
-
provide(darkModeSymbol, isDarkMode);
|
|
59
|
-
applyDarkModeToHTML(isDarkMode);
|
|
60
|
-
};
|
|
1
|
+
import{darkModeSymbol as e}from"@vuepress/helper/client";import{useData as t}from"@theme/useData";import{usePreferredDark as n,useStorage as r,watchImmediate as i}from"@vueuse/core";import{computed as a,inject as o,onMounted as s,onUnmounted as c,provide as l}from"vue";const u=e=>{let t=globalThis.document.documentElement;t.dataset.theme=e?`dark`:`light`},d=e=>{s(()=>{i(e,u)}),c(()=>{u(e.value)})},f=()=>{let t=o(e);if(!t)throw Error(`useDarkMode() is called without provider.`);return t},p=()=>{let{themeLocale:i}=t(),o=n(),s=r(`vuepress-color-scheme`,i.value.colorMode),c=a({get(){return i.value.colorModeSwitch?s.value===`auto`?o.value:s.value===`dark`:i.value.colorMode===`dark`},set(e){e===o.value?s.value=`auto`:s.value=e?`dark`:`light`}});l(e,c),d(c)};export{p as setupDarkMode,f as useDarkMode};
|
|
2
|
+
//# sourceMappingURL=useDarkMode.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useDarkMode.js","names":[],"sources":["../../../src/client/composables/useDarkMode.ts"],"sourcesContent":["import { useData } from '@theme/useData'\nimport { darkModeSymbol } from '@vuepress/helper/client'\nimport { usePreferredDark, useStorage, watchImmediate } from '@vueuse/core'\nimport type { WritableComputedRef } from 'vue'\nimport { computed, inject, onMounted, onUnmounted, provide } from 'vue'\n\nexport type DarkModeRef = WritableComputedRef<boolean>\n\nconst update = (value: boolean): void => {\n // set `class=\"dark\"` on `<html>` element\n const el = globalThis.document.documentElement\n\n // set `data-theme=\"light|dark\"` on `<html>` element\n el.dataset.theme = value ? 'dark' : 'light'\n}\n\nconst applyDarkModeToHTML = (isDarkMode: DarkModeRef): void => {\n onMounted(() => {\n watchImmediate(isDarkMode, update)\n })\n\n onUnmounted(() => {\n update(isDarkMode.value)\n })\n}\n\n/**\n * Inject dark mode global computed\n *\n * 注入暗色模式全局计算属性\n *\n * @returns Dark mode ref / 暗色模式引用\n */\nexport const useDarkMode = (): DarkModeRef => {\n const isDarkMode = inject<WritableComputedRef<boolean>>(darkModeSymbol)\n if (!isDarkMode) throw new Error('useDarkMode() is called without provider.')\n\n return isDarkMode\n}\n\n/**\n * Create dark mode ref and provide as global computed in setup\n */\nexport const setupDarkMode = (): void => {\n const { themeLocale } = useData()\n const isDarkPreferred = usePreferredDark()\n const darkStorage = useStorage(\n 'vuepress-color-scheme',\n themeLocale.value.colorMode,\n )\n\n const isDarkMode = computed<boolean>({\n get() {\n // disable color mode switching\n if (!themeLocale.value.colorModeSwitch)\n return themeLocale.value.colorMode === 'dark'\n\n // auto detected from prefers-color-scheme\n if (darkStorage.value === 'auto') return isDarkPreferred.value\n\n // storage value\n return darkStorage.value === 'dark'\n },\n set(val) {\n if (val === isDarkPreferred.value) darkStorage.value = 'auto'\n else darkStorage.value = val ? 'dark' : 'light'\n },\n })\n provide(darkModeSymbol, isDarkMode)\n\n applyDarkModeToHTML(isDarkMode)\n}\n"],"mappings":"8QAQA,MAAM,EAAU,GAAyB,CAEvC,IAAM,EAAK,WAAW,SAAS,gBAG/B,EAAG,QAAQ,MAAQ,EAAQ,OAAS,SAGhC,EAAuB,GAAkC,CAC7D,MAAgB,CACd,EAAe,EAAY,EAAO,EAClC,CAEF,MAAkB,CAChB,EAAO,EAAW,MAAM,EACxB,EAUS,MAAiC,CAC5C,IAAM,EAAa,EAAqC,EAAe,CACvE,GAAI,CAAC,EAAY,MAAU,MAAM,4CAA4C,CAE7E,OAAO,GAMI,MAA4B,CACvC,GAAM,CAAE,eAAgB,GAAS,CAC3B,EAAkB,GAAkB,CACpC,EAAc,EAClB,wBACA,EAAY,MAAM,UACnB,CAEK,EAAa,EAAkB,CACnC,KAAM,CASJ,OAPK,EAAY,MAAM,gBAInB,EAAY,QAAU,OAAe,EAAgB,MAGlD,EAAY,QAAU,OANpB,EAAY,MAAM,YAAc,QAQ3C,IAAI,EAAK,CACH,IAAQ,EAAgB,MAAO,EAAY,MAAQ,OAClD,EAAY,MAAQ,EAAM,OAAS,SAE3C,CAAC,CACF,EAAQ,EAAgB,EAAW,CAEnC,EAAoB,EAAW"}
|
|
@@ -1,8 +1,13 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
1
|
+
import { a as DefaultThemeData, n as DefaultThemeNormalPageFrontmatter, r as DefaultThemePageData } from "../../page-F2gyvsdE.js";
|
|
2
|
+
import { ClientData } from "vuepress/client";
|
|
3
|
+
import { ThemeDataRef, ThemeLocaleDataRef } from "@vuepress/plugin-theme-data/client";
|
|
4
|
+
|
|
5
|
+
//#region src/client/composables/useData.d.ts
|
|
6
|
+
interface Data<PageFrontmatter extends Record<string, unknown> = DefaultThemeNormalPageFrontmatter, PageData extends Record<string, unknown> = DefaultThemePageData> extends Pick<ClientData<PageFrontmatter, PageData>, 'frontmatter' | 'head' | 'headTitle' | 'lang' | 'layouts' | 'page' | 'pageComponent' | 'pageLayout' | 'redirects' | 'routeLocale' | 'routePath' | 'routes' | 'site' | 'siteLocale'> {
|
|
7
|
+
theme: ThemeDataRef<DefaultThemeData>;
|
|
8
|
+
themeLocale: ThemeLocaleDataRef<DefaultThemeData>;
|
|
7
9
|
}
|
|
8
|
-
|
|
10
|
+
declare const useData: <PageFrontmatter extends Record<string, unknown> = DefaultThemeNormalPageFrontmatter, PageData extends Record<string, unknown> = DefaultThemePageData>() => Data<PageFrontmatter, PageData>;
|
|
11
|
+
//#endregion
|
|
12
|
+
export { Data, useData };
|
|
13
|
+
//# sourceMappingURL=useData.d.ts.map
|
|
@@ -1,7 +1,2 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
export const useData = () => ({
|
|
4
|
-
..._useData(),
|
|
5
|
-
theme: useThemeData(),
|
|
6
|
-
themeLocale: useThemeLocaleData(),
|
|
7
|
-
});
|
|
1
|
+
import{useData as e}from"vuepress/client";import{useThemeData as t,useThemeLocaleData as n}from"@vuepress/plugin-theme-data/client";const r=()=>({...e(),theme:t(),themeLocale:n()});export{r as useData};
|
|
2
|
+
//# sourceMappingURL=useData.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useData.js","names":["_useData"],"sources":["../../../src/client/composables/useData.ts"],"sourcesContent":["import type {\n ThemeDataRef,\n ThemeLocaleDataRef,\n} from '@vuepress/plugin-theme-data/client'\nimport {\n useThemeData,\n useThemeLocaleData,\n} from '@vuepress/plugin-theme-data/client'\nimport type { ClientData } from 'vuepress/client'\nimport { useData as _useData } from 'vuepress/client'\nimport type {\n DefaultThemeData,\n DefaultThemeNormalPageFrontmatter,\n DefaultThemePageData,\n} from '../../shared/index.js'\n\nexport interface Data<\n PageFrontmatter extends Record<string, unknown> =\n DefaultThemeNormalPageFrontmatter,\n PageData extends Record<string, unknown> = DefaultThemePageData,\n> extends Pick<\n ClientData<PageFrontmatter, PageData>,\n | 'frontmatter'\n | 'head'\n | 'headTitle'\n | 'lang'\n | 'layouts'\n | 'page'\n | 'pageComponent'\n | 'pageLayout'\n | 'redirects'\n | 'routeLocale'\n | 'routePath'\n | 'routes'\n | 'site'\n | 'siteLocale'\n> {\n theme: ThemeDataRef<DefaultThemeData>\n themeLocale: ThemeLocaleDataRef<DefaultThemeData>\n}\n\nexport const useData = <\n PageFrontmatter extends Record<string, unknown> =\n DefaultThemeNormalPageFrontmatter,\n PageData extends Record<string, unknown> = DefaultThemePageData,\n>(): Data<PageFrontmatter, PageData> => ({\n ..._useData<PageFrontmatter, PageData>(),\n theme: useThemeData<DefaultThemeData>(),\n themeLocale: useThemeLocaleData<DefaultThemeData>(),\n})\n"],"mappings":"oIAyCA,MAAa,OAI4B,CACvC,GAAGA,GAAqC,CACxC,MAAO,GAAgC,CACvC,YAAa,GAAsC,CACpD"}
|
|
@@ -1,3 +1,8 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
|
|
1
|
+
import { AutoLinkConfig } from "vuepress/client";
|
|
2
|
+
import { ComputedRef } from "vue";
|
|
3
|
+
|
|
4
|
+
//#region src/client/composables/useEditLink.d.ts
|
|
5
|
+
declare const useEditLink: () => ComputedRef<AutoLinkConfig | null>;
|
|
6
|
+
//#endregion
|
|
7
|
+
export { useEditLink };
|
|
8
|
+
//# sourceMappingURL=useEditLink.d.ts.map
|
|
@@ -1,28 +1,2 @@
|
|
|
1
|
-
import { resolveEditLink }
|
|
2
|
-
|
|
3
|
-
import { computed } from 'vue';
|
|
4
|
-
export const useEditLink = () => {
|
|
5
|
-
const { frontmatter, page, themeLocale } = useData();
|
|
6
|
-
return computed(() => {
|
|
7
|
-
const showEditLink = frontmatter.value.editLink ?? themeLocale.value.editLink ?? true;
|
|
8
|
-
if (!showEditLink) {
|
|
9
|
-
return null;
|
|
10
|
-
}
|
|
11
|
-
const { repo, docsRepo = repo, docsBranch = 'main', docsDir = '', editLinkText, } = themeLocale.value;
|
|
12
|
-
if (!docsRepo)
|
|
13
|
-
return null;
|
|
14
|
-
const editLink = resolveEditLink({
|
|
15
|
-
docsRepo,
|
|
16
|
-
docsBranch,
|
|
17
|
-
docsDir,
|
|
18
|
-
filePathRelative: page.value.filePathRelative,
|
|
19
|
-
editLinkPattern: frontmatter.value.editLinkPattern ?? themeLocale.value.editLinkPattern,
|
|
20
|
-
});
|
|
21
|
-
if (!editLink)
|
|
22
|
-
return null;
|
|
23
|
-
return {
|
|
24
|
-
text: editLinkText ?? 'Edit this page',
|
|
25
|
-
link: editLink,
|
|
26
|
-
};
|
|
27
|
-
});
|
|
28
|
-
};
|
|
1
|
+
import{useData as e}from"@theme/useData";import{computed as t}from"vue";import{resolveEditLink as n}from"@theme/resolveEditLink";const r=()=>{let{frontmatter:r,page:i,themeLocale:a}=e();return t(()=>{if(!(r.value.editLink??a.value.editLink??!0))return null;let{repo:e,docsRepo:t=e,docsBranch:o=`main`,docsDir:s=``,editLinkText:c}=a.value;if(!t)return null;let l=n({docsRepo:t,docsBranch:o,docsDir:s,filePathRelative:i.value.filePathRelative,editLinkPattern:r.value.editLinkPattern??a.value.editLinkPattern});return l?{text:c??`Edit this page`,link:l}:null})};export{r as useEditLink};
|
|
2
|
+
//# sourceMappingURL=useEditLink.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useEditLink.js","names":[],"sources":["../../../src/client/composables/useEditLink.ts"],"sourcesContent":["import { resolveEditLink } from '@theme/resolveEditLink'\nimport { useData } from '@theme/useData'\nimport type { ComputedRef } from 'vue'\nimport { computed } from 'vue'\nimport type { AutoLinkConfig } from 'vuepress/client'\n\nexport const useEditLink = (): ComputedRef<AutoLinkConfig | null> => {\n const { frontmatter, page, themeLocale } = useData()\n\n return computed(() => {\n const showEditLink =\n frontmatter.value.editLink ?? themeLocale.value.editLink ?? true\n if (!showEditLink) return null\n\n const {\n repo,\n docsRepo = repo,\n docsBranch = 'main',\n docsDir = '',\n editLinkText,\n } = themeLocale.value\n\n if (!docsRepo) return null\n\n const editLink = resolveEditLink({\n docsRepo,\n docsBranch,\n docsDir,\n filePathRelative: page.value.filePathRelative,\n editLinkPattern:\n frontmatter.value.editLinkPattern ?? themeLocale.value.editLinkPattern,\n })\n\n if (!editLink) return null\n\n return {\n text: editLinkText ?? 'Edit this page',\n link: editLink,\n }\n })\n}\n"],"mappings":"iIAMA,MAAa,MAAwD,CACnE,GAAM,CAAE,cAAa,OAAM,eAAgB,GAAS,CAEpD,OAAO,MAAe,CAGpB,GAAI,EADF,EAAY,MAAM,UAAY,EAAY,MAAM,UAAY,IAC3C,OAAO,KAE1B,GAAM,CACJ,OACA,WAAW,EACX,aAAa,OACb,UAAU,GACV,gBACE,EAAY,MAEhB,GAAI,CAAC,EAAU,OAAO,KAEtB,IAAM,EAAW,EAAgB,CAC/B,WACA,aACA,UACA,iBAAkB,EAAK,MAAM,iBAC7B,gBACE,EAAY,MAAM,iBAAmB,EAAY,MAAM,gBAC1D,CAAC,CAIF,OAFK,EAEE,CACL,KAAM,GAAgB,iBACtB,KAAM,EACP,CALqB,MAMtB"}
|
|
@@ -1,9 +1,18 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
import { HeaderItem } from "@vuepress/helper/client";
|
|
2
|
+
import { InjectionKey, Ref } from "vue";
|
|
3
|
+
|
|
4
|
+
//#region src/client/composables/useHeaders.d.ts
|
|
5
|
+
type HeadersRef = Ref<HeaderItem[]>;
|
|
6
|
+
declare const headersSymbol: InjectionKey<HeadersRef>;
|
|
5
7
|
/**
|
|
6
8
|
* Inject headers
|
|
9
|
+
*
|
|
10
|
+
* 注入标题
|
|
11
|
+
*
|
|
12
|
+
* @returns Headers ref / 标题引用
|
|
7
13
|
*/
|
|
8
|
-
|
|
9
|
-
|
|
14
|
+
declare const useHeaders: () => HeadersRef;
|
|
15
|
+
declare const setupHeaders: () => void;
|
|
16
|
+
//#endregion
|
|
17
|
+
export { HeadersRef, headersSymbol, setupHeaders, useHeaders };
|
|
18
|
+
//# sourceMappingURL=useHeaders.d.ts.map
|
|
@@ -1,38 +1,2 @@
|
|
|
1
|
-
import { useData }
|
|
2
|
-
|
|
3
|
-
import { injectLocal, provideLocal } from '@vueuse/core';
|
|
4
|
-
import { computed, ref } from 'vue';
|
|
5
|
-
import { onContentUpdated } from 'vuepress/client';
|
|
6
|
-
export const headersSymbol = Symbol('headers');
|
|
7
|
-
/**
|
|
8
|
-
* Inject headers
|
|
9
|
-
*/
|
|
10
|
-
export const useHeaders = () => {
|
|
11
|
-
const headers = injectLocal(headersSymbol);
|
|
12
|
-
if (!headers) {
|
|
13
|
-
throw new Error('useHeaders() is called without provider.');
|
|
14
|
-
}
|
|
15
|
-
return headers;
|
|
16
|
-
};
|
|
17
|
-
export const setupHeaders = () => {
|
|
18
|
-
const { frontmatter, themeLocale } = useData();
|
|
19
|
-
const headersRef = ref([]);
|
|
20
|
-
const levels = computed(() => frontmatter.value.sidebarDepth ?? themeLocale.value.sidebarDepth ?? 2);
|
|
21
|
-
const updateHeaders = () => {
|
|
22
|
-
if (levels.value <= 0) {
|
|
23
|
-
headersRef.value = [];
|
|
24
|
-
return;
|
|
25
|
-
}
|
|
26
|
-
headersRef.value = getHeaders({
|
|
27
|
-
levels: [2, levels.value + 1],
|
|
28
|
-
ignore: ['.vp-badge'],
|
|
29
|
-
});
|
|
30
|
-
};
|
|
31
|
-
provideLocal(headersSymbol, headersRef);
|
|
32
|
-
onContentUpdated((reason) => {
|
|
33
|
-
if (reason === 'beforeUnmount')
|
|
34
|
-
headersRef.value = [];
|
|
35
|
-
else
|
|
36
|
-
updateHeaders();
|
|
37
|
-
});
|
|
38
|
-
};
|
|
1
|
+
import{getHeaders as e}from"@vuepress/helper/client";import{onContentUpdated as t}from"vuepress/client";import{useData as n}from"@theme/useData";import{injectLocal as r,provideLocal as i}from"@vueuse/core";import{computed as a,ref as o}from"vue";const s=Symbol(`headers`),c=()=>{let e=r(s);if(!e)throw Error(`useHeaders() is called without provider.`);return e},l=()=>{let{frontmatter:r,themeLocale:c}=n(),l=o([]),u=a(()=>r.value.sidebarDepth??c.value.sidebarDepth??2),d=()=>{if(u.value<=0){l.value=[];return}l.value=e({levels:[2,u.value+1],ignore:[`.vp-badge`]})};i(s,l),t(e=>{e===`beforeUnmount`?l.value=[]:d()})};export{s as headersSymbol,l as setupHeaders,c as useHeaders};
|
|
2
|
+
//# sourceMappingURL=useHeaders.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useHeaders.js","names":["useData"],"sources":["../../../src/client/composables/useHeaders.ts"],"sourcesContent":["import { useData } from '@theme/useData'\nimport type { HeaderItem } from '@vuepress/helper/client'\nimport { getHeaders } from '@vuepress/helper/client'\nimport { injectLocal, provideLocal } from '@vueuse/core'\nimport type { InjectionKey, Ref } from 'vue'\nimport { computed, ref } from 'vue'\nimport { onContentUpdated } from 'vuepress/client'\n\nexport type HeadersRef = Ref<HeaderItem[]>\n\nexport const headersSymbol: InjectionKey<HeadersRef> = Symbol('headers')\n\n/**\n * Inject headers\n *\n * 注入标题\n *\n * @returns Headers ref / 标题引用\n */\nexport const useHeaders = (): HeadersRef => {\n const headers = injectLocal(headersSymbol)\n\n if (!headers) throw new Error('useHeaders() is called without provider.')\n\n return headers\n}\n\nexport const setupHeaders = (): void => {\n const { frontmatter, themeLocale } = useData()\n\n const headersRef: HeadersRef = ref([])\n const levels = computed(\n () => frontmatter.value.sidebarDepth ?? themeLocale.value.sidebarDepth ?? 2,\n )\n\n const updateHeaders = (): void => {\n if (levels.value <= 0) {\n headersRef.value = []\n return\n }\n\n headersRef.value = getHeaders({\n levels: [2, levels.value + 1],\n ignore: ['.vp-badge'],\n })\n }\n\n provideLocal(headersSymbol, headersRef)\n\n onContentUpdated((reason) => {\n if (reason === 'beforeUnmount') headersRef.value = []\n else updateHeaders()\n })\n}\n"],"mappings":"sPAUA,MAAa,EAA0C,OAAO,UAAU,CAS3D,MAA+B,CAC1C,IAAM,EAAU,EAAY,EAAc,CAE1C,GAAI,CAAC,EAAS,MAAU,MAAM,2CAA2C,CAEzE,OAAO,GAGI,MAA2B,CACtC,GAAM,CAAE,cAAa,eAAgBA,GAAS,CAExC,EAAyB,EAAI,EAAE,CAAC,CAChC,EAAS,MACP,EAAY,MAAM,cAAgB,EAAY,MAAM,cAAgB,EAC3E,CAEK,MAA4B,CAChC,GAAI,EAAO,OAAS,EAAG,CACrB,EAAW,MAAQ,EAAE,CACrB,OAGF,EAAW,MAAQ,EAAW,CAC5B,OAAQ,CAAC,EAAG,EAAO,MAAQ,EAAE,CAC7B,OAAQ,CAAC,YAAY,CACtB,CAAC,EAGJ,EAAa,EAAe,EAAW,CAEvC,EAAkB,GAAW,CACvB,IAAW,gBAAiB,EAAW,MAAQ,EAAE,CAChD,GAAe,EACpB"}
|
|
@@ -1,3 +1,8 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
|
|
1
|
+
import { t as NavbarItem } from "../../typings-jKn48KwS.js";
|
|
2
|
+
import { ComputedRef } from "vue";
|
|
3
|
+
|
|
4
|
+
//#region src/client/composables/useNavbarConfig.d.ts
|
|
5
|
+
declare const useNavbarConfig: () => ComputedRef<NavbarItem[]>;
|
|
6
|
+
//#endregion
|
|
7
|
+
export { useNavbarConfig };
|
|
8
|
+
//# sourceMappingURL=useNavbarConfig.d.ts.map
|
|
@@ -1,29 +1,2 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
import { useData } from '@theme/useData';
|
|
4
|
-
import { isLinkRelative } from '@vuepress/helper/client';
|
|
5
|
-
import { computed } from 'vue';
|
|
6
|
-
import { isString } from 'vuepress/shared';
|
|
7
|
-
const resolveNavbarItem = (item, prefix = '') => {
|
|
8
|
-
if (isString(item)) {
|
|
9
|
-
return resolveAutoLink(resolvePrefix(prefix, item));
|
|
10
|
-
}
|
|
11
|
-
if ('children' in item) {
|
|
12
|
-
return {
|
|
13
|
-
...item,
|
|
14
|
-
children: item.children.map((child) => resolveNavbarItem(child, resolvePrefix(prefix, item.prefix))),
|
|
15
|
-
};
|
|
16
|
-
}
|
|
17
|
-
return {
|
|
18
|
-
...item,
|
|
19
|
-
link: isLinkRelative(item.link)
|
|
20
|
-
? resolveAutoLink(resolvePrefix(prefix, item.link)).link
|
|
21
|
-
: item.link,
|
|
22
|
-
};
|
|
23
|
-
};
|
|
24
|
-
export const useNavbarConfig = () => {
|
|
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)));
|
|
29
|
-
};
|
|
1
|
+
import{isString as e}from"vuepress/shared";import{isLinkRelative as t}from"@vuepress/helper/client";import{useData as n}from"@theme/useData";import{computed as r}from"vue";import{resolveAutoLink as i}from"@theme/resolveAutoLink";import{resolvePrefix as a}from"@theme/resolvePrefix";const o=(n,r=``)=>e(n)?i(a(r,n)):`children`in n?{...n,children:n.children.map(e=>o(e,a(r,n.prefix)))}:{...n,link:t(n.link)?i(a(r,n.link)).link:n.link},s=()=>{let{themeLocale:e}=n();return r(()=>(e.value.navbar||[]).map(e=>o(e)))};export{s as useNavbarConfig};
|
|
2
|
+
//# sourceMappingURL=useNavbarConfig.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useNavbarConfig.js","names":[],"sources":["../../../src/client/composables/useNavbarConfig.ts"],"sourcesContent":["import { resolveAutoLink } from '@theme/resolveAutoLink'\nimport { resolvePrefix } from '@theme/resolvePrefix'\nimport { useData } from '@theme/useData'\nimport { isLinkRelative } from '@vuepress/helper/client'\nimport type { ComputedRef } from 'vue'\nimport { computed } from 'vue'\nimport { isString } from 'vuepress/shared'\nimport type {\n NavbarGroupOptions,\n NavbarLinkOptions,\n} from '../../shared/navbar.js'\nimport type { NavbarItem } from '../typings.js'\n\nconst resolveNavbarItem = (\n item: NavbarGroupOptions | NavbarLinkOptions,\n prefix = '',\n): NavbarItem => {\n if (isString(item)) return resolveAutoLink(resolvePrefix(prefix, item))\n\n if ('children' in item) {\n return {\n ...item,\n children: item.children.map((child) =>\n resolveNavbarItem(child, resolvePrefix(prefix, item.prefix)),\n ),\n }\n }\n\n return {\n ...item,\n link: isLinkRelative(item.link)\n ? resolveAutoLink(resolvePrefix(prefix, item.link)).link\n : item.link,\n }\n}\n\nexport const useNavbarConfig = (): ComputedRef<NavbarItem[]> => {\n const { themeLocale } = useData()\n\n return computed(() =>\n (themeLocale.value.navbar || []).map((item) => resolveNavbarItem(item)),\n )\n}\n"],"mappings":"0RAaA,MAAM,GACJ,EACA,EAAS,KAEL,EAAS,EAAK,CAAS,EAAgB,EAAc,EAAQ,EAAK,CAAC,CAEnE,aAAc,EACT,CACL,GAAG,EACH,SAAU,EAAK,SAAS,IAAK,GAC3B,EAAkB,EAAO,EAAc,EAAQ,EAAK,OAAO,CAAC,CAC7D,CACF,CAGI,CACL,GAAG,EACH,KAAM,EAAe,EAAK,KAAK,CAC3B,EAAgB,EAAc,EAAQ,EAAK,KAAK,CAAC,CAAC,KAClD,EAAK,KACV,CAGU,MAAmD,CAC9D,GAAM,CAAE,eAAgB,GAAS,CAEjC,OAAO,OACJ,EAAY,MAAM,QAAU,EAAE,EAAE,IAAK,GAAS,EAAkB,EAAK,CAAC,CACxE"}
|
|
@@ -1,6 +1,13 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
1
|
+
import { t as NavbarItem } from "../../typings-jKn48KwS.js";
|
|
2
|
+
import { ComputedRef } from "vue";
|
|
3
|
+
|
|
4
|
+
//#region src/client/composables/useNavbarRepo.d.ts
|
|
3
5
|
/**
|
|
4
|
-
*
|
|
6
|
+
* Repository link in navbar
|
|
7
|
+
*
|
|
8
|
+
* @returns Navbar config of repository link / 仓库链接的导航栏配置
|
|
5
9
|
*/
|
|
6
|
-
|
|
10
|
+
declare const useNavbarRepo: () => ComputedRef<NavbarItem[]>;
|
|
11
|
+
//#endregion
|
|
12
|
+
export { useNavbarRepo };
|
|
13
|
+
//# sourceMappingURL=useNavbarRepo.d.ts.map
|
|
@@ -1,38 +1,2 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
import { computed } from 'vue';
|
|
4
|
-
import { isLinkHttp } from 'vuepress/shared';
|
|
5
|
-
/**
|
|
6
|
-
* Get navbar config of repository link
|
|
7
|
-
*/
|
|
8
|
-
export const useNavbarRepo = () => {
|
|
9
|
-
const { themeLocale } = useData();
|
|
10
|
-
const repo = computed(() => themeLocale.value.repo);
|
|
11
|
-
const repoType = computed(() => repo.value ? resolveRepoType(repo.value) : null);
|
|
12
|
-
const repoLink = computed(() => {
|
|
13
|
-
if (repo.value && !isLinkHttp(repo.value)) {
|
|
14
|
-
return `https://github.com/${repo.value}`;
|
|
15
|
-
}
|
|
16
|
-
return repo.value;
|
|
17
|
-
});
|
|
18
|
-
const repoLabel = computed(() => {
|
|
19
|
-
if (!repoLink.value)
|
|
20
|
-
return null;
|
|
21
|
-
if (themeLocale.value.repoLabel)
|
|
22
|
-
return themeLocale.value.repoLabel;
|
|
23
|
-
if (repoType.value === null)
|
|
24
|
-
return 'Source';
|
|
25
|
-
return repoType.value;
|
|
26
|
-
});
|
|
27
|
-
return computed(() => {
|
|
28
|
-
if (!repoLink.value || !repoLabel.value) {
|
|
29
|
-
return [];
|
|
30
|
-
}
|
|
31
|
-
return [
|
|
32
|
-
{
|
|
33
|
-
text: repoLabel.value,
|
|
34
|
-
link: repoLink.value,
|
|
35
|
-
},
|
|
36
|
-
];
|
|
37
|
-
});
|
|
38
|
-
};
|
|
1
|
+
import{isLinkHttp as e}from"vuepress/shared";import{useData as t}from"@theme/useData";import{computed as n}from"vue";import{resolveRepoType as r}from"@theme/resolveRepoType";const i=()=>{let{themeLocale:i}=t(),a=n(()=>i.value.repo),o=n(()=>a.value?r(a.value):null),s=n(()=>a.value&&!e(a.value)?`https://github.com/${a.value}`:a.value),c=n(()=>s.value?i.value.repoLabel?i.value.repoLabel:o.value==null?`Source`:o.value:null);return n(()=>!s.value||!c.value?[]:[{text:c.value,link:s.value}])};export{i as useNavbarRepo};
|
|
2
|
+
//# sourceMappingURL=useNavbarRepo.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useNavbarRepo.js","names":[],"sources":["../../../src/client/composables/useNavbarRepo.ts"],"sourcesContent":["import { resolveRepoType } from '@theme/resolveRepoType'\nimport { useData } from '@theme/useData'\nimport type { ComputedRef } from 'vue'\nimport { computed } from 'vue'\nimport { isLinkHttp } from 'vuepress/shared'\nimport type { NavbarItem } from '../typings.js'\n\n/**\n * Repository link in navbar\n *\n * @returns Navbar config of repository link / 仓库链接的导航栏配置\n */\nexport const useNavbarRepo = (): ComputedRef<NavbarItem[]> => {\n const { themeLocale } = useData()\n\n const repo = computed(() => themeLocale.value.repo)\n const repoType = computed(() =>\n repo.value ? resolveRepoType(repo.value) : null,\n )\n\n const repoLink = computed(() => {\n if (repo.value && !isLinkHttp(repo.value))\n return `https://github.com/${repo.value}`\n\n return repo.value\n })\n\n const repoLabel = computed(() => {\n if (!repoLink.value) return null\n if (themeLocale.value.repoLabel) return themeLocale.value.repoLabel\n if (repoType.value == null) return 'Source'\n return repoType.value\n })\n\n return computed(() => {\n if (!repoLink.value || !repoLabel.value) return []\n\n return [\n {\n text: repoLabel.value,\n link: repoLink.value,\n },\n ]\n })\n}\n"],"mappings":"8KAYA,MAAa,MAAiD,CAC5D,GAAM,CAAE,eAAgB,GAAS,CAE3B,EAAO,MAAe,EAAY,MAAM,KAAK,CAC7C,EAAW,MACf,EAAK,MAAQ,EAAgB,EAAK,MAAM,CAAG,KAC5C,CAEK,EAAW,MACX,EAAK,OAAS,CAAC,EAAW,EAAK,MAAM,CAChC,sBAAsB,EAAK,QAE7B,EAAK,MACZ,CAEI,EAAY,MACX,EAAS,MACV,EAAY,MAAM,UAAkB,EAAY,MAAM,UACtD,EAAS,OAAS,KAAa,SAC5B,EAAS,MAHY,KAI5B,CAEF,OAAO,MACD,CAAC,EAAS,OAAS,CAAC,EAAU,MAAc,EAAE,CAE3C,CACL,CACE,KAAM,EAAU,MAChB,KAAM,EAAS,MAChB,CACF,CACD"}
|
|
@@ -1,6 +1,13 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
1
|
+
import { t as NavbarItem } from "../../typings-jKn48KwS.js";
|
|
2
|
+
import { ComputedRef } from "vue";
|
|
3
|
+
|
|
4
|
+
//#region src/client/composables/useNavbarSelectLanguage.d.ts
|
|
3
5
|
/**
|
|
4
6
|
* Get navbar config of select language dropdown
|
|
7
|
+
*
|
|
8
|
+
* @returns Navbar config of select language dropdown
|
|
5
9
|
*/
|
|
6
|
-
|
|
10
|
+
declare const useNavbarSelectLanguage: () => ComputedRef<NavbarItem[]>;
|
|
11
|
+
//#endregion
|
|
12
|
+
export { useNavbarSelectLanguage };
|
|
13
|
+
//# sourceMappingURL=useNavbarSelectLanguage.d.ts.map
|