@vuepress/theme-default 2.0.0-rc.32 → 2.0.0-rc.34
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/client/components/VPDarkIcon.vue +8 -0
- package/lib/client/components/{DropdownTransition.vue → VPDropdownTransition.vue} +10 -1
- package/lib/client/components/VPEditIcon.vue +12 -0
- package/lib/client/components/VPHome.vue +38 -0
- package/lib/client/components/VPHomeFeatures.vue +68 -0
- package/lib/client/components/{HomeFooter.vue → VPHomeFooter.vue} +16 -2
- package/lib/client/components/{HomeHero.vue → VPHomeHero.vue} +107 -5
- package/lib/client/components/VPLightIcon.vue +28 -0
- package/lib/client/components/VPNavbar.vue +127 -0
- package/lib/client/components/{NavbarBrand.vue → VPNavbarBrand.vue} +36 -4
- package/lib/client/components/VPNavbarDropdown.vue +319 -0
- package/lib/client/components/VPNavbarItems.vue +110 -0
- package/lib/client/components/VPPage.vue +66 -0
- package/lib/client/components/VPPageMeta.vue +132 -0
- package/lib/client/components/VPPageNav.vue +118 -0
- package/lib/client/components/VPSidebar.vue +112 -0
- package/lib/client/components/VPSidebarItem.vue +169 -0
- package/lib/client/components/{SidebarItems.vue → VPSidebarItems.vue} +30 -6
- package/lib/client/components/VPToggleColorModeButton.vue +54 -0
- package/lib/client/components/VPToggleSidebarButton.vue +92 -0
- package/lib/client/components/global/Badge.vue +60 -18
- package/lib/client/components/global/CodeGroup.d.ts +1 -0
- package/lib/client/components/global/CodeGroup.js +4 -3
- package/lib/client/components/global/CodeGroupItem.vue +5 -16
- package/lib/client/composables/index.d.ts +7 -0
- package/lib/client/composables/index.js +7 -0
- package/lib/client/composables/useContributors.d.ts +3 -0
- package/lib/client/composables/useContributors.js +14 -0
- package/lib/client/composables/useDarkMode.js +1 -1
- package/lib/client/composables/useEditLink.d.ts +3 -0
- package/lib/client/composables/useEditLink.js +31 -0
- package/lib/client/composables/useLastUpdated.d.ts +2 -0
- package/lib/client/composables/useLastUpdated.js +17 -0
- package/lib/client/composables/useNavbarConfig.d.ts +3 -0
- package/lib/client/composables/useNavbarConfig.js +25 -0
- package/lib/client/composables/useNavbarRepo.d.ts +6 -0
- package/lib/client/composables/useNavbarRepo.js +38 -0
- package/lib/client/composables/useNavbarSelectLanguage.d.ts +6 -0
- package/lib/client/composables/useNavbarSelectLanguage.js +58 -0
- package/lib/client/composables/useNavigate.js +4 -7
- package/lib/client/composables/useRelatedLinks.d.ts +8 -0
- package/lib/client/composables/useRelatedLinks.js +73 -0
- package/lib/client/composables/useSidebarItems.d.ts +10 -9
- package/lib/client/composables/useSidebarItems.js +58 -47
- package/lib/client/config.d.ts +1 -0
- package/lib/client/config.js +2 -1
- package/lib/client/index.d.ts +1 -0
- package/lib/client/index.js +1 -0
- package/lib/client/layouts/Layout.vue +111 -18
- package/lib/client/layouts/NotFound.vue +1 -1
- package/lib/client/styles/_mixins.scss +4 -4
- package/lib/client/styles/_variables.module.scss +1 -1
- package/lib/client/styles/_variables.scss +1 -0
- package/lib/client/styles/code-group.scss +32 -29
- package/lib/client/styles/{code.scss → content/code.scss} +81 -99
- package/lib/client/styles/{custom-container.scss → content/custom-container.scss} +9 -5
- package/lib/client/styles/content/index.scss +4 -0
- package/lib/client/styles/content/normalize.scss +39 -0
- package/lib/client/styles/{toc.scss → content/toc.scss} +1 -1
- package/lib/client/styles/external-link-icon.scss +7 -3
- package/lib/client/styles/index.scss +2 -13
- package/lib/client/styles/layout.scss +3 -203
- package/lib/client/styles/normalize.scss +18 -149
- package/lib/client/styles/plugins.scss +20 -0
- package/lib/client/styles/vars-dark.scss +17 -16
- package/lib/client/styles/vars.scss +19 -23
- package/lib/client/typings.d.ts +13 -0
- package/lib/client/typings.js +1 -0
- package/lib/client/utils/{getNavLink.d.ts → getAutoLink.d.ts} +2 -2
- package/lib/client/utils/index.d.ts +3 -1
- package/lib/client/utils/index.js +3 -1
- package/lib/client/utils/isActiveSidebarItem.d.ts +2 -2
- package/lib/client/utils/isActiveSidebarItem.js +3 -3
- package/lib/client/utils/isLinkInternal.d.ts +1 -0
- package/lib/client/utils/isLinkInternal.js +2 -0
- package/lib/client/utils/resolvePrefix.d.ts +1 -0
- package/lib/client/utils/resolvePrefix.js +4 -0
- package/lib/node/defaultTheme.js +9 -1
- package/lib/node/utils/assignDefaultLocaleOptions.js +1 -1
- package/lib/shared/index.d.ts +2 -0
- package/lib/shared/index.js +2 -0
- package/lib/shared/nav.d.ts +23 -26
- package/lib/shared/navbar.d.ts +21 -0
- package/lib/shared/navbar.js +1 -0
- package/lib/shared/options.d.ts +4 -3
- package/lib/shared/page.d.ts +2 -2
- package/lib/shared/sidebar.d.ts +26 -0
- package/lib/shared/sidebar.js +1 -0
- package/package.json +19 -19
- package/templates/build.html +2 -0
- package/lib/client/components/Home.vue +0 -15
- package/lib/client/components/HomeContent.vue +0 -5
- package/lib/client/components/HomeFeatures.vue +0 -22
- package/lib/client/components/Navbar.vue +0 -80
- package/lib/client/components/NavbarDropdown.vue +0 -125
- package/lib/client/components/NavbarItems.vue +0 -198
- package/lib/client/components/Page.vue +0 -31
- package/lib/client/components/PageMeta.vue +0 -220
- package/lib/client/components/PageNav.vue +0 -228
- package/lib/client/components/Sidebar.vue +0 -18
- package/lib/client/components/SidebarItem.vue +0 -86
- package/lib/client/components/ToggleColorModeButton.vue +0 -57
- package/lib/client/components/ToggleSidebarButton.vue +0 -24
- package/lib/client/styles/badge.scss +0 -36
- package/lib/client/styles/home.scss +0 -168
- package/lib/client/styles/navbar-dropdown.scss +0 -183
- package/lib/client/styles/navbar.scss +0 -197
- package/lib/client/styles/page.scss +0 -11
- package/lib/client/styles/sidebar.scss +0 -134
- package/lib/client/styles/transitions.scss +0 -22
- /package/lib/client/utils/{getNavLink.js → getAutoLink.js} +0 -0
|
@@ -1,125 +0,0 @@
|
|
|
1
|
-
<script setup lang="ts">
|
|
2
|
-
import DropdownTransition from '@theme/DropdownTransition.vue'
|
|
3
|
-
import { computed, ref, toRefs, watch } from 'vue'
|
|
4
|
-
import type { PropType } from 'vue'
|
|
5
|
-
import { AutoLink, useRoute } from 'vuepress/client'
|
|
6
|
-
import type { NavbarItem, ResolvedNavbarItem } from '../../shared/index.js'
|
|
7
|
-
|
|
8
|
-
const props = defineProps({
|
|
9
|
-
item: {
|
|
10
|
-
type: Object as PropType<Exclude<ResolvedNavbarItem, NavbarItem>>,
|
|
11
|
-
required: true,
|
|
12
|
-
},
|
|
13
|
-
})
|
|
14
|
-
|
|
15
|
-
const { item } = toRefs(props)
|
|
16
|
-
|
|
17
|
-
const dropdownAriaLabel = computed(
|
|
18
|
-
() => item.value.ariaLabel || item.value.text,
|
|
19
|
-
)
|
|
20
|
-
|
|
21
|
-
const open = ref(false)
|
|
22
|
-
const route = useRoute()
|
|
23
|
-
watch(
|
|
24
|
-
() => route.path,
|
|
25
|
-
() => {
|
|
26
|
-
open.value = false
|
|
27
|
-
},
|
|
28
|
-
)
|
|
29
|
-
|
|
30
|
-
/**
|
|
31
|
-
* Open the dropdown when user tab and click from keyboard.
|
|
32
|
-
*
|
|
33
|
-
* Use event.detail to detect tab and click from keyboard.
|
|
34
|
-
* The Tab + Click is UIEvent > KeyboardEvent, so the detail is 0.
|
|
35
|
-
*
|
|
36
|
-
* @see https://developer.mozilla.org/en-US/docs/Web/API/UIEvent/detail
|
|
37
|
-
*/
|
|
38
|
-
const handleDropdown = (e): void => {
|
|
39
|
-
const isTriggerByTab = e.detail === 0
|
|
40
|
-
if (isTriggerByTab) {
|
|
41
|
-
open.value = !open.value
|
|
42
|
-
} else {
|
|
43
|
-
open.value = false
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
const isLastItemOfArray = (item: unknown, arr: unknown[]): boolean =>
|
|
48
|
-
arr[arr.length - 1] === item
|
|
49
|
-
</script>
|
|
50
|
-
|
|
51
|
-
<template>
|
|
52
|
-
<div class="navbar-dropdown-wrapper" :class="{ open }">
|
|
53
|
-
<button
|
|
54
|
-
class="navbar-dropdown-title"
|
|
55
|
-
type="button"
|
|
56
|
-
:aria-label="dropdownAriaLabel"
|
|
57
|
-
@click="handleDropdown"
|
|
58
|
-
>
|
|
59
|
-
<span class="title">{{ item.text }}</span>
|
|
60
|
-
<span class="arrow down" />
|
|
61
|
-
</button>
|
|
62
|
-
|
|
63
|
-
<button
|
|
64
|
-
class="navbar-dropdown-title-mobile"
|
|
65
|
-
type="button"
|
|
66
|
-
:aria-label="dropdownAriaLabel"
|
|
67
|
-
@click="open = !open"
|
|
68
|
-
>
|
|
69
|
-
<span class="title">{{ item.text }}</span>
|
|
70
|
-
<span class="arrow" :class="open ? 'down' : 'right'" />
|
|
71
|
-
</button>
|
|
72
|
-
|
|
73
|
-
<DropdownTransition>
|
|
74
|
-
<ul v-show="open" class="navbar-dropdown">
|
|
75
|
-
<li
|
|
76
|
-
v-for="child in item.children"
|
|
77
|
-
:key="child.text"
|
|
78
|
-
class="navbar-dropdown-item"
|
|
79
|
-
>
|
|
80
|
-
<template v-if="child.children">
|
|
81
|
-
<h4 class="navbar-dropdown-subtitle">
|
|
82
|
-
<AutoLink
|
|
83
|
-
v-if="child.link"
|
|
84
|
-
:config="child"
|
|
85
|
-
@focusout="
|
|
86
|
-
isLastItemOfArray(child, item.children) &&
|
|
87
|
-
child.children.length === 0 &&
|
|
88
|
-
(open = false)
|
|
89
|
-
"
|
|
90
|
-
/>
|
|
91
|
-
|
|
92
|
-
<span v-else>{{ child.text }}</span>
|
|
93
|
-
</h4>
|
|
94
|
-
|
|
95
|
-
<ul class="navbar-dropdown-subitem-wrapper">
|
|
96
|
-
<li
|
|
97
|
-
v-for="grandchild in child.children"
|
|
98
|
-
:key="grandchild.link"
|
|
99
|
-
class="navbar-dropdown-subitem"
|
|
100
|
-
>
|
|
101
|
-
<AutoLink
|
|
102
|
-
:config="grandchild"
|
|
103
|
-
@focusout="
|
|
104
|
-
isLastItemOfArray(grandchild, child.children) &&
|
|
105
|
-
isLastItemOfArray(child, item.children) &&
|
|
106
|
-
(open = false)
|
|
107
|
-
"
|
|
108
|
-
/>
|
|
109
|
-
</li>
|
|
110
|
-
</ul>
|
|
111
|
-
</template>
|
|
112
|
-
|
|
113
|
-
<template v-else>
|
|
114
|
-
<AutoLink
|
|
115
|
-
:config="child"
|
|
116
|
-
@focusout="
|
|
117
|
-
isLastItemOfArray(child, item.children) && (open = false)
|
|
118
|
-
"
|
|
119
|
-
/>
|
|
120
|
-
</template>
|
|
121
|
-
</li>
|
|
122
|
-
</ul>
|
|
123
|
-
</DropdownTransition>
|
|
124
|
-
</div>
|
|
125
|
-
</template>
|
|
@@ -1,198 +0,0 @@
|
|
|
1
|
-
<script setup lang="ts">
|
|
2
|
-
import NavbarDropdown from '@theme/NavbarDropdown.vue'
|
|
3
|
-
import { useRoutePaths } from '@vuepress/helper/client'
|
|
4
|
-
import { computed, ref } from 'vue'
|
|
5
|
-
import type { ComputedRef } from 'vue'
|
|
6
|
-
import {
|
|
7
|
-
AutoLink,
|
|
8
|
-
useRoute,
|
|
9
|
-
useRouteLocale,
|
|
10
|
-
useSiteData,
|
|
11
|
-
useSiteLocaleData,
|
|
12
|
-
} from 'vuepress/client'
|
|
13
|
-
import { isLinkHttp, isString } from 'vuepress/shared'
|
|
14
|
-
import type {
|
|
15
|
-
NavbarGroup,
|
|
16
|
-
NavbarItem,
|
|
17
|
-
ResolvedNavbarItem,
|
|
18
|
-
} from '../../shared/index.js'
|
|
19
|
-
import {
|
|
20
|
-
DeviceType,
|
|
21
|
-
useThemeData,
|
|
22
|
-
useThemeLocaleData,
|
|
23
|
-
useUpdateDeviceStatus,
|
|
24
|
-
} from '../composables/index.js'
|
|
25
|
-
import { getAutoLink, resolveRepoType } from '../utils/index.js'
|
|
26
|
-
|
|
27
|
-
/**
|
|
28
|
-
* Get navbar config of select language dropdown
|
|
29
|
-
*/
|
|
30
|
-
const useNavbarSelectLanguage = (): ComputedRef<ResolvedNavbarItem[]> => {
|
|
31
|
-
const route = useRoute()
|
|
32
|
-
const routePaths = useRoutePaths()
|
|
33
|
-
const routeLocale = useRouteLocale()
|
|
34
|
-
const site = useSiteData()
|
|
35
|
-
const siteLocale = useSiteLocaleData()
|
|
36
|
-
const theme = useThemeData()
|
|
37
|
-
const themeLocale = useThemeLocaleData()
|
|
38
|
-
|
|
39
|
-
return computed<ResolvedNavbarItem[]>(() => {
|
|
40
|
-
const localePaths = Object.keys(site.value.locales)
|
|
41
|
-
// do not display language selection dropdown if there is only one language
|
|
42
|
-
if (localePaths.length < 2) {
|
|
43
|
-
return []
|
|
44
|
-
}
|
|
45
|
-
const currentPath = route.path
|
|
46
|
-
const currentFullPath = route.fullPath
|
|
47
|
-
|
|
48
|
-
const languageDropdown: ResolvedNavbarItem = {
|
|
49
|
-
text: `${themeLocale.value.selectLanguageText}`,
|
|
50
|
-
ariaLabel: `${
|
|
51
|
-
themeLocale.value.selectLanguageAriaLabel ??
|
|
52
|
-
themeLocale.value.selectLanguageText
|
|
53
|
-
}`,
|
|
54
|
-
children: localePaths.map((targetLocalePath) => {
|
|
55
|
-
// target locale config of this language link
|
|
56
|
-
const targetSiteLocale = site.value.locales?.[targetLocalePath] ?? {}
|
|
57
|
-
const targetThemeLocale = theme.value.locales?.[targetLocalePath] ?? {}
|
|
58
|
-
const targetLang = `${targetSiteLocale.lang}`
|
|
59
|
-
|
|
60
|
-
const text = targetThemeLocale.selectLanguageName ?? targetLang
|
|
61
|
-
|
|
62
|
-
// if the target language is current language
|
|
63
|
-
// stay at current link
|
|
64
|
-
if (targetLang === siteLocale.value.lang) {
|
|
65
|
-
return {
|
|
66
|
-
text,
|
|
67
|
-
activeMatch: /./,
|
|
68
|
-
link: route.hash ?? '#',
|
|
69
|
-
}
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
// if the target language is not current language
|
|
73
|
-
// try to link to the corresponding page of current page
|
|
74
|
-
// or fallback to homepage
|
|
75
|
-
const targetLocalePage = currentPath.replace(
|
|
76
|
-
routeLocale.value,
|
|
77
|
-
targetLocalePath,
|
|
78
|
-
)
|
|
79
|
-
|
|
80
|
-
return {
|
|
81
|
-
text,
|
|
82
|
-
// try to keep current hash and params across languages
|
|
83
|
-
link: routePaths.value.some((item) => item === targetLocalePage)
|
|
84
|
-
? currentFullPath.replace(currentPath, targetLocalePage)
|
|
85
|
-
: targetThemeLocale.home ?? targetLocalePath,
|
|
86
|
-
}
|
|
87
|
-
}),
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
return [languageDropdown]
|
|
91
|
-
})
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
/**
|
|
95
|
-
* Get navbar config of repository link
|
|
96
|
-
*/
|
|
97
|
-
const useNavbarRepo = (): ComputedRef<ResolvedNavbarItem[]> => {
|
|
98
|
-
const themeLocale = useThemeLocaleData()
|
|
99
|
-
|
|
100
|
-
const repo = computed(() => themeLocale.value.repo)
|
|
101
|
-
const repoType = computed(() =>
|
|
102
|
-
repo.value ? resolveRepoType(repo.value) : null,
|
|
103
|
-
)
|
|
104
|
-
|
|
105
|
-
const repoLink = computed(() => {
|
|
106
|
-
if (repo.value && !isLinkHttp(repo.value)) {
|
|
107
|
-
return `https://github.com/${repo.value}`
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
return repo.value
|
|
111
|
-
})
|
|
112
|
-
|
|
113
|
-
const repoLabel = computed(() => {
|
|
114
|
-
if (!repoLink.value) return null
|
|
115
|
-
if (themeLocale.value.repoLabel) return themeLocale.value.repoLabel
|
|
116
|
-
if (repoType.value === null) return 'Source'
|
|
117
|
-
return repoType.value
|
|
118
|
-
})
|
|
119
|
-
|
|
120
|
-
return computed(() => {
|
|
121
|
-
if (!repoLink.value || !repoLabel.value) {
|
|
122
|
-
return []
|
|
123
|
-
}
|
|
124
|
-
|
|
125
|
-
return [
|
|
126
|
-
{
|
|
127
|
-
text: repoLabel.value,
|
|
128
|
-
link: repoLink.value,
|
|
129
|
-
},
|
|
130
|
-
]
|
|
131
|
-
})
|
|
132
|
-
}
|
|
133
|
-
|
|
134
|
-
const resolveNavbarItem = (
|
|
135
|
-
item: NavbarItem | NavbarGroup | string,
|
|
136
|
-
): ResolvedNavbarItem => {
|
|
137
|
-
if (isString(item)) {
|
|
138
|
-
return getAutoLink(item)
|
|
139
|
-
}
|
|
140
|
-
if ((item as NavbarGroup).children) {
|
|
141
|
-
return {
|
|
142
|
-
...item,
|
|
143
|
-
children: (item as NavbarGroup).children.map((item) =>
|
|
144
|
-
resolveNavbarItem(item),
|
|
145
|
-
),
|
|
146
|
-
}
|
|
147
|
-
}
|
|
148
|
-
return item as ResolvedNavbarItem
|
|
149
|
-
}
|
|
150
|
-
|
|
151
|
-
const useNavbarConfig = (): ComputedRef<ResolvedNavbarItem[]> => {
|
|
152
|
-
const themeLocale = useThemeLocaleData()
|
|
153
|
-
|
|
154
|
-
return computed(() =>
|
|
155
|
-
(themeLocale.value.navbar || []).map((item) => resolveNavbarItem(item)),
|
|
156
|
-
)
|
|
157
|
-
}
|
|
158
|
-
|
|
159
|
-
const isMobile = ref(false)
|
|
160
|
-
const navbarConfig = useNavbarConfig()
|
|
161
|
-
const navbarSelectLanguage = useNavbarSelectLanguage()
|
|
162
|
-
const navbarRepo = useNavbarRepo()
|
|
163
|
-
const navbarLinks = computed(() => [
|
|
164
|
-
...navbarConfig.value,
|
|
165
|
-
...navbarSelectLanguage.value,
|
|
166
|
-
...navbarRepo.value,
|
|
167
|
-
])
|
|
168
|
-
|
|
169
|
-
useUpdateDeviceStatus(
|
|
170
|
-
DeviceType.MOBILE,
|
|
171
|
-
(mobileDesktopBreakpoint: number): void => {
|
|
172
|
-
// avoid overlapping of long title and long navbar links
|
|
173
|
-
if (window.innerWidth < mobileDesktopBreakpoint) {
|
|
174
|
-
isMobile.value = true
|
|
175
|
-
} else {
|
|
176
|
-
isMobile.value = false
|
|
177
|
-
}
|
|
178
|
-
},
|
|
179
|
-
)
|
|
180
|
-
|
|
181
|
-
const navbarLabel = computed(() => {
|
|
182
|
-
const themeLocale = useThemeLocaleData()
|
|
183
|
-
return themeLocale.value.navbarLabel ?? 'site navigation'
|
|
184
|
-
})
|
|
185
|
-
</script>
|
|
186
|
-
|
|
187
|
-
<template>
|
|
188
|
-
<nav v-if="navbarLinks.length" class="navbar-items" :aria-label="navbarLabel">
|
|
189
|
-
<div v-for="item in navbarLinks" :key="item.text" class="navbar-item">
|
|
190
|
-
<NavbarDropdown
|
|
191
|
-
v-if="'children' in item"
|
|
192
|
-
:item="item"
|
|
193
|
-
:class="isMobile ? 'mobile' : ''"
|
|
194
|
-
/>
|
|
195
|
-
<AutoLink v-else :config="item" />
|
|
196
|
-
</div>
|
|
197
|
-
</nav>
|
|
198
|
-
</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>
|
|
@@ -1,220 +0,0 @@
|
|
|
1
|
-
<script setup lang="ts">
|
|
2
|
-
import { computed } from 'vue'
|
|
3
|
-
import type { ComputedRef } from 'vue'
|
|
4
|
-
import { AutoLink, usePageData, usePageFrontmatter } from 'vuepress/client'
|
|
5
|
-
import type { AutoLinkConfig } from 'vuepress/client'
|
|
6
|
-
import type {
|
|
7
|
-
DefaultThemeNormalPageFrontmatter,
|
|
8
|
-
DefaultThemePageData,
|
|
9
|
-
} from '../../shared/index.js'
|
|
10
|
-
import { useThemeLocaleData } from '../composables/index.js'
|
|
11
|
-
import { resolveEditLink } from '../utils/index.js'
|
|
12
|
-
|
|
13
|
-
const useEditNavLink = (): ComputedRef<null | AutoLinkConfig> => {
|
|
14
|
-
const themeLocale = useThemeLocaleData()
|
|
15
|
-
const page = usePageData<DefaultThemePageData>()
|
|
16
|
-
const frontmatter = usePageFrontmatter<DefaultThemeNormalPageFrontmatter>()
|
|
17
|
-
|
|
18
|
-
return computed(() => {
|
|
19
|
-
const showEditLink =
|
|
20
|
-
frontmatter.value.editLink ?? themeLocale.value.editLink ?? true
|
|
21
|
-
if (!showEditLink) {
|
|
22
|
-
return null
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
const {
|
|
26
|
-
repo,
|
|
27
|
-
docsRepo = repo,
|
|
28
|
-
docsBranch = 'main',
|
|
29
|
-
docsDir = '',
|
|
30
|
-
editLinkText,
|
|
31
|
-
} = themeLocale.value
|
|
32
|
-
|
|
33
|
-
if (!docsRepo) return null
|
|
34
|
-
|
|
35
|
-
const editLink = resolveEditLink({
|
|
36
|
-
docsRepo,
|
|
37
|
-
docsBranch,
|
|
38
|
-
docsDir,
|
|
39
|
-
filePathRelative: page.value.filePathRelative,
|
|
40
|
-
editLinkPattern:
|
|
41
|
-
frontmatter.value.editLinkPattern ?? themeLocale.value.editLinkPattern,
|
|
42
|
-
})
|
|
43
|
-
|
|
44
|
-
if (!editLink) return null
|
|
45
|
-
|
|
46
|
-
return {
|
|
47
|
-
text: editLinkText ?? 'Edit this page',
|
|
48
|
-
link: editLink,
|
|
49
|
-
}
|
|
50
|
-
})
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
const useLastUpdated = (): ComputedRef<null | string> => {
|
|
54
|
-
const themeLocale = useThemeLocaleData()
|
|
55
|
-
const page = usePageData<DefaultThemePageData>()
|
|
56
|
-
const frontmatter = usePageFrontmatter<DefaultThemeNormalPageFrontmatter>()
|
|
57
|
-
|
|
58
|
-
return computed(() => {
|
|
59
|
-
const showLastUpdated =
|
|
60
|
-
frontmatter.value.lastUpdated ?? themeLocale.value.lastUpdated ?? true
|
|
61
|
-
|
|
62
|
-
if (!showLastUpdated) return null
|
|
63
|
-
|
|
64
|
-
if (!page.value.git?.updatedTime) return null
|
|
65
|
-
|
|
66
|
-
const updatedDate = new Date(page.value.git?.updatedTime)
|
|
67
|
-
|
|
68
|
-
return updatedDate.toLocaleString()
|
|
69
|
-
})
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
const useContributors = (): ComputedRef<
|
|
73
|
-
null | Required<DefaultThemePageData['git']>['contributors']
|
|
74
|
-
> => {
|
|
75
|
-
const themeLocale = useThemeLocaleData()
|
|
76
|
-
const page = usePageData<DefaultThemePageData>()
|
|
77
|
-
const frontmatter = usePageFrontmatter<DefaultThemeNormalPageFrontmatter>()
|
|
78
|
-
|
|
79
|
-
return computed(() => {
|
|
80
|
-
const showContributors =
|
|
81
|
-
frontmatter.value.contributors ?? themeLocale.value.contributors ?? true
|
|
82
|
-
|
|
83
|
-
if (!showContributors) return null
|
|
84
|
-
|
|
85
|
-
return page.value.git?.contributors ?? null
|
|
86
|
-
})
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
const themeLocale = useThemeLocaleData()
|
|
90
|
-
const editNavLink = useEditNavLink()
|
|
91
|
-
const lastUpdated = useLastUpdated()
|
|
92
|
-
const contributors = useContributors()
|
|
93
|
-
</script>
|
|
94
|
-
|
|
95
|
-
<template>
|
|
96
|
-
<footer class="vp-page-meta">
|
|
97
|
-
<div v-if="editNavLink" class="vp-meta-item edit-link">
|
|
98
|
-
<AutoLink class="label" :config="editNavLink">
|
|
99
|
-
<template #before>
|
|
100
|
-
<svg class="icon" viewBox="0 0 1024 1024">
|
|
101
|
-
<g fill="currentColor">
|
|
102
|
-
<path
|
|
103
|
-
d="M430.818 653.65a60.46 60.46 0 0 1-50.96-93.281l71.69-114.012 7.773-10.365L816.038 80.138A60.46 60.46 0 0 1 859.225 62a60.46 60.46 0 0 1 43.186 18.138l43.186 43.186a60.46 60.46 0 0 1 0 86.373L588.879 565.55l-8.637 8.637-117.466 68.234a60.46 60.46 0 0 1-31.958 11.229z"
|
|
104
|
-
/>
|
|
105
|
-
<path
|
|
106
|
-
d="M728.802 962H252.891A190.883 190.883 0 0 1 62.008 771.98V296.934a190.883 190.883 0 0 1 190.883-192.61h267.754a60.46 60.46 0 0 1 0 120.92H252.891a69.962 69.962 0 0 0-69.098 69.099V771.98a69.962 69.962 0 0 0 69.098 69.098h475.911A69.962 69.962 0 0 0 797.9 771.98V503.363a60.46 60.46 0 1 1 120.922 0V771.98A190.883 190.883 0 0 1 728.802 962z"
|
|
107
|
-
/>
|
|
108
|
-
</g>
|
|
109
|
-
</svg>
|
|
110
|
-
</template>
|
|
111
|
-
</AutoLink>
|
|
112
|
-
</div>
|
|
113
|
-
|
|
114
|
-
<div class="vp-meta-item git-info">
|
|
115
|
-
<div v-if="lastUpdated" class="vp-meta-item last-updated">
|
|
116
|
-
<span class="meta-item-label">{{ themeLocale.lastUpdatedText }}: </span>
|
|
117
|
-
<ClientOnly>
|
|
118
|
-
<span class="meta-item-info">{{ lastUpdated }}</span>
|
|
119
|
-
</ClientOnly>
|
|
120
|
-
</div>
|
|
121
|
-
|
|
122
|
-
<div
|
|
123
|
-
v-if="contributors && contributors.length"
|
|
124
|
-
class="vp-meta-item contributors"
|
|
125
|
-
>
|
|
126
|
-
<span class="meta-item-label"
|
|
127
|
-
>{{ themeLocale.contributorsText }}:
|
|
128
|
-
</span>
|
|
129
|
-
<span class="meta-item-info">
|
|
130
|
-
<template v-for="(contributor, index) in contributors" :key="index">
|
|
131
|
-
<span class="contributor" :title="`email: ${contributor.email}`">
|
|
132
|
-
{{ contributor.name }}
|
|
133
|
-
</span>
|
|
134
|
-
<template v-if="index !== contributors.length - 1">, </template>
|
|
135
|
-
</template>
|
|
136
|
-
</span>
|
|
137
|
-
</div>
|
|
138
|
-
</div>
|
|
139
|
-
</footer>
|
|
140
|
-
</template>
|
|
141
|
-
|
|
142
|
-
<style lang="scss">
|
|
143
|
-
@use '../styles/mixins';
|
|
144
|
-
@import '../styles/_variables';
|
|
145
|
-
|
|
146
|
-
.vp-page-meta {
|
|
147
|
-
@include mixins.content_wrapper;
|
|
148
|
-
|
|
149
|
-
display: flex;
|
|
150
|
-
flex-wrap: wrap;
|
|
151
|
-
justify-content: space-between;
|
|
152
|
-
|
|
153
|
-
overflow: auto;
|
|
154
|
-
|
|
155
|
-
padding-top: 0.75rem;
|
|
156
|
-
padding-bottom: 0.75rem;
|
|
157
|
-
|
|
158
|
-
@media print {
|
|
159
|
-
margin: 0 !important;
|
|
160
|
-
padding-inline: 0 !important;
|
|
161
|
-
}
|
|
162
|
-
|
|
163
|
-
@media (max-width: $MQMobile) {
|
|
164
|
-
display: block;
|
|
165
|
-
}
|
|
166
|
-
|
|
167
|
-
.vp-meta-item {
|
|
168
|
-
flex-grow: 1;
|
|
169
|
-
|
|
170
|
-
.vp-meta-label {
|
|
171
|
-
font-weight: 500;
|
|
172
|
-
|
|
173
|
-
&:not(a) {
|
|
174
|
-
color: var(--c-text-lighter);
|
|
175
|
-
}
|
|
176
|
-
}
|
|
177
|
-
|
|
178
|
-
.vp-meta-info {
|
|
179
|
-
color: var(--c-text-quote);
|
|
180
|
-
font-weight: 400;
|
|
181
|
-
}
|
|
182
|
-
}
|
|
183
|
-
|
|
184
|
-
.git-info {
|
|
185
|
-
text-align: end;
|
|
186
|
-
}
|
|
187
|
-
|
|
188
|
-
.edit-link {
|
|
189
|
-
margin-top: 0.25rem;
|
|
190
|
-
margin-bottom: 0.25rem;
|
|
191
|
-
margin-inline-end: 0.5rem;
|
|
192
|
-
font-size: 14px;
|
|
193
|
-
|
|
194
|
-
@media print {
|
|
195
|
-
display: none;
|
|
196
|
-
}
|
|
197
|
-
|
|
198
|
-
.icon {
|
|
199
|
-
position: relative;
|
|
200
|
-
bottom: -0.125em;
|
|
201
|
-
|
|
202
|
-
width: 1em;
|
|
203
|
-
height: 1em;
|
|
204
|
-
margin-inline-end: 0.25em;
|
|
205
|
-
}
|
|
206
|
-
}
|
|
207
|
-
|
|
208
|
-
.last-updated,
|
|
209
|
-
.contributors {
|
|
210
|
-
margin-top: 0.25rem;
|
|
211
|
-
margin-bottom: 0.25rem;
|
|
212
|
-
font-size: 14px;
|
|
213
|
-
|
|
214
|
-
@media (max-width: $MQMobile) {
|
|
215
|
-
font-size: 13px;
|
|
216
|
-
text-align: start;
|
|
217
|
-
}
|
|
218
|
-
}
|
|
219
|
-
}
|
|
220
|
-
</style>
|