@vuepress/theme-default 2.0.0-rc.123 → 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.
Files changed (101) hide show
  1. package/lib/client/components/VPHomeHero.vue +7 -14
  2. package/lib/client/components/VPNavbar.vue +8 -11
  3. package/lib/client/components/VPNavbarBrand.vue +4 -5
  4. package/lib/client/composables/index.d.ts +12 -11
  5. package/lib/client/composables/index.js +1 -11
  6. package/lib/client/composables/useDarkMode.d.ts +9 -4
  7. package/lib/client/composables/useDarkMode.js +2 -64
  8. package/lib/client/composables/useDarkMode.js.map +1 -0
  9. package/lib/client/composables/useData.d.ts +12 -7
  10. package/lib/client/composables/useData.js +2 -7
  11. package/lib/client/composables/useData.js.map +1 -0
  12. package/lib/client/composables/useEditLink.d.ts +8 -3
  13. package/lib/client/composables/useEditLink.js +2 -28
  14. package/lib/client/composables/useEditLink.js.map +1 -0
  15. package/lib/client/composables/useHeaders.d.ts +11 -6
  16. package/lib/client/composables/useHeaders.js +2 -42
  17. package/lib/client/composables/useHeaders.js.map +1 -0
  18. package/lib/client/composables/useNavbarConfig.d.ts +8 -3
  19. package/lib/client/composables/useNavbarConfig.js +2 -27
  20. package/lib/client/composables/useNavbarConfig.js.map +1 -0
  21. package/lib/client/composables/useNavbarRepo.d.ts +8 -3
  22. package/lib/client/composables/useNavbarRepo.js +2 -40
  23. package/lib/client/composables/useNavbarRepo.js.map +1 -0
  24. package/lib/client/composables/useNavbarSelectLanguage.d.ts +8 -3
  25. package/lib/client/composables/useNavbarSelectLanguage.js +2 -60
  26. package/lib/client/composables/useNavbarSelectLanguage.js.map +1 -0
  27. package/lib/client/composables/useNavigate.d.ts +5 -1
  28. package/lib/client/composables/useNavigate.js +2 -22
  29. package/lib/client/composables/useNavigate.js.map +1 -0
  30. package/lib/client/composables/useRelatedLinks.d.ts +10 -6
  31. package/lib/client/composables/useRelatedLinks.js +2 -95
  32. package/lib/client/composables/useRelatedLinks.js.map +1 -0
  33. package/lib/client/composables/useScrollPromise.d.ts +9 -5
  34. package/lib/client/composables/useScrollPromise.js +2 -16
  35. package/lib/client/composables/useScrollPromise.js.map +1 -0
  36. package/lib/client/composables/useSidebarItems.d.ts +19 -14
  37. package/lib/client/composables/useSidebarItems.js +2 -164
  38. package/lib/client/composables/useSidebarItems.js.map +1 -0
  39. package/lib/client/composables/useUpdateDeviceStatus.d.ts +7 -3
  40. package/lib/client/composables/useUpdateDeviceStatus.js +2 -34
  41. package/lib/client/composables/useUpdateDeviceStatus.js.map +1 -0
  42. package/lib/client/config.d.ts +10 -5
  43. package/lib/client/config.js +2 -35
  44. package/lib/client/config.js.map +1 -0
  45. package/lib/client/index.d.ts +21 -4
  46. package/lib/client/index.js +1 -2
  47. package/lib/client/layouts/Layout.vue +2 -5
  48. package/lib/client/layouts/NotFound.vue +1 -2
  49. package/lib/client/styles/arrow.scss +1 -2
  50. package/lib/client/styles/vars.scss +1 -2
  51. package/lib/client/utils/index.d.ts +6 -5
  52. package/lib/client/utils/index.js +1 -5
  53. package/lib/client/utils/isActiveSidebarItem.d.ts +8 -3
  54. package/lib/client/utils/isActiveSidebarItem.js +2 -20
  55. package/lib/client/utils/isActiveSidebarItem.js.map +1 -0
  56. package/lib/client/utils/resolveAutoLink.d.ts +7 -2
  57. package/lib/client/utils/resolveAutoLink.js +2 -23
  58. package/lib/client/utils/resolveAutoLink.js.map +1 -0
  59. package/lib/client/utils/resolveEditLink.d.ts +19 -8
  60. package/lib/client/utils/resolveEditLink.js +2 -29
  61. package/lib/client/utils/resolveEditLink.js.map +1 -0
  62. package/lib/client/utils/resolvePrefix.d.ts +5 -1
  63. package/lib/client/utils/resolvePrefix.js +2 -4
  64. package/lib/client/utils/resolvePrefix.js.map +1 -0
  65. package/lib/client/utils/resolveRepoType.d.ts +6 -2
  66. package/lib/client/utils/resolveRepoType.js +2 -12
  67. package/lib/client/utils/resolveRepoType.js.map +1 -0
  68. package/lib/nav-DikslSJ_.d.ts +36 -0
  69. package/lib/node/index.d.ts +106 -4
  70. package/lib/node/index.js +2 -2
  71. package/lib/node/index.js.map +1 -0
  72. package/lib/page-F2gyvsdE.d.ts +292 -0
  73. package/lib/sidebar-FqrQ3PGy.d.ts +53 -0
  74. package/lib/typings-jKn48KwS.d.ts +19 -0
  75. package/package.json +30 -21
  76. package/lib/client/components/global/index.d.ts +0 -2
  77. package/lib/client/components/global/index.js +0 -2
  78. package/lib/client/typings.d.ts +0 -13
  79. package/lib/client/typings.js +0 -1
  80. package/lib/node/defaultTheme.d.ts +0 -15
  81. package/lib/node/defaultTheme.js +0 -140
  82. package/lib/node/typings.d.ts +0 -59
  83. package/lib/node/typings.js +0 -1
  84. package/lib/node/utils/assignDefaultLocaleOptions.d.ts +0 -7
  85. package/lib/node/utils/assignDefaultLocaleOptions.js +0 -51
  86. package/lib/node/utils/index.d.ts +0 -2
  87. package/lib/node/utils/index.js +0 -2
  88. package/lib/node/utils/resolveMarkdownHintLocales.d.ts +0 -12
  89. package/lib/node/utils/resolveMarkdownHintLocales.js +0 -22
  90. package/lib/shared/index.d.ts +0 -5
  91. package/lib/shared/index.js +0 -1
  92. package/lib/shared/nav.d.ts +0 -32
  93. package/lib/shared/nav.js +0 -1
  94. package/lib/shared/navbar.d.ts +0 -21
  95. package/lib/shared/navbar.js +0 -1
  96. package/lib/shared/options.d.ts +0 -244
  97. package/lib/shared/options.js +0 -1
  98. package/lib/shared/page.d.ts +0 -44
  99. package/lib/shared/page.js +0 -1
  100. package/lib/shared/sidebar.d.ts +0 -26
  101. package/lib/shared/sidebar.js +0 -1
@@ -12,16 +12,13 @@ const isDarkMode = useDarkMode()
12
12
 
13
13
  const heroText = computed(() => {
14
14
  // oxlint-disable-next-line eqeqeq
15
- if (frontmatter.value.heroText === null) {
16
- return null
17
- }
15
+ if (frontmatter.value.heroText === null) return null
16
+
18
17
  return frontmatter.value.heroText || siteLocale.value.title || 'Hello'
19
18
  })
20
19
  const tagline = computed(() => {
21
20
  // oxlint-disable-next-line eqeqeq
22
- if (frontmatter.value.tagline === null) {
23
- return null
24
- }
21
+ if (frontmatter.value.tagline === null) return null
25
22
 
26
23
  return (
27
24
  frontmatter.value.tagline ||
@@ -30,9 +27,9 @@ const tagline = computed(() => {
30
27
  )
31
28
  })
32
29
  const heroImage = computed(() => {
33
- if (isDarkMode.value && frontmatter.value.heroImageDark !== undefined) {
30
+ if (isDarkMode.value && frontmatter.value.heroImageDark !== undefined)
34
31
  return frontmatter.value.heroImageDark
35
- }
32
+
36
33
  return frontmatter.value.heroImage
37
34
  })
38
35
  const heroAlt = computed(
@@ -41,9 +38,7 @@ const heroAlt = computed(
41
38
  const heroHeight = computed(() => frontmatter.value.heroHeight ?? 280)
42
39
 
43
40
  const actions = computed(() => {
44
- if (!Array.isArray(frontmatter.value.actions)) {
45
- return []
46
- }
41
+ if (!Array.isArray(frontmatter.value.actions)) return []
47
42
 
48
43
  return frontmatter.value.actions.map(({ type = 'primary', ...rest }) => ({
49
44
  type,
@@ -61,9 +56,7 @@ const HomeHeroImage: FunctionalComponent = () => {
61
56
  height: heroHeight.value,
62
57
  })
63
58
 
64
- if (frontmatter.value.heroImageDark === undefined) {
65
- return img
66
- }
59
+ if (frontmatter.value.heroImageDark === undefined) return img
67
60
 
68
61
  // wrap hero image with <ClientOnly> to avoid ssr-mismatch
69
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
- return {}
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
- if (window.innerWidth < mobileDesktopBreakpoint) {
59
- linksWrapperMaxWidth.value = 0
60
- } else {
61
- linksWrapperMaxWidth.value =
62
- navbar.value!.offsetWidth -
63
- navbarHorizontalPadding -
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
- return img
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)
@@ -1,11 +1,12 @@
1
- export * from './useDarkMode.js';
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 { 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
- export * from './useDarkMode.js';
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,5 +1,7 @@
1
- import type { WritableComputedRef } from 'vue';
2
- export type DarkModeRef = WritableComputedRef<boolean>;
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
5
7
  *
@@ -7,8 +9,11 @@ export type DarkModeRef = WritableComputedRef<boolean>;
7
9
  *
8
10
  * @returns Dark mode ref / 暗色模式引用
9
11
  */
10
- export declare const useDarkMode: () => DarkModeRef;
12
+ declare const useDarkMode: () => DarkModeRef;
11
13
  /**
12
14
  * Create dark mode ref and provide as global computed in setup
13
15
  */
14
- export declare const setupDarkMode: () => void;
16
+ declare const setupDarkMode: () => void;
17
+ //#endregion
18
+ export { DarkModeRef, setupDarkMode, useDarkMode };
19
+ //# sourceMappingURL=useDarkMode.d.ts.map
@@ -1,64 +1,2 @@
1
- import { useData } from '@theme/useData';
2
- import { darkModeSymbol } from '@vuepress/helper/client';
3
- import { usePreferredDark, useStorage, watchImmediate } from '@vueuse/core';
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
- };
11
- const applyDarkModeToHTML = (isDarkMode) => {
12
- onMounted(() => {
13
- watchImmediate(isDarkMode, update);
14
- });
15
- onUnmounted(() => {
16
- update(isDarkMode.value);
17
- });
18
- };
19
- /**
20
- * Inject dark mode global computed
21
- *
22
- * 注入暗色模式全局计算属性
23
- *
24
- * @returns Dark mode ref / 暗色模式引用
25
- */
26
- export const useDarkMode = () => {
27
- const isDarkMode = inject(darkModeSymbol);
28
- if (!isDarkMode) {
29
- throw new Error('useDarkMode() is called without provider.');
30
- }
31
- return isDarkMode;
32
- };
33
- /**
34
- * Create dark mode ref and provide as global computed in setup
35
- */
36
- export const setupDarkMode = () => {
37
- const { themeLocale } = useData();
38
- const isDarkPreferred = usePreferredDark();
39
- const darkStorage = useStorage('vuepress-color-scheme', themeLocale.value.colorMode);
40
- const isDarkMode = computed({
41
- get() {
42
- // disable color mode switching
43
- if (!themeLocale.value.colorModeSwitch) {
44
- return themeLocale.value.colorMode === 'dark';
45
- }
46
- // auto detected from prefers-color-scheme
47
- if (darkStorage.value === 'auto') {
48
- return isDarkPreferred.value;
49
- }
50
- // storage value
51
- return darkStorage.value === 'dark';
52
- },
53
- set(val) {
54
- if (val === isDarkPreferred.value) {
55
- darkStorage.value = 'auto';
56
- }
57
- else {
58
- darkStorage.value = val ? 'dark' : 'light';
59
- }
60
- },
61
- });
62
- provide(darkModeSymbol, isDarkMode);
63
- applyDarkModeToHTML(isDarkMode);
64
- };
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 type { ThemeDataRef, ThemeLocaleDataRef } from '@vuepress/plugin-theme-data/client';
2
- import type { ClientData } from 'vuepress/client';
3
- import type { DefaultThemeData, DefaultThemeNormalPageFrontmatter, DefaultThemePageData } from '../../shared/index.js';
4
- export 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'> {
5
- theme: ThemeDataRef<DefaultThemeData>;
6
- themeLocale: ThemeLocaleDataRef<DefaultThemeData>;
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
- export declare const useData: <PageFrontmatter extends Record<string, unknown> = DefaultThemeNormalPageFrontmatter, PageData extends Record<string, unknown> = DefaultThemePageData>() => Data<PageFrontmatter, PageData>;
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 { useThemeData, useThemeLocaleData, } from '@vuepress/plugin-theme-data/client';
2
- import { useData as _useData } from 'vuepress/client';
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 type { ComputedRef } from 'vue';
2
- import type { AutoLinkConfig } from 'vuepress/client';
3
- export declare const useEditLink: () => ComputedRef<AutoLinkConfig | null>;
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 } from '@theme/resolveEditLink';
2
- import { useData } from '@theme/useData';
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,7 +1,9 @@
1
- import type { HeaderItem } from '@vuepress/helper/client';
2
- import type { InjectionKey, Ref } from 'vue';
3
- export type HeadersRef = Ref<HeaderItem[]>;
4
- export declare const headersSymbol: InjectionKey<HeadersRef>;
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
7
9
  *
@@ -9,5 +11,8 @@ export declare const headersSymbol: InjectionKey<HeadersRef>;
9
11
  *
10
12
  * @returns Headers ref / 标题引用
11
13
  */
12
- export declare const useHeaders: () => HeadersRef;
13
- export declare const setupHeaders: () => void;
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,42 +1,2 @@
1
- import { useData } from '@theme/useData';
2
- import { getHeaders } from '@vuepress/helper/client';
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
- * 注入标题
11
- *
12
- * @returns Headers ref / 标题引用
13
- */
14
- export const useHeaders = () => {
15
- const headers = injectLocal(headersSymbol);
16
- if (!headers) {
17
- throw new Error('useHeaders() is called without provider.');
18
- }
19
- return headers;
20
- };
21
- export const setupHeaders = () => {
22
- const { frontmatter, themeLocale } = useData();
23
- const headersRef = ref([]);
24
- const levels = computed(() => frontmatter.value.sidebarDepth ?? themeLocale.value.sidebarDepth ?? 2);
25
- const updateHeaders = () => {
26
- if (levels.value <= 0) {
27
- headersRef.value = [];
28
- return;
29
- }
30
- headersRef.value = getHeaders({
31
- levels: [2, levels.value + 1],
32
- ignore: ['.vp-badge'],
33
- });
34
- };
35
- provideLocal(headersSymbol, headersRef);
36
- onContentUpdated((reason) => {
37
- if (reason === 'beforeUnmount')
38
- headersRef.value = [];
39
- else
40
- updateHeaders();
41
- });
42
- };
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 type { ComputedRef } from 'vue';
2
- import type { NavbarItem } from '../typings.js';
3
- export declare const useNavbarConfig: () => ComputedRef<NavbarItem[]>;
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,27 +1,2 @@
1
- import { resolveAutoLink } from '@theme/resolveAutoLink';
2
- import { resolvePrefix } from '@theme/resolvePrefix';
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(() => (themeLocale.value.navbar || []).map((item) => resolveNavbarItem(item)));
27
- };
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,8 +1,13 @@
1
- import type { ComputedRef } from 'vue';
2
- import type { NavbarItem } from '../typings.js';
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
5
7
  *
6
8
  * @returns Navbar config of repository link / 仓库链接的导航栏配置
7
9
  */
8
- export declare const useNavbarRepo: () => ComputedRef<NavbarItem[]>;
10
+ declare const useNavbarRepo: () => ComputedRef<NavbarItem[]>;
11
+ //#endregion
12
+ export { useNavbarRepo };
13
+ //# sourceMappingURL=useNavbarRepo.d.ts.map
@@ -1,40 +1,2 @@
1
- import { resolveRepoType } from '@theme/resolveRepoType';
2
- import { useData } from '@theme/useData';
3
- import { computed } from 'vue';
4
- import { isLinkHttp } from 'vuepress/shared';
5
- /**
6
- * Repository link in navbar
7
- *
8
- * @returns Navbar config of repository link / 仓库链接的导航栏配置
9
- */
10
- export const useNavbarRepo = () => {
11
- const { themeLocale } = useData();
12
- const repo = computed(() => themeLocale.value.repo);
13
- const repoType = computed(() => repo.value ? resolveRepoType(repo.value) : null);
14
- const repoLink = computed(() => {
15
- if (repo.value && !isLinkHttp(repo.value)) {
16
- return `https://github.com/${repo.value}`;
17
- }
18
- return repo.value;
19
- });
20
- const repoLabel = computed(() => {
21
- if (!repoLink.value)
22
- return null;
23
- if (themeLocale.value.repoLabel)
24
- return themeLocale.value.repoLabel;
25
- if (repoType.value == null)
26
- return 'Source';
27
- return repoType.value;
28
- });
29
- return computed(() => {
30
- if (!repoLink.value || !repoLabel.value) {
31
- return [];
32
- }
33
- return [
34
- {
35
- text: repoLabel.value,
36
- link: repoLink.value,
37
- },
38
- ];
39
- });
40
- };
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,8 +1,13 @@
1
- import type { ComputedRef } from 'vue';
2
- import type { NavbarItem } from '../typings.js';
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
5
7
  *
6
8
  * @returns Navbar config of select language dropdown
7
9
  */
8
- export declare const useNavbarSelectLanguage: () => ComputedRef<NavbarItem[]>;
10
+ declare const useNavbarSelectLanguage: () => ComputedRef<NavbarItem[]>;
11
+ //#endregion
12
+ export { useNavbarSelectLanguage };
13
+ //# sourceMappingURL=useNavbarSelectLanguage.d.ts.map
@@ -1,60 +1,2 @@
1
- import { useData } from '@theme/useData';
2
- import { useRoutePaths } from '@vuepress/helper/client';
3
- import { useMounted } from '@vueuse/core';
4
- import { computed } from 'vue';
5
- import { useRoute } from 'vuepress/client';
6
- /**
7
- * Get navbar config of select language dropdown
8
- *
9
- * @returns Navbar config of select language dropdown
10
- */
11
- export const useNavbarSelectLanguage = () => {
12
- const route = useRoute();
13
- const routePaths = useRoutePaths();
14
- const { routeLocale, site, siteLocale, theme, themeLocale } = useData();
15
- const isMounted = useMounted();
16
- return computed(() => {
17
- const localePaths = Object.keys(site.value.locales);
18
- // do not display language selection dropdown if there is only one language
19
- if (localePaths.length < 2) {
20
- return [];
21
- }
22
- const currentPath = route.path;
23
- const currentFullPath = route.fullPath;
24
- const languageDropdown = {
25
- text: `${themeLocale.value.selectLanguageText}`,
26
- ariaLabel: `${themeLocale.value.selectLanguageAriaLabel ??
27
- themeLocale.value.selectLanguageText}`,
28
- children: localePaths.map((targetLocalePath) => {
29
- // target locale config of this language link
30
- const targetSiteLocale = site.value.locales?.[targetLocalePath] ?? {};
31
- const targetThemeLocale = theme.value.locales?.[targetLocalePath] ?? {};
32
- const targetLang = `${targetSiteLocale.lang}`;
33
- const text = targetThemeLocale.selectLanguageName ?? targetLang;
34
- // if the target language is current language
35
- // stay at current link
36
- if (targetLang === siteLocale.value.lang) {
37
- return {
38
- text,
39
- activeMatch: '.',
40
- link: isMounted.value ? currentFullPath : currentPath,
41
- };
42
- }
43
- // if the target language is not current language
44
- // try to link to the corresponding page of current page
45
- // or fallback to homepage
46
- const targetLocalePage = currentPath.replace(routeLocale.value, targetLocalePath);
47
- return {
48
- text,
49
- // try to keep current hash and params across languages
50
- link: routePaths.value.some((item) => item === targetLocalePage)
51
- ? isMounted.value
52
- ? currentFullPath.replace(currentPath, targetLocalePage)
53
- : targetLocalePage
54
- : (targetThemeLocale.home ?? targetLocalePath),
55
- };
56
- }),
57
- };
58
- return [languageDropdown];
59
- });
60
- };
1
+ import{useRoutePaths as e}from"@vuepress/helper/client";import{useRoute as t}from"vuepress/client";import{useData as n}from"@theme/useData";import{useMounted as r}from"@vueuse/core";import{computed as i}from"vue";const a=()=>{let a=t(),o=e(),{routeLocale:s,site:c,siteLocale:l,theme:u,themeLocale:d}=n(),f=r();return i(()=>{let e=Object.keys(c.value.locales);if(e.length<2)return[];let t=a.path,n=a.fullPath;return[{text:`${d.value.selectLanguageText}`,ariaLabel:`${d.value.selectLanguageAriaLabel??d.value.selectLanguageText}`,children:e.map(e=>{let r=c.value.locales?.[e]??{},i=u.value.locales?.[e]??{},a=`${r.lang}`,d=i.selectLanguageName??a;if(a===l.value.lang)return{text:d,activeMatch:`.`,link:f.value?n:t};let p=t.replace(s.value,e);return{text:d,link:o.value.some(e=>e===p)?f.value?n.replace(t,p):p:i.home??e}})}]})};export{a as useNavbarSelectLanguage};
2
+ //# sourceMappingURL=useNavbarSelectLanguage.js.map