@vuepress/theme-default 2.0.0-beta.9 → 2.0.0-rc.1

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 (118) hide show
  1. package/LICENSE +1 -1
  2. package/lib/client/components/AutoLink.vue +113 -0
  3. package/lib/client/components/DropdownTransition.vue +15 -24
  4. package/lib/client/components/Home.vue +12 -130
  5. package/lib/client/components/HomeContent.vue +5 -0
  6. package/lib/client/components/HomeFeatures.vue +22 -0
  7. package/lib/client/components/HomeFooter.vue +17 -0
  8. package/lib/client/components/HomeHero.vue +97 -0
  9. package/lib/client/components/Navbar.vue +60 -95
  10. package/lib/client/components/NavbarBrand.vue +55 -0
  11. package/lib/client/components/NavbarDropdown.vue +126 -0
  12. package/lib/client/components/{NavbarLinks.vue → NavbarItems.vue} +81 -61
  13. package/lib/client/components/Page.vue +16 -15
  14. package/lib/client/components/PageMeta.vue +51 -66
  15. package/lib/client/components/PageNav.vue +61 -64
  16. package/lib/client/components/Sidebar.vue +12 -32
  17. package/lib/client/components/SidebarItem.vue +87 -0
  18. package/lib/client/components/SidebarItems.vue +57 -0
  19. package/lib/client/components/ToggleColorModeButton.vue +57 -0
  20. package/lib/client/components/ToggleSidebarButton.vue +21 -24
  21. package/lib/client/components/global/Badge.vue +24 -26
  22. package/lib/client/components/global/CodeGroup.d.ts +5 -4
  23. package/lib/client/components/global/CodeGroup.js +85 -17
  24. package/lib/client/components/global/CodeGroupItem.vue +22 -20
  25. package/lib/client/components/global/index.d.ts +4 -0
  26. package/lib/client/components/global/index.js +4 -0
  27. package/lib/client/composables/index.d.ts +5 -5
  28. package/lib/client/composables/index.js +5 -5
  29. package/lib/client/composables/useDarkMode.d.ts +12 -0
  30. package/lib/client/composables/useDarkMode.js +57 -0
  31. package/lib/client/composables/useScrollPromise.js +1 -1
  32. package/lib/client/composables/useSidebarItems.d.ts +14 -8
  33. package/lib/client/composables/useSidebarItems.js +49 -48
  34. package/lib/client/composables/useThemeData.d.ts +2 -2
  35. package/lib/client/composables/useThemeData.js +1 -1
  36. package/lib/client/composables/useUpdateDeviceStatus.d.ts +7 -0
  37. package/lib/client/composables/useUpdateDeviceStatus.js +25 -0
  38. package/lib/client/config.d.ts +4 -0
  39. package/lib/client/config.js +44 -0
  40. package/lib/client/index.d.ts +3 -4
  41. package/lib/client/index.js +3 -2
  42. package/lib/client/layouts/Layout.vue +133 -136
  43. package/lib/client/layouts/NotFound.vue +27 -0
  44. package/lib/client/shim.d.ts +5 -0
  45. package/lib/client/styles/{_wrapper.scss → _mixins.scss} +7 -2
  46. package/lib/client/styles/_variables.module.scss +5 -0
  47. package/lib/client/styles/_variables.scss +0 -34
  48. package/lib/client/styles/arrow.scss +4 -6
  49. package/lib/client/styles/badge.scss +14 -11
  50. package/lib/client/styles/code-group.scss +10 -10
  51. package/lib/client/styles/code.scss +33 -46
  52. package/lib/client/styles/custom-container.scss +82 -18
  53. package/lib/client/styles/home.scss +32 -24
  54. package/lib/client/styles/index.scss +4 -4
  55. package/lib/client/styles/layout.scss +82 -73
  56. package/lib/client/styles/{dropdown.scss → navbar-dropdown.scss} +36 -50
  57. package/lib/client/styles/navbar.scss +106 -50
  58. package/lib/client/styles/normalize.scss +199 -0
  59. package/lib/client/styles/page.scss +24 -8
  60. package/lib/client/styles/sidebar.scss +69 -87
  61. package/lib/client/styles/transitions.scss +13 -4
  62. package/lib/client/styles/vars-dark.scss +68 -0
  63. package/lib/client/styles/vars.scss +155 -0
  64. package/lib/client/utils/getNavLink.d.ts +15 -0
  65. package/lib/client/utils/getNavLink.js +18 -0
  66. package/lib/client/utils/getResolveRouteWithRedirect.d.ts +5 -0
  67. package/lib/client/{composables/useResolveRouteWithRedirect.js → utils/getResolveRouteWithRedirect.js} +4 -6
  68. package/lib/client/utils/index.d.ts +5 -2
  69. package/lib/client/utils/index.js +5 -2
  70. package/lib/client/utils/isActiveSidebarItem.d.ts +3 -0
  71. package/lib/client/utils/isActiveSidebarItem.js +20 -0
  72. package/lib/client/utils/resolveEditLink.d.ts +2 -2
  73. package/lib/client/utils/resolveEditLink.js +15 -9
  74. package/lib/client/utils/resolveRepoType.d.ts +1 -1
  75. package/lib/client/utils/resolveRepoType.js +4 -2
  76. package/lib/node/defaultTheme.d.ts +4 -4
  77. package/lib/node/defaultTheme.js +111 -48
  78. package/lib/node/index.d.ts +4 -4
  79. package/lib/node/index.js +5 -17
  80. package/lib/node/utils/assignDefaultLocaleOptions.d.ts +4 -2
  81. package/lib/node/utils/assignDefaultLocaleOptions.js +13 -13
  82. package/lib/node/utils/index.d.ts +2 -5
  83. package/lib/node/utils/index.js +2 -17
  84. package/lib/node/utils/resolveContainerPluginOptions.d.ts +2 -20
  85. package/lib/node/utils/resolveContainerPluginOptions.js +4 -66
  86. package/lib/shared/index.d.ts +3 -3
  87. package/lib/shared/index.js +3 -15
  88. package/lib/shared/nav.d.ts +16 -18
  89. package/lib/shared/nav.js +1 -2
  90. package/lib/shared/options.d.ts +51 -6
  91. package/lib/shared/options.js +1 -2
  92. package/lib/shared/page.d.ts +15 -6
  93. package/lib/shared/page.js +1 -2
  94. package/package.json +43 -25
  95. package/templates/build.html +34 -0
  96. package/CHANGELOG.md +0 -419
  97. package/lib/client/clientAppEnhance.d.ts +0 -3
  98. package/lib/client/clientAppEnhance.js +0 -28
  99. package/lib/client/clientAppSetup.d.ts +0 -2
  100. package/lib/client/clientAppSetup.js +0 -11
  101. package/lib/client/components/DropdownLink.vue +0 -141
  102. package/lib/client/components/NavLink.vue +0 -115
  103. package/lib/client/components/SidebarChild.d.ts +0 -6
  104. package/lib/client/components/SidebarChild.js +0 -91
  105. package/lib/client/components/global/OutboundLink.vue +0 -30
  106. package/lib/client/composables/useNavLink.d.ts +0 -9
  107. package/lib/client/composables/useNavLink.js +0 -15
  108. package/lib/client/composables/useResolveRouteWithRedirect.d.ts +0 -5
  109. package/lib/client/layouts/404.vue +0 -38
  110. package/lib/client/styles/_normalize.scss +0 -148
  111. package/lib/client/styles/plugins.scss +0 -18
  112. package/lib/client/styles/sr-only.scss +0 -12
  113. package/lib/node/utils/resolveActiveHeaderLinksPluginOptions.d.ts +0 -6
  114. package/lib/node/utils/resolveActiveHeaderLinksPluginOptions.js +0 -16
  115. package/lib/node/utils/resolveGitPluginOptions.d.ts +0 -6
  116. package/lib/node/utils/resolveGitPluginOptions.js +0 -22
  117. package/lib/node/utils/resolveMediumZoomPluginOptions.d.ts +0 -6
  118. package/lib/node/utils/resolveMediumZoomPluginOptions.js +0 -17
@@ -0,0 +1,126 @@
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,28 +1,24 @@
1
- <template>
2
- <nav v-if="navbarLinks.length" class="navbar-links">
3
- <div v-for="item in navbarLinks" :key="item.link" class="navbar-links-item">
4
- <template v-if="item.children">
5
- <DropdownLink :item="item" />
6
- </template>
7
-
8
- <template v-else>
9
- <NavLink :item="item" />
10
- </template>
11
- </div>
12
- </nav>
13
- </template>
14
-
15
- <script lang="ts">
16
- import { computed, defineComponent } from 'vue'
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'
17
5
  import type { ComputedRef } from 'vue'
18
6
  import { useRouter } from 'vue-router'
19
- import { useRouteLocale, useSiteLocaleData } from '@vuepress/client'
20
- import { isString } from '@vuepress/shared'
21
- import type { NavbarItem, NavbarGroup, ResolvedNavbarItem } from '../../shared'
22
- import { useNavLink, useThemeLocaleData } from '../composables'
23
- import { resolveRepoType } from '../utils'
24
- import DropdownLink from './DropdownLink.vue'
25
- import NavLink from './NavLink.vue'
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'
26
22
 
27
23
  /**
28
24
  * Get navbar config of select language dropdown
@@ -30,11 +26,13 @@ import NavLink from './NavLink.vue'
30
26
  const useNavbarSelectLanguage = (): ComputedRef<ResolvedNavbarItem[]> => {
31
27
  const router = useRouter()
32
28
  const routeLocale = useRouteLocale()
29
+ const site = useSiteData()
33
30
  const siteLocale = useSiteLocaleData()
31
+ const theme = useThemeData()
34
32
  const themeLocale = useThemeLocaleData()
35
33
 
36
34
  return computed<ResolvedNavbarItem[]>(() => {
37
- const localePaths = Object.keys(siteLocale.value.locales)
35
+ const localePaths = Object.keys(site.value.locales)
38
36
  // do not display language selection dropdown if there is only one language
39
37
  if (localePaths.length < 2) {
40
38
  return []
@@ -43,14 +41,15 @@ const useNavbarSelectLanguage = (): ComputedRef<ResolvedNavbarItem[]> => {
43
41
  const currentFullPath = router.currentRoute.value.fullPath
44
42
 
45
43
  const languageDropdown: ResolvedNavbarItem = {
46
- text: themeLocale.value.selectLanguageText ?? 'unkown language',
47
- ariaLabel: themeLocale.value.selectLanguageAriaLabel ?? 'unkown language',
44
+ text: `${themeLocale.value.selectLanguageText}`,
45
+ ariaLabel: `${
46
+ themeLocale.value.selectLanguageAriaLabel ??
47
+ themeLocale.value.selectLanguageText
48
+ }`,
48
49
  children: localePaths.map((targetLocalePath) => {
49
- // target locale config of this langauge link
50
- const targetSiteLocale =
51
- siteLocale.value.locales?.[targetLocalePath] ?? {}
52
- const targetThemeLocale =
53
- themeLocale.value.locales?.[targetLocalePath] ?? {}
50
+ // target locale config of this language link
51
+ const targetSiteLocale = site.value.locales?.[targetLocalePath] ?? {}
52
+ const targetThemeLocale = theme.value.locales?.[targetLocalePath] ?? {}
54
53
  const targetLang = `${targetSiteLocale.lang}`
55
54
 
56
55
  const text = targetThemeLocale.selectLanguageName ?? targetLang
@@ -66,12 +65,13 @@ const useNavbarSelectLanguage = (): ComputedRef<ResolvedNavbarItem[]> => {
66
65
  // or fallback to homepage
67
66
  const targetLocalePage = currentPath.replace(
68
67
  routeLocale.value,
69
- targetLocalePath
68
+ targetLocalePath,
70
69
  )
71
70
  if (
72
71
  router.getRoutes().some((item) => item.path === targetLocalePage)
73
72
  ) {
74
- link = targetLocalePage
73
+ // try to keep current hash and params across languages
74
+ link = currentFullPath.replace(currentPath, targetLocalePage)
75
75
  } else {
76
76
  link = targetThemeLocale.home ?? targetLocalePath
77
77
  }
@@ -96,13 +96,14 @@ const useNavbarRepo = (): ComputedRef<ResolvedNavbarItem[]> => {
96
96
 
97
97
  const repo = computed(() => themeLocale.value.repo)
98
98
  const repoType = computed(() =>
99
- repo.value ? resolveRepoType(repo.value) : null
99
+ repo.value ? resolveRepoType(repo.value) : null,
100
100
  )
101
101
 
102
102
  const repoLink = computed(() => {
103
- if (repoType.value === 'GitHub') {
103
+ if (repo.value && !isLinkHttp(repo.value)) {
104
104
  return `https://github.com/${repo.value}`
105
105
  }
106
+
106
107
  return repo.value
107
108
  })
108
109
 
@@ -128,47 +129,66 @@ const useNavbarRepo = (): ComputedRef<ResolvedNavbarItem[]> => {
128
129
  }
129
130
 
130
131
  const resolveNavbarItem = (
131
- item: NavbarItem | NavbarGroup | string
132
+ router: Router,
133
+ item: NavbarItem | NavbarGroup | string,
132
134
  ): ResolvedNavbarItem => {
133
135
  if (isString(item)) {
134
- return useNavLink(item)
136
+ return getNavLink(router, item)
135
137
  }
136
138
  if ((item as NavbarGroup).children) {
137
139
  return {
138
140
  ...item,
139
- children: (item as NavbarGroup).children.map(resolveNavbarItem),
141
+ children: (item as NavbarGroup).children.map((item) =>
142
+ resolveNavbarItem(router, item),
143
+ ),
140
144
  }
141
145
  }
142
146
  return item as ResolvedNavbarItem
143
147
  }
144
148
 
145
149
  const useNavbarConfig = (): ComputedRef<ResolvedNavbarItem[]> => {
150
+ const router = useRouter()
146
151
  const themeLocale = useThemeLocaleData()
147
- return computed(() => (themeLocale.value.navbar || []).map(resolveNavbarItem))
148
- }
149
-
150
- export default defineComponent({
151
- name: 'NavbarLinks',
152
-
153
- components: {
154
- NavLink,
155
- DropdownLink,
156
- },
157
-
158
- setup() {
159
- const navbarConfig = useNavbarConfig()
160
- const navbarSelectLanguage = useNavbarSelectLanguage()
161
- const navbarRepo = useNavbarRepo()
162
152
 
163
- const navbarLinks = computed(() => [
164
- ...navbarConfig.value,
165
- ...navbarSelectLanguage.value,
166
- ...navbarRepo.value,
167
- ])
153
+ return computed(() =>
154
+ (themeLocale.value.navbar || []).map((item) =>
155
+ resolveNavbarItem(router, item),
156
+ ),
157
+ )
158
+ }
168
159
 
169
- return {
170
- navbarLinks,
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
171
178
  }
172
179
  },
173
- })
180
+ )
174
181
  </script>
182
+
183
+ <template>
184
+ <nav v-if="navbarLinks.length" class="navbar-items">
185
+ <div v-for="item in navbarLinks" :key="item.text" class="navbar-item">
186
+ <NavbarDropdown
187
+ v-if="item.children"
188
+ :item="item"
189
+ :class="isMobile ? 'mobile' : ''"
190
+ />
191
+ <AutoLink v-else :item="item" />
192
+ </div>
193
+ </nav>
194
+ </template>
@@ -1,9 +1,25 @@
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
+
1
13
  <template>
2
14
  <main class="page">
3
15
  <slot name="top" />
4
16
 
5
17
  <div class="theme-default-content">
18
+ <slot name="content-top" />
19
+
6
20
  <Content />
21
+
22
+ <slot name="content-bottom" />
7
23
  </div>
8
24
 
9
25
  <PageMeta />
@@ -13,18 +29,3 @@
13
29
  <slot name="bottom" />
14
30
  </main>
15
31
  </template>
16
-
17
- <script>
18
- import { defineComponent } from 'vue'
19
- import PageMeta from './PageMeta.vue'
20
- import PageNav from './PageNav.vue'
21
-
22
- export default defineComponent({
23
- name: 'Page',
24
-
25
- components: {
26
- PageMeta,
27
- PageNav,
28
- },
29
- })
30
- </script>
@@ -1,48 +1,20 @@
1
- <template>
2
- <footer class="page-meta">
3
- <div v-if="editNavLink" class="meta-item edit-link">
4
- <NavLink class="meta-item-label" :item="editNavLink" />
5
- </div>
6
-
7
- <div v-if="lastUpdated" class="meta-item last-updated">
8
- <span class="meta-item-label">{{ themeLocale.lastUpdatedText }}: </span>
9
- <span class="meta-item-info">{{ lastUpdated }}</span>
10
- </div>
11
-
12
- <div
13
- v-if="contributors && contributors.length"
14
- class="meta-item contributors"
15
- >
16
- <span class="meta-item-label">{{ themeLocale.contributorsText }}: </span>
17
- <span class="meta-item-info">
18
- <template v-for="(contributor, index) in contributors" :key="index">
19
- <span class="contributor" :title="`email: ${contributor.email}`">
20
- {{ contributor.name }}
21
- </span>
22
- <template v-if="index !== contributors.length - 1">, </template>
23
- </template>
24
- </span>
25
- </div>
26
- </footer>
27
- </template>
28
-
29
- <script lang="ts">
30
- import { computed, defineComponent } from 'vue'
1
+ <script setup lang="ts">
2
+ import AutoLink from '@theme/AutoLink.vue'
3
+ import { computed } from 'vue'
31
4
  import type { ComputedRef } from 'vue'
32
- import {
33
- usePageData,
34
- usePageFrontmatter,
35
- useSiteLocaleData,
36
- } from '@vuepress/client'
37
- import type { DefaultThemePageData, NavLink as NavLinkType } from '../../shared'
38
- import { useThemeLocaleData } from '../composables'
39
- import { resolveEditLink } from '../utils'
40
- import NavLink from './NavLink.vue'
41
-
42
- const useEditNavLink = (): ComputedRef<null | NavLinkType> => {
5
+ import { usePageData, usePageFrontmatter } from 'vuepress/client'
6
+ import type {
7
+ DefaultThemeNormalPageFrontmatter,
8
+ DefaultThemePageData,
9
+ NavLink,
10
+ } from '../../shared/index.js'
11
+ import { useThemeLocaleData } from '../composables/index.js'
12
+ import { resolveEditLink } from '../utils/index.js'
13
+
14
+ const useEditNavLink = (): ComputedRef<null | NavLink> => {
43
15
  const themeLocale = useThemeLocaleData()
44
16
  const page = usePageData<DefaultThemePageData>()
45
- const frontmatter = usePageFrontmatter()
17
+ const frontmatter = usePageFrontmatter<DefaultThemeNormalPageFrontmatter>()
46
18
 
47
19
  return computed(() => {
48
20
  const showEditLink =
@@ -66,7 +38,8 @@ const useEditNavLink = (): ComputedRef<null | NavLinkType> => {
66
38
  docsBranch,
67
39
  docsDir,
68
40
  filePathRelative: page.value.filePathRelative,
69
- editLinkPattern: themeLocale.value.editLinkPattern,
41
+ editLinkPattern:
42
+ frontmatter.value.editLinkPattern ?? themeLocale.value.editLinkPattern,
70
43
  })
71
44
 
72
45
  if (!editLink) return null
@@ -79,10 +52,9 @@ const useEditNavLink = (): ComputedRef<null | NavLinkType> => {
79
52
  }
80
53
 
81
54
  const useLastUpdated = (): ComputedRef<null | string> => {
82
- const siteLocale = useSiteLocaleData()
83
55
  const themeLocale = useThemeLocaleData()
84
56
  const page = usePageData<DefaultThemePageData>()
85
- const frontmatter = usePageFrontmatter()
57
+ const frontmatter = usePageFrontmatter<DefaultThemeNormalPageFrontmatter>()
86
58
 
87
59
  return computed(() => {
88
60
  const showLastUpdated =
@@ -94,7 +66,7 @@ const useLastUpdated = (): ComputedRef<null | string> => {
94
66
 
95
67
  const updatedDate = new Date(page.value.git?.updatedTime)
96
68
 
97
- return updatedDate.toLocaleString(siteLocale.value.lang)
69
+ return updatedDate.toLocaleString()
98
70
  })
99
71
  }
100
72
 
@@ -103,7 +75,7 @@ const useContributors = (): ComputedRef<
103
75
  > => {
104
76
  const themeLocale = useThemeLocaleData()
105
77
  const page = usePageData<DefaultThemePageData>()
106
- const frontmatter = usePageFrontmatter()
78
+ const frontmatter = usePageFrontmatter<DefaultThemeNormalPageFrontmatter>()
107
79
 
108
80
  return computed(() => {
109
81
  const showContributors =
@@ -115,25 +87,38 @@ const useContributors = (): ComputedRef<
115
87
  })
116
88
  }
117
89
 
118
- export default defineComponent({
119
- name: 'PageMeta',
90
+ const themeLocale = useThemeLocaleData()
91
+ const editNavLink = useEditNavLink()
92
+ const lastUpdated = useLastUpdated()
93
+ const contributors = useContributors()
94
+ </script>
120
95
 
121
- components: {
122
- NavLink,
123
- },
96
+ <template>
97
+ <footer class="page-meta">
98
+ <div v-if="editNavLink" class="meta-item edit-link">
99
+ <AutoLink class="meta-item-label" :item="editNavLink" />
100
+ </div>
124
101
 
125
- setup() {
126
- const themeLocale = useThemeLocaleData()
127
- const editNavLink = useEditNavLink()
128
- const lastUpdated = useLastUpdated()
129
- const contributors = useContributors()
102
+ <div v-if="lastUpdated" class="meta-item last-updated">
103
+ <span class="meta-item-label">{{ themeLocale.lastUpdatedText }}: </span>
104
+ <ClientOnly>
105
+ <span class="meta-item-info">{{ lastUpdated }}</span>
106
+ </ClientOnly>
107
+ </div>
130
108
 
131
- return {
132
- themeLocale,
133
- editNavLink,
134
- lastUpdated,
135
- contributors,
136
- }
137
- },
138
- })
139
- </script>
109
+ <div
110
+ v-if="contributors && contributors.length"
111
+ class="meta-item contributors"
112
+ >
113
+ <span class="meta-item-label">{{ themeLocale.contributorsText }}: </span>
114
+ <span class="meta-item-info">
115
+ <template v-for="(contributor, index) in contributors" :key="index">
116
+ <span class="contributor" :title="`email: ${contributor.email}`">
117
+ {{ contributor.name }}
118
+ </span>
119
+ <template v-if="index !== contributors.length - 1">, </template>
120
+ </template>
121
+ </span>
122
+ </div>
123
+ </footer>
124
+ </template>