@vuepress/theme-default 2.0.0-beta.9 → 2.0.0-rc.0
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/AutoLink.vue +119 -0
- package/lib/client/components/DropdownTransition.vue +15 -24
- package/lib/client/components/Home.vue +12 -130
- package/lib/client/components/HomeContent.vue +5 -0
- package/lib/client/components/HomeFeatures.vue +23 -0
- package/lib/client/components/HomeFooter.vue +17 -0
- package/lib/client/components/HomeHero.vue +98 -0
- package/lib/client/components/Navbar.vue +60 -95
- package/lib/client/components/NavbarBrand.vue +55 -0
- package/lib/client/components/NavbarDropdown.vue +126 -0
- package/lib/client/components/{NavbarLinks.vue → NavbarItems.vue} +73 -58
- package/lib/client/components/Page.vue +16 -15
- package/lib/client/components/PageMeta.vue +51 -66
- package/lib/client/components/PageNav.vue +47 -60
- package/lib/client/components/Sidebar.vue +12 -32
- package/lib/client/components/SidebarItem.vue +87 -0
- package/lib/client/components/SidebarItems.vue +57 -0
- package/lib/client/components/ToggleColorModeButton.vue +57 -0
- package/lib/client/components/ToggleSidebarButton.vue +21 -24
- package/lib/client/components/global/Badge.vue +24 -26
- package/lib/client/components/global/CodeGroup.d.ts +5 -4
- package/lib/client/components/global/CodeGroup.js +85 -17
- package/lib/client/components/global/CodeGroupItem.vue +23 -17
- package/lib/client/components/global/index.d.ts +4 -0
- package/lib/client/components/global/index.js +4 -0
- package/lib/client/composables/index.d.ts +7 -5
- package/lib/client/composables/index.js +7 -5
- package/lib/client/composables/useDarkMode.d.ts +12 -0
- package/lib/client/composables/useDarkMode.js +57 -0
- package/lib/client/composables/useNavLink.d.ts +6 -1
- package/lib/client/composables/useNavLink.js +5 -2
- package/lib/client/composables/useResolveRouteWithRedirect.js +2 -2
- package/lib/client/composables/useScrollPromise.js +1 -1
- package/lib/client/composables/useSidebarItems.d.ts +13 -8
- package/lib/client/composables/useSidebarItems.js +42 -38
- package/lib/client/composables/useThemeData.d.ts +2 -2
- package/lib/client/composables/useThemeData.js +1 -1
- package/lib/client/composables/useUpdateDeviceStatus.d.ts +7 -0
- package/lib/client/composables/useUpdateDeviceStatus.js +25 -0
- package/lib/client/config.d.ts +3 -0
- package/lib/client/config.js +44 -0
- package/lib/client/index.d.ts +3 -4
- package/lib/client/index.js +3 -2
- package/lib/client/layouts/Layout.vue +133 -136
- package/lib/client/layouts/NotFound.vue +27 -0
- package/lib/client/shim.d.ts +5 -0
- package/lib/client/styles/{_wrapper.scss → _mixins.scss} +7 -2
- package/lib/client/styles/_variables.module.scss +5 -0
- package/lib/client/styles/_variables.scss +0 -34
- package/lib/client/styles/arrow.scss +4 -6
- package/lib/client/styles/badge.scss +14 -11
- package/lib/client/styles/code-group.scss +9 -2
- package/lib/client/styles/code.scss +33 -46
- package/lib/client/styles/custom-container.scss +82 -18
- package/lib/client/styles/home.scss +32 -24
- package/lib/client/styles/index.scss +4 -4
- package/lib/client/styles/layout.scss +82 -73
- package/lib/client/styles/{dropdown.scss → navbar-dropdown.scss} +36 -50
- package/lib/client/styles/navbar.scss +106 -50
- package/lib/client/styles/normalize.scss +200 -0
- package/lib/client/styles/page.scss +24 -8
- package/lib/client/styles/sidebar.scss +69 -87
- package/lib/client/styles/transitions.scss +13 -4
- package/lib/client/styles/vars-dark.scss +68 -0
- package/lib/client/styles/vars.scss +149 -0
- package/lib/client/utils/index.d.ts +3 -2
- package/lib/client/utils/index.js +3 -2
- package/lib/client/utils/isActiveSidebarItem.d.ts +3 -0
- package/lib/client/utils/isActiveSidebarItem.js +20 -0
- package/lib/client/utils/resolveEditLink.d.ts +2 -2
- package/lib/client/utils/resolveEditLink.js +15 -9
- package/lib/client/utils/resolveRepoType.d.ts +1 -1
- package/lib/client/utils/resolveRepoType.js +3 -1
- package/lib/node/defaultTheme.d.ts +4 -4
- package/lib/node/defaultTheme.js +111 -48
- package/lib/node/index.d.ts +4 -4
- package/lib/node/index.js +5 -17
- package/lib/node/utils/assignDefaultLocaleOptions.d.ts +4 -2
- package/lib/node/utils/assignDefaultLocaleOptions.js +13 -13
- package/lib/node/utils/index.d.ts +2 -5
- package/lib/node/utils/index.js +2 -17
- package/lib/node/utils/resolveContainerPluginOptions.d.ts +2 -20
- package/lib/node/utils/resolveContainerPluginOptions.js +4 -66
- package/lib/shared/index.d.ts +3 -3
- package/lib/shared/index.js +3 -15
- package/lib/shared/nav.d.ts +16 -18
- package/lib/shared/nav.js +1 -2
- package/lib/shared/options.d.ts +51 -6
- package/lib/shared/options.js +1 -2
- package/lib/shared/page.d.ts +15 -6
- package/lib/shared/page.js +1 -2
- package/package.json +49 -29
- package/templates/build.html +34 -0
- package/CHANGELOG.md +0 -419
- package/lib/client/clientAppEnhance.d.ts +0 -3
- package/lib/client/clientAppEnhance.js +0 -28
- package/lib/client/clientAppSetup.d.ts +0 -2
- package/lib/client/clientAppSetup.js +0 -11
- package/lib/client/components/DropdownLink.vue +0 -141
- package/lib/client/components/NavLink.vue +0 -115
- package/lib/client/components/SidebarChild.d.ts +0 -6
- package/lib/client/components/SidebarChild.js +0 -91
- package/lib/client/components/global/OutboundLink.vue +0 -30
- package/lib/client/layouts/404.vue +0 -38
- package/lib/client/styles/_normalize.scss +0 -148
- package/lib/client/styles/plugins.scss +0 -18
- package/lib/client/styles/sr-only.scss +0 -12
- package/lib/node/utils/resolveActiveHeaderLinksPluginOptions.d.ts +0 -6
- package/lib/node/utils/resolveActiveHeaderLinksPluginOptions.js +0 -16
- package/lib/node/utils/resolveGitPluginOptions.d.ts +0 -6
- package/lib/node/utils/resolveGitPluginOptions.js +0 -22
- package/lib/node/utils/resolveMediumZoomPluginOptions.d.ts +0 -6
- package/lib/node/utils/resolveMediumZoomPluginOptions.js +0 -17
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
/* eslint-disable import/first, import/no-duplicates, import/order */
|
|
3
|
+
import { defineComponent } from 'vue'
|
|
4
|
+
|
|
5
|
+
export default defineComponent({
|
|
6
|
+
inheritAttrs: false,
|
|
7
|
+
})
|
|
8
|
+
/* eslint-enable import/order */
|
|
9
|
+
</script>
|
|
10
|
+
|
|
11
|
+
<script setup lang="ts">
|
|
12
|
+
import { useSiteData } from '@vuepress/client'
|
|
13
|
+
import { isLinkHttp, isLinkWithProtocol } from '@vuepress/shared'
|
|
14
|
+
import { computed, toRefs } from 'vue'
|
|
15
|
+
import type { PropType } from 'vue'
|
|
16
|
+
import { useRoute } from 'vue-router'
|
|
17
|
+
import type { NavLink } from '../../shared/index.js'
|
|
18
|
+
|
|
19
|
+
const props = defineProps({
|
|
20
|
+
item: {
|
|
21
|
+
type: Object as PropType<NavLink>,
|
|
22
|
+
required: true,
|
|
23
|
+
},
|
|
24
|
+
})
|
|
25
|
+
|
|
26
|
+
defineSlots<{
|
|
27
|
+
before?: (props: Record<never, never>) => any
|
|
28
|
+
after?: (props: Record<never, never>) => any
|
|
29
|
+
}>()
|
|
30
|
+
|
|
31
|
+
const route = useRoute()
|
|
32
|
+
const site = useSiteData()
|
|
33
|
+
const { item } = toRefs(props)
|
|
34
|
+
|
|
35
|
+
// if the link has http protocol
|
|
36
|
+
const hasHttpProtocol = computed(() => isLinkHttp(item.value.link))
|
|
37
|
+
// if the link has non-http protocol
|
|
38
|
+
const hasNonHttpProtocol = computed(
|
|
39
|
+
() => !hasHttpProtocol.value && isLinkWithProtocol(item.value.link),
|
|
40
|
+
)
|
|
41
|
+
// resolve the `target` attr
|
|
42
|
+
const linkTarget = computed(() => {
|
|
43
|
+
if (hasNonHttpProtocol.value) return undefined
|
|
44
|
+
if (item.value.target) return item.value.target
|
|
45
|
+
if (hasHttpProtocol.value) return '_blank'
|
|
46
|
+
return undefined
|
|
47
|
+
})
|
|
48
|
+
// if the `target` attr is '_blank'
|
|
49
|
+
const isBlankTarget = computed(() => linkTarget.value === '_blank')
|
|
50
|
+
// is `<RouterLink>` or not
|
|
51
|
+
const isRouterLink = computed(
|
|
52
|
+
() =>
|
|
53
|
+
!hasHttpProtocol.value && !hasNonHttpProtocol.value && !isBlankTarget.value,
|
|
54
|
+
)
|
|
55
|
+
// resolve the `rel` attr
|
|
56
|
+
const linkRel = computed(() => {
|
|
57
|
+
if (hasNonHttpProtocol.value) return undefined
|
|
58
|
+
if (item.value.rel) return item.value.rel
|
|
59
|
+
if (isBlankTarget.value) return 'noopener noreferrer'
|
|
60
|
+
return undefined
|
|
61
|
+
})
|
|
62
|
+
// resolve the `aria-label` attr
|
|
63
|
+
const linkAriaLabel = computed(() => item.value.ariaLabel || item.value.text)
|
|
64
|
+
|
|
65
|
+
// should be active when current route is a subpath of this link
|
|
66
|
+
const shouldBeActiveInSubpath = computed(() => {
|
|
67
|
+
const localeKeys = Object.keys(site.value.locales)
|
|
68
|
+
if (localeKeys.length) {
|
|
69
|
+
return !localeKeys.some((key) => key === item.value.link)
|
|
70
|
+
}
|
|
71
|
+
return item.value.link !== '/'
|
|
72
|
+
})
|
|
73
|
+
// if this link is active in subpath
|
|
74
|
+
const isActiveInSubpath = computed(() => {
|
|
75
|
+
if (!shouldBeActiveInSubpath.value) {
|
|
76
|
+
return false
|
|
77
|
+
}
|
|
78
|
+
return route.path.startsWith(item.value.link)
|
|
79
|
+
})
|
|
80
|
+
|
|
81
|
+
// if this link is active
|
|
82
|
+
const isActive = computed(() => {
|
|
83
|
+
if (!isRouterLink.value) {
|
|
84
|
+
return false
|
|
85
|
+
}
|
|
86
|
+
if (item.value.activeMatch) {
|
|
87
|
+
return new RegExp(item.value.activeMatch).test(route.path)
|
|
88
|
+
}
|
|
89
|
+
return isActiveInSubpath.value
|
|
90
|
+
})
|
|
91
|
+
</script>
|
|
92
|
+
|
|
93
|
+
<template>
|
|
94
|
+
<RouterLink
|
|
95
|
+
v-if="isRouterLink"
|
|
96
|
+
:class="{ 'router-link-active': isActive }"
|
|
97
|
+
:to="item.link"
|
|
98
|
+
:aria-label="linkAriaLabel"
|
|
99
|
+
v-bind="$attrs"
|
|
100
|
+
>
|
|
101
|
+
<slot name="before" />
|
|
102
|
+
{{ item.text }}
|
|
103
|
+
<slot name="after" />
|
|
104
|
+
</RouterLink>
|
|
105
|
+
<a
|
|
106
|
+
v-else
|
|
107
|
+
class="external-link"
|
|
108
|
+
:href="item.link"
|
|
109
|
+
:rel="linkRel"
|
|
110
|
+
:target="linkTarget"
|
|
111
|
+
:aria-label="linkAriaLabel"
|
|
112
|
+
v-bind="$attrs"
|
|
113
|
+
>
|
|
114
|
+
<slot name="before" />
|
|
115
|
+
{{ item.text }}
|
|
116
|
+
<AutoLinkExternalIcon v-if="isBlankTarget" />
|
|
117
|
+
<slot name="after" />
|
|
118
|
+
</a>
|
|
119
|
+
</template>
|
|
@@ -1,3 +1,18 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
defineSlots<{
|
|
3
|
+
default?: (props: Record<never, never>) => any
|
|
4
|
+
}>()
|
|
5
|
+
|
|
6
|
+
const setHeight = (items): void => {
|
|
7
|
+
// explicitly set height so that it can be transitioned
|
|
8
|
+
items.style.height = items.scrollHeight + 'px'
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
const unsetHeight = (items): void => {
|
|
12
|
+
items.style.height = ''
|
|
13
|
+
}
|
|
14
|
+
</script>
|
|
15
|
+
|
|
1
16
|
<template>
|
|
2
17
|
<Transition
|
|
3
18
|
name="dropdown"
|
|
@@ -8,27 +23,3 @@
|
|
|
8
23
|
<slot />
|
|
9
24
|
</Transition>
|
|
10
25
|
</template>
|
|
11
|
-
|
|
12
|
-
<script lang="ts">
|
|
13
|
-
import { defineComponent } from 'vue'
|
|
14
|
-
|
|
15
|
-
export default defineComponent({
|
|
16
|
-
name: 'DropdownTransition',
|
|
17
|
-
|
|
18
|
-
setup() {
|
|
19
|
-
const setHeight = (items): void => {
|
|
20
|
-
// explicitly set height so that it can be transitioned
|
|
21
|
-
items.style.height = items.scrollHeight + 'px'
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
const unsetHeight = (items): void => {
|
|
25
|
-
items.style.height = ''
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
return {
|
|
29
|
-
setHeight,
|
|
30
|
-
unsetHeight,
|
|
31
|
-
}
|
|
32
|
-
},
|
|
33
|
-
})
|
|
34
|
-
</script>
|
|
@@ -1,133 +1,15 @@
|
|
|
1
|
-
<
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
{{ heroText }}
|
|
8
|
-
</h1>
|
|
9
|
-
|
|
10
|
-
<p v-if="tagline" class="description">
|
|
11
|
-
{{ tagline }}
|
|
12
|
-
</p>
|
|
13
|
-
|
|
14
|
-
<p v-if="actions.length" class="actions">
|
|
15
|
-
<NavLink
|
|
16
|
-
v-for="action in actions"
|
|
17
|
-
:key="action.text"
|
|
18
|
-
class="action-button"
|
|
19
|
-
:class="[action.type]"
|
|
20
|
-
:item="action"
|
|
21
|
-
/>
|
|
22
|
-
</p>
|
|
23
|
-
</header>
|
|
24
|
-
|
|
25
|
-
<div v-if="features.length" class="features">
|
|
26
|
-
<div v-for="feature in features" :key="feature.title" class="feature">
|
|
27
|
-
<h2>{{ feature.title }}</h2>
|
|
28
|
-
<p>{{ feature.details }}</p>
|
|
29
|
-
</div>
|
|
30
|
-
</div>
|
|
31
|
-
|
|
32
|
-
<div class="theme-default-content custom">
|
|
33
|
-
<Content />
|
|
34
|
-
</div>
|
|
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>
|
|
35
7
|
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
8
|
+
<template>
|
|
9
|
+
<main class="home">
|
|
10
|
+
<HomeHero />
|
|
11
|
+
<HomeFeatures />
|
|
12
|
+
<HomeContent />
|
|
13
|
+
<HomeFooter />
|
|
41
14
|
</main>
|
|
42
15
|
</template>
|
|
43
|
-
|
|
44
|
-
<script lang="ts">
|
|
45
|
-
import { computed, defineComponent } from 'vue'
|
|
46
|
-
import {
|
|
47
|
-
usePageFrontmatter,
|
|
48
|
-
useSiteLocaleData,
|
|
49
|
-
withBase,
|
|
50
|
-
} from '@vuepress/client'
|
|
51
|
-
import { isArray } from '@vuepress/shared'
|
|
52
|
-
import type { DefaultThemeHomePageFrontmatter } from '../../shared'
|
|
53
|
-
import NavLink from './NavLink.vue'
|
|
54
|
-
|
|
55
|
-
export default defineComponent({
|
|
56
|
-
name: 'Home',
|
|
57
|
-
|
|
58
|
-
components: {
|
|
59
|
-
NavLink,
|
|
60
|
-
},
|
|
61
|
-
|
|
62
|
-
setup() {
|
|
63
|
-
const frontmatter = usePageFrontmatter<DefaultThemeHomePageFrontmatter>()
|
|
64
|
-
const siteLocale = useSiteLocaleData()
|
|
65
|
-
|
|
66
|
-
const heroImage = computed(() => {
|
|
67
|
-
if (!frontmatter.value.heroImage) {
|
|
68
|
-
return null
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
return withBase(frontmatter.value.heroImage)
|
|
72
|
-
})
|
|
73
|
-
|
|
74
|
-
const heroText = computed(() => {
|
|
75
|
-
if (frontmatter.value.heroText === null) {
|
|
76
|
-
return null
|
|
77
|
-
}
|
|
78
|
-
return frontmatter.value.heroText || siteLocale.value.title || 'Hello'
|
|
79
|
-
})
|
|
80
|
-
|
|
81
|
-
const heroAlt = computed(
|
|
82
|
-
() => frontmatter.value.heroAlt || heroText.value || 'hero'
|
|
83
|
-
)
|
|
84
|
-
|
|
85
|
-
const tagline = computed(() => {
|
|
86
|
-
if (frontmatter.value.tagline === null) {
|
|
87
|
-
return null
|
|
88
|
-
}
|
|
89
|
-
return (
|
|
90
|
-
frontmatter.value.tagline ||
|
|
91
|
-
siteLocale.value.description ||
|
|
92
|
-
'Welcome to your VuePress site'
|
|
93
|
-
)
|
|
94
|
-
})
|
|
95
|
-
|
|
96
|
-
const actions = computed(() => {
|
|
97
|
-
if (!isArray(frontmatter.value.actions)) {
|
|
98
|
-
return []
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
return frontmatter.value.actions.map(
|
|
102
|
-
({ text, link, type = 'primary' }) => ({
|
|
103
|
-
text,
|
|
104
|
-
link,
|
|
105
|
-
type,
|
|
106
|
-
})
|
|
107
|
-
)
|
|
108
|
-
})
|
|
109
|
-
|
|
110
|
-
const features = computed(() => {
|
|
111
|
-
if (isArray(frontmatter.value.features)) {
|
|
112
|
-
return frontmatter.value.features
|
|
113
|
-
}
|
|
114
|
-
return []
|
|
115
|
-
})
|
|
116
|
-
|
|
117
|
-
const footer = computed(() => frontmatter.value.footer)
|
|
118
|
-
|
|
119
|
-
const footerHtml = computed(() => frontmatter.value.footerHtml)
|
|
120
|
-
|
|
121
|
-
return {
|
|
122
|
-
heroImage,
|
|
123
|
-
heroAlt,
|
|
124
|
-
heroText,
|
|
125
|
-
tagline,
|
|
126
|
-
actions,
|
|
127
|
-
features,
|
|
128
|
-
footer,
|
|
129
|
-
footerHtml,
|
|
130
|
-
}
|
|
131
|
-
},
|
|
132
|
-
})
|
|
133
|
-
</script>
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
import { usePageFrontmatter } from '@vuepress/client'
|
|
3
|
+
import { isArray } from '@vuepress/shared'
|
|
4
|
+
import { computed } from 'vue'
|
|
5
|
+
import type { DefaultThemeHomePageFrontmatter } from '../../shared/index.js'
|
|
6
|
+
|
|
7
|
+
const frontmatter = usePageFrontmatter<DefaultThemeHomePageFrontmatter>()
|
|
8
|
+
const features = computed(() => {
|
|
9
|
+
if (isArray(frontmatter.value.features)) {
|
|
10
|
+
return frontmatter.value.features
|
|
11
|
+
}
|
|
12
|
+
return []
|
|
13
|
+
})
|
|
14
|
+
</script>
|
|
15
|
+
|
|
16
|
+
<template>
|
|
17
|
+
<div v-if="features.length" class="features">
|
|
18
|
+
<div v-for="feature in features" :key="feature.title" class="feature">
|
|
19
|
+
<h2>{{ feature.title }}</h2>
|
|
20
|
+
<p>{{ feature.details }}</p>
|
|
21
|
+
</div>
|
|
22
|
+
</div>
|
|
23
|
+
</template>
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
import { usePageFrontmatter } from '@vuepress/client'
|
|
3
|
+
import { computed } from 'vue'
|
|
4
|
+
import type { DefaultThemeHomePageFrontmatter } from '../../shared/index.js'
|
|
5
|
+
|
|
6
|
+
const frontmatter = usePageFrontmatter<DefaultThemeHomePageFrontmatter>()
|
|
7
|
+
const footer = computed(() => frontmatter.value.footer)
|
|
8
|
+
const footerHtml = computed(() => frontmatter.value.footerHtml)
|
|
9
|
+
</script>
|
|
10
|
+
|
|
11
|
+
<template>
|
|
12
|
+
<template v-if="footer">
|
|
13
|
+
<!-- eslint-disable-next-line vue/no-v-html -->
|
|
14
|
+
<div v-if="footerHtml" class="footer" v-html="footer" />
|
|
15
|
+
<div v-else class="footer" v-text="footer" />
|
|
16
|
+
</template>
|
|
17
|
+
</template>
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
import AutoLink from '@theme/AutoLink.vue'
|
|
3
|
+
import {
|
|
4
|
+
ClientOnly,
|
|
5
|
+
usePageFrontmatter,
|
|
6
|
+
useSiteLocaleData,
|
|
7
|
+
withBase,
|
|
8
|
+
} from '@vuepress/client'
|
|
9
|
+
import { isArray } from '@vuepress/shared'
|
|
10
|
+
import type { FunctionalComponent } from 'vue'
|
|
11
|
+
import { computed, h } from 'vue'
|
|
12
|
+
import type { DefaultThemeHomePageFrontmatter } from '../../shared/index.js'
|
|
13
|
+
import { useDarkMode } from '../composables/index.js'
|
|
14
|
+
|
|
15
|
+
const frontmatter = usePageFrontmatter<DefaultThemeHomePageFrontmatter>()
|
|
16
|
+
const siteLocale = useSiteLocaleData()
|
|
17
|
+
const isDarkMode = useDarkMode()
|
|
18
|
+
|
|
19
|
+
const heroImage = computed(() => {
|
|
20
|
+
if (isDarkMode.value && frontmatter.value.heroImageDark !== undefined) {
|
|
21
|
+
return frontmatter.value.heroImageDark
|
|
22
|
+
}
|
|
23
|
+
return frontmatter.value.heroImage
|
|
24
|
+
})
|
|
25
|
+
const heroAlt = computed(
|
|
26
|
+
() => frontmatter.value.heroAlt || heroText.value || 'hero',
|
|
27
|
+
)
|
|
28
|
+
const heroHeight = computed(() => frontmatter.value.heroHeight || 280)
|
|
29
|
+
|
|
30
|
+
const heroText = computed(() => {
|
|
31
|
+
if (frontmatter.value.heroText === null) {
|
|
32
|
+
return null
|
|
33
|
+
}
|
|
34
|
+
return frontmatter.value.heroText || siteLocale.value.title || 'Hello'
|
|
35
|
+
})
|
|
36
|
+
|
|
37
|
+
const tagline = computed(() => {
|
|
38
|
+
if (frontmatter.value.tagline === null) {
|
|
39
|
+
return null
|
|
40
|
+
}
|
|
41
|
+
return (
|
|
42
|
+
frontmatter.value.tagline ||
|
|
43
|
+
siteLocale.value.description ||
|
|
44
|
+
'Welcome to your VuePress site'
|
|
45
|
+
)
|
|
46
|
+
})
|
|
47
|
+
|
|
48
|
+
const actions = computed(() => {
|
|
49
|
+
if (!isArray(frontmatter.value.actions)) {
|
|
50
|
+
return []
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
return frontmatter.value.actions.map(({ text, link, type = 'primary' }) => ({
|
|
54
|
+
text,
|
|
55
|
+
link,
|
|
56
|
+
type,
|
|
57
|
+
}))
|
|
58
|
+
})
|
|
59
|
+
|
|
60
|
+
const HomeHeroImage: FunctionalComponent = () => {
|
|
61
|
+
if (!heroImage.value) return null
|
|
62
|
+
const img = h('img', {
|
|
63
|
+
src: withBase(heroImage.value),
|
|
64
|
+
alt: heroAlt.value,
|
|
65
|
+
height: heroHeight.value,
|
|
66
|
+
})
|
|
67
|
+
if (frontmatter.value.heroImageDark === undefined) {
|
|
68
|
+
return img
|
|
69
|
+
}
|
|
70
|
+
// wrap hero image with <ClientOnly> to avoid ssr-mismatch
|
|
71
|
+
// when using a different hero image in dark mode
|
|
72
|
+
return h(ClientOnly, () => img)
|
|
73
|
+
}
|
|
74
|
+
</script>
|
|
75
|
+
|
|
76
|
+
<template>
|
|
77
|
+
<header class="hero">
|
|
78
|
+
<HomeHeroImage />
|
|
79
|
+
|
|
80
|
+
<h1 v-if="heroText" id="main-title">
|
|
81
|
+
{{ heroText }}
|
|
82
|
+
</h1>
|
|
83
|
+
|
|
84
|
+
<p v-if="tagline" class="description">
|
|
85
|
+
{{ tagline }}
|
|
86
|
+
</p>
|
|
87
|
+
|
|
88
|
+
<p v-if="actions.length" class="actions">
|
|
89
|
+
<AutoLink
|
|
90
|
+
v-for="action in actions"
|
|
91
|
+
:key="action.text"
|
|
92
|
+
class="action-button"
|
|
93
|
+
:class="[action.type]"
|
|
94
|
+
:item="action"
|
|
95
|
+
/>
|
|
96
|
+
</p>
|
|
97
|
+
</header>
|
|
98
|
+
</template>
|
|
@@ -1,107 +1,54 @@
|
|
|
1
|
-
<
|
|
2
|
-
|
|
3
|
-
|
|
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'
|
|
4
12
|
|
|
5
|
-
|
|
6
|
-
<RouterLink :to="siteBrandLink">
|
|
7
|
-
<img
|
|
8
|
-
v-if="siteBrandLogo"
|
|
9
|
-
class="logo"
|
|
10
|
-
:src="withBase(siteBrandLogo)"
|
|
11
|
-
:alt="siteBrandTitle"
|
|
12
|
-
/>
|
|
13
|
+
defineEmits<(e: 'toggle-sidebar') => void>()
|
|
13
14
|
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
>
|
|
19
|
-
{{ siteBrandTitle }}
|
|
20
|
-
</span>
|
|
21
|
-
</RouterLink>
|
|
22
|
-
</span>
|
|
15
|
+
defineSlots<{
|
|
16
|
+
before?: (props: Record<never, never>) => any
|
|
17
|
+
after?: (props: Record<never, never>) => any
|
|
18
|
+
}>()
|
|
23
19
|
|
|
24
|
-
|
|
25
|
-
<slot name="before" />
|
|
26
|
-
<NavbarLinks class="can-hide" />
|
|
27
|
-
<slot name="after" />
|
|
28
|
-
<Docsearch />
|
|
29
|
-
</div>
|
|
30
|
-
</header>
|
|
31
|
-
</template>
|
|
32
|
-
|
|
33
|
-
<script lang="ts">
|
|
34
|
-
import { computed, defineComponent, onMounted, ref } from 'vue'
|
|
35
|
-
import { useRouteLocale, useSiteLocaleData, withBase } from '@vuepress/client'
|
|
36
|
-
import { useThemeLocaleData } from '../composables'
|
|
37
|
-
import NavbarLinks from './NavbarLinks.vue'
|
|
38
|
-
import ToggleSidebarButton from './ToggleSidebarButton.vue'
|
|
20
|
+
const themeLocale = useThemeLocaleData()
|
|
39
21
|
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
components: {
|
|
44
|
-
NavbarLinks,
|
|
45
|
-
ToggleSidebarButton,
|
|
46
|
-
},
|
|
22
|
+
const navbar = ref<HTMLElement | null>(null)
|
|
23
|
+
const navbarBrand = ref<HTMLElement | null>(null)
|
|
47
24
|
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
const siteBrandLink = computed(
|
|
58
|
-
() => themeLocale.value.home || routeLocale.value
|
|
59
|
-
)
|
|
60
|
-
const siteBrandLogo = computed(() => themeLocale.value.logo)
|
|
61
|
-
const siteBrandTitle = computed(() => siteLocale.value.title)
|
|
62
|
-
const linksWrapperMaxWidth = ref(0)
|
|
63
|
-
const linksWrapperStyle = computed(() => {
|
|
64
|
-
if (!linksWrapperMaxWidth.value) {
|
|
65
|
-
return {}
|
|
66
|
-
}
|
|
67
|
-
return {
|
|
68
|
-
maxWidth: linksWrapperMaxWidth.value + 'px',
|
|
69
|
-
}
|
|
70
|
-
})
|
|
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
|
+
})
|
|
71
34
|
|
|
35
|
+
useUpdateDeviceStatus(
|
|
36
|
+
DeviceType.MOBILE,
|
|
37
|
+
(mobileDesktopBreakpoint: number): void => {
|
|
72
38
|
// avoid overlapping of long title and long navbar links
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
} else {
|
|
84
|
-
linksWrapperMaxWidth.value =
|
|
85
|
-
navbar.value!.offsetWidth -
|
|
86
|
-
navbarHorizontalPadding -
|
|
87
|
-
(siteBrand.value?.offsetWidth || 0)
|
|
88
|
-
}
|
|
89
|
-
}
|
|
90
|
-
handleLinksWrapWidth()
|
|
91
|
-
window.addEventListener('resize', handleLinksWrapWidth, false)
|
|
92
|
-
})
|
|
93
|
-
|
|
94
|
-
return {
|
|
95
|
-
navbar,
|
|
96
|
-
siteBrand,
|
|
97
|
-
siteBrandLink,
|
|
98
|
-
siteBrandLogo,
|
|
99
|
-
siteBrandTitle,
|
|
100
|
-
linksWrapperStyle,
|
|
101
|
-
withBase,
|
|
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)
|
|
102
49
|
}
|
|
103
50
|
},
|
|
104
|
-
|
|
51
|
+
)
|
|
105
52
|
|
|
106
53
|
function getCssValue(el: HTMLElement | null, property: string): number {
|
|
107
54
|
// NOTE: Known bug, will return 'auto' if style value is 'auto'
|
|
@@ -112,3 +59,21 @@ function getCssValue(el: HTMLElement | null, property: string): number {
|
|
|
112
59
|
return Number.isNaN(num) ? 0 : num
|
|
113
60
|
}
|
|
114
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>
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
import {
|
|
3
|
+
ClientOnly,
|
|
4
|
+
useRouteLocale,
|
|
5
|
+
useSiteLocaleData,
|
|
6
|
+
withBase,
|
|
7
|
+
} from '@vuepress/client'
|
|
8
|
+
import { computed, h } from 'vue'
|
|
9
|
+
import type { FunctionalComponent } from 'vue'
|
|
10
|
+
import { useDarkMode, useThemeLocaleData } from '../composables/index.js'
|
|
11
|
+
|
|
12
|
+
const routeLocale = useRouteLocale()
|
|
13
|
+
const siteLocale = useSiteLocaleData()
|
|
14
|
+
const themeLocale = useThemeLocaleData()
|
|
15
|
+
const isDarkMode = useDarkMode()
|
|
16
|
+
|
|
17
|
+
const navbarBrandLink = computed(
|
|
18
|
+
() => themeLocale.value.home || routeLocale.value,
|
|
19
|
+
)
|
|
20
|
+
const navbarBrandTitle = computed(() => siteLocale.value.title)
|
|
21
|
+
const navbarBrandLogo = computed(() => {
|
|
22
|
+
if (isDarkMode.value && themeLocale.value.logoDark !== undefined) {
|
|
23
|
+
return themeLocale.value.logoDark
|
|
24
|
+
}
|
|
25
|
+
return themeLocale.value.logo
|
|
26
|
+
})
|
|
27
|
+
const NavbarBrandLogo: FunctionalComponent = () => {
|
|
28
|
+
if (!navbarBrandLogo.value) return null
|
|
29
|
+
const img = h('img', {
|
|
30
|
+
class: 'logo',
|
|
31
|
+
src: withBase(navbarBrandLogo.value),
|
|
32
|
+
alt: navbarBrandTitle.value,
|
|
33
|
+
})
|
|
34
|
+
if (themeLocale.value.logoDark === undefined) {
|
|
35
|
+
return img
|
|
36
|
+
}
|
|
37
|
+
// wrap brand logo with <ClientOnly> to avoid ssr-mismatch
|
|
38
|
+
// when using a different brand logo in dark mode
|
|
39
|
+
return h(ClientOnly, () => img)
|
|
40
|
+
}
|
|
41
|
+
</script>
|
|
42
|
+
|
|
43
|
+
<template>
|
|
44
|
+
<RouterLink :to="navbarBrandLink">
|
|
45
|
+
<NavbarBrandLogo />
|
|
46
|
+
|
|
47
|
+
<span
|
|
48
|
+
v-if="navbarBrandTitle"
|
|
49
|
+
class="site-name"
|
|
50
|
+
:class="{ 'can-hide': navbarBrandLogo }"
|
|
51
|
+
>
|
|
52
|
+
{{ navbarBrandTitle }}
|
|
53
|
+
</span>
|
|
54
|
+
</RouterLink>
|
|
55
|
+
</template>
|