@vuepress/theme-default 2.0.0-rc.4 → 2.0.0-rc.40

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (127) hide show
  1. package/lib/client/components/VPDarkIcon.vue +8 -0
  2. package/lib/client/components/{DropdownTransition.vue → VPDropdownTransition.vue} +10 -1
  3. package/lib/client/components/VPEditIcon.vue +12 -0
  4. package/lib/client/components/VPHome.vue +38 -0
  5. package/lib/client/components/VPHomeFeatures.vue +68 -0
  6. package/lib/client/components/{HomeFooter.vue → VPHomeFooter.vue} +16 -2
  7. package/lib/client/components/{HomeHero.vue → VPHomeHero.vue} +108 -7
  8. package/lib/client/components/VPLightIcon.vue +28 -0
  9. package/lib/client/components/VPNavbar.vue +125 -0
  10. package/lib/client/components/{NavbarBrand.vue → VPNavbarBrand.vue} +39 -6
  11. package/lib/client/components/VPNavbarDropdown.vue +320 -0
  12. package/lib/client/components/VPNavbarItems.vue +110 -0
  13. package/lib/client/components/VPPage.vue +69 -0
  14. package/lib/client/components/VPPageMeta.vue +132 -0
  15. package/lib/client/components/VPPageNav.vue +118 -0
  16. package/lib/client/components/VPSidebar.vue +112 -0
  17. package/lib/client/components/VPSidebarItem.vue +167 -0
  18. package/lib/client/components/{SidebarItems.vue → VPSidebarItems.vue} +31 -7
  19. package/lib/client/components/VPToggleColorModeButton.vue +54 -0
  20. package/lib/client/components/VPToggleSidebarButton.vue +92 -0
  21. package/lib/client/components/global/Badge.vue +60 -18
  22. package/lib/client/components/global/CodeGroup.d.ts +1 -0
  23. package/lib/client/components/global/CodeGroup.js +4 -3
  24. package/lib/client/components/global/CodeGroupItem.vue +5 -16
  25. package/lib/client/composables/index.d.ts +8 -0
  26. package/lib/client/composables/index.js +8 -0
  27. package/lib/client/composables/useContributors.d.ts +3 -0
  28. package/lib/client/composables/useContributors.js +14 -0
  29. package/lib/client/composables/useDarkMode.d.ts +0 -1
  30. package/lib/client/composables/useDarkMode.js +14 -13
  31. package/lib/client/composables/useEditLink.d.ts +3 -0
  32. package/lib/client/composables/useEditLink.js +31 -0
  33. package/lib/client/composables/useLastUpdated.d.ts +2 -0
  34. package/lib/client/composables/useLastUpdated.js +17 -0
  35. package/lib/client/composables/useNavbarConfig.d.ts +3 -0
  36. package/lib/client/composables/useNavbarConfig.js +25 -0
  37. package/lib/client/composables/useNavbarRepo.d.ts +6 -0
  38. package/lib/client/composables/useNavbarRepo.js +38 -0
  39. package/lib/client/composables/useNavbarSelectLanguage.d.ts +6 -0
  40. package/lib/client/composables/useNavbarSelectLanguage.js +58 -0
  41. package/lib/client/composables/useNavigate.d.ts +1 -0
  42. package/lib/client/composables/useNavigate.js +22 -0
  43. package/lib/client/composables/useRelatedLinks.d.ts +8 -0
  44. package/lib/client/composables/useRelatedLinks.js +91 -0
  45. package/lib/client/composables/useSidebarItems.d.ts +17 -12
  46. package/lib/client/composables/useSidebarItems.js +87 -52
  47. package/lib/client/composables/useUpdateDeviceStatus.js +5 -4
  48. package/lib/client/config.d.ts +2 -2
  49. package/lib/client/config.js +12 -13
  50. package/lib/client/index.d.ts +2 -1
  51. package/lib/client/index.js +1 -1
  52. package/lib/client/layouts/Layout.vue +121 -20
  53. package/lib/client/layouts/NotFound.vue +18 -4
  54. package/lib/client/shim.d.ts +3 -3
  55. package/lib/client/styles/_mixins.scss +4 -4
  56. package/lib/client/styles/_variables.module.scss +1 -1
  57. package/lib/client/styles/_variables.scss +1 -0
  58. package/lib/client/styles/arrow.scss +18 -24
  59. package/lib/client/styles/code-group.scss +32 -29
  60. package/lib/client/styles/content/code.scss +23 -0
  61. package/lib/client/styles/{custom-container.scss → content/custom-container.scss} +13 -13
  62. package/lib/client/styles/content/index.scss +4 -0
  63. package/lib/client/styles/content/normalize.scss +39 -0
  64. package/lib/client/styles/{toc.scss → content/toc.scss} +1 -1
  65. package/lib/client/styles/external-link-icon.scss +37 -0
  66. package/lib/client/styles/index.scss +3 -13
  67. package/lib/client/styles/layout.scss +3 -199
  68. package/lib/client/styles/normalize.scss +20 -148
  69. package/lib/client/styles/plugins.scss +20 -0
  70. package/lib/client/styles/vars-dark.scss +17 -12
  71. package/lib/client/styles/vars.scss +71 -33
  72. package/lib/client/typings.d.ts +13 -0
  73. package/lib/client/typings.js +1 -0
  74. package/lib/client/utils/getAutoLink.d.ts +9 -0
  75. package/lib/client/utils/getAutoLink.js +17 -0
  76. package/lib/client/utils/index.d.ts +3 -2
  77. package/lib/client/utils/index.js +3 -2
  78. package/lib/client/utils/isActiveSidebarItem.d.ts +3 -3
  79. package/lib/client/utils/isActiveSidebarItem.js +3 -3
  80. package/lib/client/utils/isLinkInternal.d.ts +1 -0
  81. package/lib/client/utils/isLinkInternal.js +2 -0
  82. package/lib/client/utils/resolveEditLink.d.ts +1 -1
  83. package/lib/client/utils/resolvePrefix.d.ts +1 -0
  84. package/lib/client/utils/resolvePrefix.js +4 -0
  85. package/lib/node/defaultTheme.js +83 -24
  86. package/lib/node/index.d.ts +2 -1
  87. package/lib/node/index.js +1 -1
  88. package/lib/node/utils/assignDefaultLocaleOptions.js +1 -1
  89. package/lib/node/utils/resolveContainerPluginOptions.d.ts +3 -3
  90. package/lib/node/utils/resolveContainerPluginOptions.js +2 -2
  91. package/lib/shared/index.d.ts +2 -0
  92. package/lib/shared/index.js +2 -0
  93. package/lib/shared/nav.d.ts +19 -30
  94. package/lib/shared/navbar.d.ts +21 -0
  95. package/lib/shared/navbar.js +1 -0
  96. package/lib/shared/options.d.ts +31 -8
  97. package/lib/shared/page.d.ts +6 -4
  98. package/lib/shared/sidebar.d.ts +26 -0
  99. package/lib/shared/sidebar.js +1 -0
  100. package/package.json +22 -26
  101. package/templates/build.html +19 -10
  102. package/lib/client/components/AutoLink.vue +0 -113
  103. package/lib/client/components/Home.vue +0 -15
  104. package/lib/client/components/HomeContent.vue +0 -5
  105. package/lib/client/components/HomeFeatures.vue +0 -22
  106. package/lib/client/components/Navbar.vue +0 -79
  107. package/lib/client/components/NavbarDropdown.vue +0 -126
  108. package/lib/client/components/NavbarItems.vue +0 -199
  109. package/lib/client/components/Page.vue +0 -31
  110. package/lib/client/components/PageMeta.vue +0 -124
  111. package/lib/client/components/PageNav.vue +0 -122
  112. package/lib/client/components/Sidebar.vue +0 -18
  113. package/lib/client/components/SidebarItem.vue +0 -87
  114. package/lib/client/components/ToggleColorModeButton.vue +0 -57
  115. package/lib/client/components/ToggleSidebarButton.vue +0 -24
  116. package/lib/client/styles/badge.scss +0 -36
  117. package/lib/client/styles/code.scss +0 -263
  118. package/lib/client/styles/home.scss +0 -168
  119. package/lib/client/styles/navbar-dropdown.scss +0 -183
  120. package/lib/client/styles/navbar.scss +0 -197
  121. package/lib/client/styles/page.scss +0 -87
  122. package/lib/client/styles/sidebar.scss +0 -134
  123. package/lib/client/styles/transitions.scss +0 -22
  124. package/lib/client/utils/getNavLink.d.ts +0 -15
  125. package/lib/client/utils/getNavLink.js +0 -18
  126. package/lib/client/utils/getResolveRouteWithRedirect.d.ts +0 -5
  127. package/lib/client/utils/getResolveRouteWithRedirect.js +0 -22
@@ -1,113 +0,0 @@
1
- <script setup lang="ts">
2
- import { computed, toRefs } from 'vue'
3
- import type { PropType } from 'vue'
4
- import { useRoute } from 'vue-router'
5
- import { useSiteData } from 'vuepress/client'
6
- import { isLinkHttp, isLinkWithProtocol } from 'vuepress/shared'
7
- import type { NavLink } from '../../shared/index.js'
8
-
9
- defineOptions({
10
- inheritAttrs: false,
11
- })
12
-
13
- const props = defineProps({
14
- item: {
15
- type: Object as PropType<NavLink>,
16
- required: true,
17
- },
18
- })
19
-
20
- defineSlots<{
21
- before?: (props: Record<never, never>) => any
22
- after?: (props: Record<never, never>) => any
23
- }>()
24
-
25
- const route = useRoute()
26
- const site = useSiteData()
27
- const { item } = toRefs(props)
28
-
29
- // if the link has http protocol
30
- const hasHttpProtocol = computed(() => isLinkHttp(item.value.link))
31
- // if the link has non-http protocol
32
- const hasNonHttpProtocol = computed(
33
- () => !hasHttpProtocol.value && isLinkWithProtocol(item.value.link),
34
- )
35
- // resolve the `target` attr
36
- const linkTarget = computed(() => {
37
- if (hasNonHttpProtocol.value) return undefined
38
- if (item.value.target) return item.value.target
39
- if (hasHttpProtocol.value) return '_blank'
40
- return undefined
41
- })
42
- // if the `target` attr is '_blank'
43
- const isBlankTarget = computed(() => linkTarget.value === '_blank')
44
- // is `<RouterLink>` or not
45
- const isRouterLink = computed(
46
- () =>
47
- !hasHttpProtocol.value && !hasNonHttpProtocol.value && !isBlankTarget.value,
48
- )
49
- // resolve the `rel` attr
50
- const linkRel = computed(() => {
51
- if (hasNonHttpProtocol.value) return undefined
52
- if (item.value.rel) return item.value.rel
53
- if (isBlankTarget.value) return 'noopener noreferrer'
54
- return undefined
55
- })
56
- // resolve the `aria-label` attr
57
- const linkAriaLabel = computed(() => item.value.ariaLabel || item.value.text)
58
-
59
- // should be active when current route is a subpath of this link
60
- const shouldBeActiveInSubpath = computed(() => {
61
- const localeKeys = Object.keys(site.value.locales)
62
- if (localeKeys.length) {
63
- return !localeKeys.some((key) => key === item.value.link)
64
- }
65
- return item.value.link !== '/'
66
- })
67
- // if this link is active in subpath
68
- const isActiveInSubpath = computed(() => {
69
- if (!shouldBeActiveInSubpath.value) {
70
- return false
71
- }
72
- return route.path.startsWith(item.value.link)
73
- })
74
-
75
- // if this link is active
76
- const isActive = computed(() => {
77
- if (!isRouterLink.value) {
78
- return false
79
- }
80
- if (item.value.activeMatch) {
81
- return new RegExp(item.value.activeMatch).test(route.path)
82
- }
83
- return isActiveInSubpath.value
84
- })
85
- </script>
86
-
87
- <template>
88
- <RouterLink
89
- v-if="isRouterLink"
90
- :class="{ 'router-link-active': isActive }"
91
- :to="item.link"
92
- :aria-label="linkAriaLabel"
93
- v-bind="$attrs"
94
- >
95
- <slot name="before" />
96
- {{ item.text }}
97
- <slot name="after" />
98
- </RouterLink>
99
- <a
100
- v-else
101
- class="external-link"
102
- :href="item.link"
103
- :rel="linkRel"
104
- :target="linkTarget"
105
- :aria-label="linkAriaLabel"
106
- v-bind="$attrs"
107
- >
108
- <slot name="before" />
109
- {{ item.text }}
110
- <AutoLinkExternalIcon v-if="isBlankTarget" />
111
- <slot name="after" />
112
- </a>
113
- </template>
@@ -1,15 +0,0 @@
1
- <script setup lang="ts">
2
- import HomeContent from '@theme/HomeContent.vue'
3
- import HomeFeatures from '@theme/HomeFeatures.vue'
4
- import HomeFooter from '@theme/HomeFooter.vue'
5
- import HomeHero from '@theme/HomeHero.vue'
6
- </script>
7
-
8
- <template>
9
- <main class="home">
10
- <HomeHero />
11
- <HomeFeatures />
12
- <HomeContent />
13
- <HomeFooter />
14
- </main>
15
- </template>
@@ -1,5 +0,0 @@
1
- <template>
2
- <div class="theme-default-content">
3
- <Content />
4
- </div>
5
- </template>
@@ -1,22 +0,0 @@
1
- <script setup lang="ts">
2
- import { computed } from 'vue'
3
- import { usePageFrontmatter } from 'vuepress/client'
4
- import type { DefaultThemeHomePageFrontmatter } from '../../shared/index.js'
5
-
6
- const frontmatter = usePageFrontmatter<DefaultThemeHomePageFrontmatter>()
7
- const features = computed(() => {
8
- if (Array.isArray(frontmatter.value.features)) {
9
- return frontmatter.value.features
10
- }
11
- return []
12
- })
13
- </script>
14
-
15
- <template>
16
- <div v-if="features.length" class="features">
17
- <div v-for="feature in features" :key="feature.title" class="feature">
18
- <h2>{{ feature.title }}</h2>
19
- <p>{{ feature.details }}</p>
20
- </div>
21
- </div>
22
- </template>
@@ -1,79 +0,0 @@
1
- <script setup lang="ts">
2
- import NavbarBrand from '@theme/NavbarBrand.vue'
3
- import NavbarItems from '@theme/NavbarItems.vue'
4
- import ToggleColorModeButton from '@theme/ToggleColorModeButton.vue'
5
- import ToggleSidebarButton from '@theme/ToggleSidebarButton.vue'
6
- import { computed, ref } from 'vue'
7
- import {
8
- DeviceType,
9
- useThemeLocaleData,
10
- useUpdateDeviceStatus,
11
- } from '../composables/index.js'
12
-
13
- defineEmits<(e: 'toggle-sidebar') => void>()
14
-
15
- defineSlots<{
16
- before?: (props: Record<never, never>) => any
17
- after?: (props: Record<never, never>) => any
18
- }>()
19
-
20
- const themeLocale = useThemeLocaleData()
21
-
22
- const navbar = ref<HTMLElement | null>(null)
23
- const navbarBrand = ref<HTMLElement | null>(null)
24
-
25
- const linksWrapperMaxWidth = ref(0)
26
- const linksWrapperStyle = computed(() => {
27
- if (!linksWrapperMaxWidth.value) {
28
- return {}
29
- }
30
- return {
31
- maxWidth: linksWrapperMaxWidth.value + 'px',
32
- }
33
- })
34
-
35
- useUpdateDeviceStatus(
36
- DeviceType.MOBILE,
37
- (mobileDesktopBreakpoint: number): void => {
38
- // avoid overlapping of long title and long navbar links
39
- const navbarHorizontalPadding =
40
- getCssValue(navbar.value, 'paddingLeft') +
41
- getCssValue(navbar.value, 'paddingRight')
42
- if (window.innerWidth < mobileDesktopBreakpoint) {
43
- linksWrapperMaxWidth.value = 0
44
- } else {
45
- linksWrapperMaxWidth.value =
46
- navbar.value!.offsetWidth -
47
- navbarHorizontalPadding -
48
- (navbarBrand.value?.offsetWidth || 0)
49
- }
50
- },
51
- )
52
-
53
- function getCssValue(el: HTMLElement | null, property: string): number {
54
- // NOTE: Known bug, will return 'auto' if style value is 'auto'
55
- const val = el?.ownerDocument?.defaultView?.getComputedStyle(el, null)?.[
56
- property
57
- ]
58
- const num = Number.parseInt(val, 10)
59
- return Number.isNaN(num) ? 0 : num
60
- }
61
- </script>
62
-
63
- <template>
64
- <header ref="navbar" class="navbar">
65
- <ToggleSidebarButton @toggle="$emit('toggle-sidebar')" />
66
-
67
- <span ref="navbarBrand">
68
- <NavbarBrand />
69
- </span>
70
-
71
- <div class="navbar-items-wrapper" :style="linksWrapperStyle">
72
- <slot name="before" />
73
- <NavbarItems class="can-hide" />
74
- <slot name="after" />
75
- <ToggleColorModeButton v-if="themeLocale.colorModeSwitch" />
76
- <NavbarSearch />
77
- </div>
78
- </header>
79
- </template>
@@ -1,126 +0,0 @@
1
- <script setup lang="ts">
2
- import AutoLink from '@theme/AutoLink.vue'
3
- import DropdownTransition from '@theme/DropdownTransition.vue'
4
- import { computed, ref, toRefs, watch } from 'vue'
5
- import type { PropType } from 'vue'
6
- import { useRoute } from 'vue-router'
7
- import type { NavbarItem, ResolvedNavbarItem } from '../../shared/index.js'
8
-
9
- const props = defineProps({
10
- item: {
11
- type: Object as PropType<Exclude<ResolvedNavbarItem, NavbarItem>>,
12
- required: true,
13
- },
14
- })
15
-
16
- const { item } = toRefs(props)
17
-
18
- const dropdownAriaLabel = computed(
19
- () => item.value.ariaLabel || item.value.text,
20
- )
21
-
22
- const open = ref(false)
23
- const route = useRoute()
24
- watch(
25
- () => route.path,
26
- () => {
27
- open.value = false
28
- },
29
- )
30
-
31
- /**
32
- * Open the dropdown when user tab and click from keyboard.
33
- *
34
- * Use event.detail to detect tab and click from keyboard.
35
- * The Tab + Click is UIEvent > KeyboardEvent, so the detail is 0.
36
- *
37
- * @see https://developer.mozilla.org/en-US/docs/Web/API/UIEvent/detail
38
- */
39
- const handleDropdown = (e): void => {
40
- const isTriggerByTab = e.detail === 0
41
- if (isTriggerByTab) {
42
- open.value = !open.value
43
- } else {
44
- open.value = false
45
- }
46
- }
47
-
48
- const isLastItemOfArray = (item: unknown, arr: unknown[]): boolean =>
49
- arr[arr.length - 1] === item
50
- </script>
51
-
52
- <template>
53
- <div class="navbar-dropdown-wrapper" :class="{ open }">
54
- <button
55
- class="navbar-dropdown-title"
56
- type="button"
57
- :aria-label="dropdownAriaLabel"
58
- @click="handleDropdown"
59
- >
60
- <span class="title">{{ item.text }}</span>
61
- <span class="arrow down" />
62
- </button>
63
-
64
- <button
65
- class="navbar-dropdown-title-mobile"
66
- type="button"
67
- :aria-label="dropdownAriaLabel"
68
- @click="open = !open"
69
- >
70
- <span class="title">{{ item.text }}</span>
71
- <span class="arrow" :class="open ? 'down' : 'right'" />
72
- </button>
73
-
74
- <DropdownTransition>
75
- <ul v-show="open" class="navbar-dropdown">
76
- <li
77
- v-for="child in item.children"
78
- :key="child.text"
79
- class="navbar-dropdown-item"
80
- >
81
- <template v-if="child.children">
82
- <h4 class="navbar-dropdown-subtitle">
83
- <AutoLink
84
- v-if="child.link"
85
- :item="child"
86
- @focusout="
87
- isLastItemOfArray(child, item.children) &&
88
- child.children.length === 0 &&
89
- (open = false)
90
- "
91
- />
92
-
93
- <span v-else>{{ child.text }}</span>
94
- </h4>
95
-
96
- <ul class="navbar-dropdown-subitem-wrapper">
97
- <li
98
- v-for="grandchild in child.children"
99
- :key="grandchild.link"
100
- class="navbar-dropdown-subitem"
101
- >
102
- <AutoLink
103
- :item="grandchild"
104
- @focusout="
105
- isLastItemOfArray(grandchild, child.children) &&
106
- isLastItemOfArray(child, item.children) &&
107
- (open = false)
108
- "
109
- />
110
- </li>
111
- </ul>
112
- </template>
113
-
114
- <template v-else>
115
- <AutoLink
116
- :item="child"
117
- @focusout="
118
- isLastItemOfArray(child, item.children) && (open = false)
119
- "
120
- />
121
- </template>
122
- </li>
123
- </ul>
124
- </DropdownTransition>
125
- </div>
126
- </template>
@@ -1,199 +0,0 @@
1
- <script setup lang="ts">
2
- import AutoLink from '@theme/AutoLink.vue'
3
- import NavbarDropdown from '@theme/NavbarDropdown.vue'
4
- import { computed, ref } from 'vue'
5
- import type { ComputedRef } from 'vue'
6
- import { useRouter } from 'vue-router'
7
- import type { Router } from 'vue-router'
8
- import { useRouteLocale, useSiteData, useSiteLocaleData } from 'vuepress/client'
9
- import { isLinkHttp, isString } from 'vuepress/shared'
10
- import type {
11
- NavbarGroup,
12
- NavbarItem,
13
- ResolvedNavbarItem,
14
- } from '../../shared/index.js'
15
- import {
16
- DeviceType,
17
- useThemeData,
18
- useThemeLocaleData,
19
- useUpdateDeviceStatus,
20
- } from '../composables/index.js'
21
- import { getNavLink, resolveRepoType } from '../utils/index.js'
22
-
23
- /**
24
- * Get navbar config of select language dropdown
25
- */
26
- const useNavbarSelectLanguage = (): ComputedRef<ResolvedNavbarItem[]> => {
27
- const router = useRouter()
28
- const routeLocale = useRouteLocale()
29
- const site = useSiteData()
30
- const siteLocale = useSiteLocaleData()
31
- const theme = useThemeData()
32
- const themeLocale = useThemeLocaleData()
33
-
34
- return computed<ResolvedNavbarItem[]>(() => {
35
- const localePaths = Object.keys(site.value.locales)
36
- // do not display language selection dropdown if there is only one language
37
- if (localePaths.length < 2) {
38
- return []
39
- }
40
- const currentPath = router.currentRoute.value.path
41
- const currentFullPath = router.currentRoute.value.fullPath
42
-
43
- const languageDropdown: ResolvedNavbarItem = {
44
- text: `${themeLocale.value.selectLanguageText}`,
45
- ariaLabel: `${
46
- themeLocale.value.selectLanguageAriaLabel ??
47
- themeLocale.value.selectLanguageText
48
- }`,
49
- children: localePaths.map((targetLocalePath) => {
50
- // target locale config of this language link
51
- const targetSiteLocale = site.value.locales?.[targetLocalePath] ?? {}
52
- const targetThemeLocale = theme.value.locales?.[targetLocalePath] ?? {}
53
- const targetLang = `${targetSiteLocale.lang}`
54
-
55
- const text = targetThemeLocale.selectLanguageName ?? targetLang
56
- let link
57
-
58
- if (targetLang === siteLocale.value.lang) {
59
- // if the target language is current language
60
- // stay at current link
61
- link = currentFullPath
62
- } else {
63
- // if the target language is not current language
64
- // try to link to the corresponding page of current page
65
- // or fallback to homepage
66
- const targetLocalePage = currentPath.replace(
67
- routeLocale.value,
68
- targetLocalePath,
69
- )
70
- if (
71
- router.getRoutes().some((item) => item.path === targetLocalePage)
72
- ) {
73
- // try to keep current hash and params across languages
74
- link = currentFullPath.replace(currentPath, targetLocalePage)
75
- } else {
76
- link = targetThemeLocale.home ?? targetLocalePath
77
- }
78
- }
79
-
80
- return {
81
- text,
82
- link,
83
- }
84
- }),
85
- }
86
-
87
- return [languageDropdown]
88
- })
89
- }
90
-
91
- /**
92
- * Get navbar config of repository link
93
- */
94
- const useNavbarRepo = (): ComputedRef<ResolvedNavbarItem[]> => {
95
- const themeLocale = useThemeLocaleData()
96
-
97
- const repo = computed(() => themeLocale.value.repo)
98
- const repoType = computed(() =>
99
- repo.value ? resolveRepoType(repo.value) : null,
100
- )
101
-
102
- const repoLink = computed(() => {
103
- if (repo.value && !isLinkHttp(repo.value)) {
104
- return `https://github.com/${repo.value}`
105
- }
106
-
107
- return repo.value
108
- })
109
-
110
- const repoLabel = computed(() => {
111
- if (!repoLink.value) return null
112
- if (themeLocale.value.repoLabel) return themeLocale.value.repoLabel
113
- if (repoType.value === null) return 'Source'
114
- return repoType.value
115
- })
116
-
117
- return computed(() => {
118
- if (!repoLink.value || !repoLabel.value) {
119
- return []
120
- }
121
-
122
- return [
123
- {
124
- text: repoLabel.value,
125
- link: repoLink.value,
126
- },
127
- ]
128
- })
129
- }
130
-
131
- const resolveNavbarItem = (
132
- router: Router,
133
- item: NavbarItem | NavbarGroup | string,
134
- ): ResolvedNavbarItem => {
135
- if (isString(item)) {
136
- return getNavLink(router, item)
137
- }
138
- if ((item as NavbarGroup).children) {
139
- return {
140
- ...item,
141
- children: (item as NavbarGroup).children.map((item) =>
142
- resolveNavbarItem(router, item),
143
- ),
144
- }
145
- }
146
- return item as ResolvedNavbarItem
147
- }
148
-
149
- const useNavbarConfig = (): ComputedRef<ResolvedNavbarItem[]> => {
150
- const router = useRouter()
151
- const themeLocale = useThemeLocaleData()
152
-
153
- return computed(() =>
154
- (themeLocale.value.navbar || []).map((item) =>
155
- resolveNavbarItem(router, item),
156
- ),
157
- )
158
- }
159
-
160
- const isMobile = ref(false)
161
- const navbarConfig = useNavbarConfig()
162
- const navbarSelectLanguage = useNavbarSelectLanguage()
163
- const navbarRepo = useNavbarRepo()
164
- const navbarLinks = computed(() => [
165
- ...navbarConfig.value,
166
- ...navbarSelectLanguage.value,
167
- ...navbarRepo.value,
168
- ])
169
-
170
- useUpdateDeviceStatus(
171
- DeviceType.MOBILE,
172
- (mobileDesktopBreakpoint: number): void => {
173
- // avoid overlapping of long title and long navbar links
174
- if (window.innerWidth < mobileDesktopBreakpoint) {
175
- isMobile.value = true
176
- } else {
177
- isMobile.value = false
178
- }
179
- },
180
- )
181
-
182
- const navbarLabel = computed(() => {
183
- const themeLocale = useThemeLocaleData()
184
- return themeLocale.value.navbarLabel ?? 'site navigation'
185
- })
186
- </script>
187
-
188
- <template>
189
- <nav v-if="navbarLinks.length" class="navbar-items" :aria-label="navbarLabel">
190
- <div v-for="item in navbarLinks" :key="item.text" class="navbar-item">
191
- <NavbarDropdown
192
- v-if="item.children"
193
- :item="item"
194
- :class="isMobile ? 'mobile' : ''"
195
- />
196
- <AutoLink v-else :item="item" />
197
- </div>
198
- </nav>
199
- </template>
@@ -1,31 +0,0 @@
1
- <script setup lang="ts">
2
- import PageMeta from '@theme/PageMeta.vue'
3
- import PageNav from '@theme/PageNav.vue'
4
-
5
- defineSlots<{
6
- 'top'?: (props: Record<never, never>) => any
7
- 'bottom'?: (props: Record<never, never>) => any
8
- 'content-top'?: (props: Record<never, never>) => any
9
- 'content-bottom'?: (props: Record<never, never>) => any
10
- }>()
11
- </script>
12
-
13
- <template>
14
- <main class="page">
15
- <slot name="top" />
16
-
17
- <div class="theme-default-content">
18
- <slot name="content-top" />
19
-
20
- <Content />
21
-
22
- <slot name="content-bottom" />
23
- </div>
24
-
25
- <PageMeta />
26
-
27
- <PageNav />
28
-
29
- <slot name="bottom" />
30
- </main>
31
- </template>