@vuepress/theme-default 2.0.0-rc.78 → 2.0.0-rc.79
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/VPHomeFeatures.vue +2 -3
- package/lib/client/components/VPHomeFooter.vue +0 -2
- package/lib/client/components/VPHomeHero.vue +3 -8
- package/lib/client/components/VPNavbar.vue +2 -2
- package/lib/client/components/VPNavbarBrand.vue +3 -11
- package/lib/client/components/VPNavbarItems.vue +2 -3
- package/lib/client/components/VPPageMeta.vue +2 -2
- package/lib/client/components/VPPageNav.vue +12 -5
- package/lib/client/components/VPSidebarItems.vue +0 -1
- package/lib/client/components/VPToggleColorModeButton.vue +2 -2
- package/lib/client/components/VPToggleSidebarButton.vue +2 -2
- package/lib/client/composables/index.d.ts +1 -1
- package/lib/client/composables/index.js +1 -1
- package/lib/client/composables/useContributors.js +2 -5
- package/lib/client/composables/useDarkMode.js +2 -2
- package/lib/client/composables/useData.d.ts +13 -0
- package/lib/client/composables/useData.js +15 -0
- package/lib/client/composables/useEditLink.js +2 -5
- package/lib/client/composables/useHeaders.js +2 -5
- package/lib/client/composables/useLastUpdated.js +2 -5
- package/lib/client/composables/useNavbarConfig.js +2 -2
- package/lib/client/composables/useNavbarRepo.js +2 -2
- package/lib/client/composables/useNavbarSelectLanguage.js +3 -7
- package/lib/client/composables/useRelatedLinks.js +3 -4
- package/lib/client/composables/useSidebarItems.js +3 -6
- package/lib/client/layouts/Layout.vue +5 -7
- package/lib/client/layouts/NotFound.vue +10 -8
- package/package.json +21 -21
- package/lib/client/composables/useThemeData.d.ts +0 -4
- package/lib/client/composables/useThemeData.js +0 -3
|
@@ -1,14 +1,13 @@
|
|
|
1
1
|
<script setup lang="ts">
|
|
2
|
+
import { useData } from '@theme/useData'
|
|
2
3
|
import { computed } from 'vue'
|
|
3
|
-
import { usePageFrontmatter } from 'vuepress/client'
|
|
4
4
|
import type { DefaultThemeHomePageFrontmatter } from '../../shared/index.js'
|
|
5
5
|
|
|
6
|
-
const frontmatter =
|
|
6
|
+
const { frontmatter } = useData<DefaultThemeHomePageFrontmatter>()
|
|
7
7
|
|
|
8
8
|
const features = computed(() => frontmatter.value.features ?? [])
|
|
9
9
|
</script>
|
|
10
10
|
|
|
11
|
-
<!-- eslint-disable-next-line vue/no-root-v-if -->
|
|
12
11
|
<template>
|
|
13
12
|
<div v-if="features.length" class="vp-features">
|
|
14
13
|
<div v-for="feature in features" :key="feature.title" class="vp-feature">
|
|
@@ -9,10 +9,8 @@ const footer = computed(() => frontmatter.value.footer)
|
|
|
9
9
|
const footerHtml = computed(() => frontmatter.value.footerHtml)
|
|
10
10
|
</script>
|
|
11
11
|
|
|
12
|
-
<!-- eslint-disable-next-line vue/no-root-v-if -->
|
|
13
12
|
<template>
|
|
14
13
|
<template v-if="footer">
|
|
15
|
-
<!-- eslint-disable-next-line vue/no-v-html -->
|
|
16
14
|
<div v-if="footerHtml" class="vp-footer" vp-footer v-html="footer" />
|
|
17
15
|
<div v-else class="vp-footer" vp-footer v-text="footer" />
|
|
18
16
|
</template>
|
|
@@ -1,18 +1,13 @@
|
|
|
1
1
|
<script setup lang="ts">
|
|
2
2
|
import VPAutoLink from '@theme/VPAutoLink.vue'
|
|
3
3
|
import { useDarkMode } from '@theme/useDarkMode'
|
|
4
|
+
import { useData } from '@theme/useData'
|
|
4
5
|
import type { FunctionalComponent } from 'vue'
|
|
5
6
|
import { computed, h } from 'vue'
|
|
6
|
-
import {
|
|
7
|
-
ClientOnly,
|
|
8
|
-
usePageFrontmatter,
|
|
9
|
-
useSiteLocaleData,
|
|
10
|
-
withBase,
|
|
11
|
-
} from 'vuepress/client'
|
|
7
|
+
import { ClientOnly, withBase } from 'vuepress/client'
|
|
12
8
|
import type { DefaultThemeHomePageFrontmatter } from '../../shared/index.js'
|
|
13
9
|
|
|
14
|
-
const frontmatter =
|
|
15
|
-
const siteLocale = useSiteLocaleData()
|
|
10
|
+
const { frontmatter, siteLocale } = useData<DefaultThemeHomePageFrontmatter>()
|
|
16
11
|
const isDarkMode = useDarkMode()
|
|
17
12
|
|
|
18
13
|
const heroText = computed(() => {
|
|
@@ -3,7 +3,7 @@ import VPNavbarBrand from '@theme/VPNavbarBrand.vue'
|
|
|
3
3
|
import VPNavbarItems from '@theme/VPNavbarItems.vue'
|
|
4
4
|
import VPToggleColorModeButton from '@theme/VPToggleColorModeButton.vue'
|
|
5
5
|
import VPToggleSidebarButton from '@theme/VPToggleSidebarButton.vue'
|
|
6
|
-
import {
|
|
6
|
+
import { useData } from '@theme/useData'
|
|
7
7
|
import { DeviceType, useUpdateDeviceStatus } from '@theme/useUpdateDeviceStatus'
|
|
8
8
|
import { hasGlobalComponent } from '@vuepress/helper/client'
|
|
9
9
|
import type { VNode } from 'vue'
|
|
@@ -22,7 +22,7 @@ const SearchBox = hasGlobalComponent('SearchBox')
|
|
|
22
22
|
? resolveComponent('SearchBox')
|
|
23
23
|
: (): null => null
|
|
24
24
|
|
|
25
|
-
const themeLocale =
|
|
25
|
+
const { themeLocale } = useData()
|
|
26
26
|
|
|
27
27
|
const navbar = useTemplateRef<HTMLElement | null>('navbar')
|
|
28
28
|
const navbarBrand = useTemplateRef<HTMLElement | null>('navbar-brand')
|
|
@@ -1,19 +1,11 @@
|
|
|
1
1
|
<script setup lang="ts">
|
|
2
2
|
import { useDarkMode } from '@theme/useDarkMode'
|
|
3
|
-
import {
|
|
3
|
+
import { useData } from '@theme/useData'
|
|
4
4
|
import type { FunctionalComponent } from 'vue'
|
|
5
5
|
import { computed, h } from 'vue'
|
|
6
|
-
import {
|
|
7
|
-
ClientOnly,
|
|
8
|
-
RouteLink,
|
|
9
|
-
useRouteLocale,
|
|
10
|
-
useSiteLocaleData,
|
|
11
|
-
withBase,
|
|
12
|
-
} from 'vuepress/client'
|
|
6
|
+
import { ClientOnly, RouteLink, withBase } from 'vuepress/client'
|
|
13
7
|
|
|
14
|
-
const routeLocale =
|
|
15
|
-
const siteLocale = useSiteLocaleData()
|
|
16
|
-
const themeLocale = useThemeLocaleData()
|
|
8
|
+
const { routeLocale, siteLocale, themeLocale } = useData()
|
|
17
9
|
const isDarkMode = useDarkMode()
|
|
18
10
|
|
|
19
11
|
const navbarBrandLink = computed(
|
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
<script setup lang="ts">
|
|
2
2
|
import VPAutoLink from '@theme/VPAutoLink.vue'
|
|
3
3
|
import VPNavbarDropdown from '@theme/VPNavbarDropdown.vue'
|
|
4
|
+
import { useData } from '@theme/useData'
|
|
4
5
|
import { useNavbarConfig } from '@theme/useNavbarConfig'
|
|
5
6
|
import { useNavbarRepo } from '@theme/useNavbarRepo'
|
|
6
7
|
import { useNavbarSelectLanguage } from '@theme/useNavbarSelectLanguage'
|
|
7
|
-
import { useThemeLocaleData } from '@theme/useThemeData'
|
|
8
8
|
import { DeviceType, useUpdateDeviceStatus } from '@theme/useUpdateDeviceStatus'
|
|
9
9
|
import { computed, ref } from 'vue'
|
|
10
10
|
|
|
11
|
+
const { themeLocale } = useData()
|
|
11
12
|
const navbarConfig = useNavbarConfig()
|
|
12
13
|
const navbarSelectLanguage = useNavbarSelectLanguage()
|
|
13
14
|
const navbarRepo = useNavbarRepo()
|
|
@@ -15,7 +16,6 @@ const navbarRepo = useNavbarRepo()
|
|
|
15
16
|
const isMobile = ref(false)
|
|
16
17
|
|
|
17
18
|
const navbarLabel = computed(() => {
|
|
18
|
-
const themeLocale = useThemeLocaleData()
|
|
19
19
|
return themeLocale.value.navbarLabel ?? 'site navigation'
|
|
20
20
|
})
|
|
21
21
|
|
|
@@ -34,7 +34,6 @@ useUpdateDeviceStatus(
|
|
|
34
34
|
)
|
|
35
35
|
</script>
|
|
36
36
|
|
|
37
|
-
<!-- eslint-disable-next-line vue/no-root-v-if -->
|
|
38
37
|
<template>
|
|
39
38
|
<nav
|
|
40
39
|
v-if="navbarLinks.length"
|
|
@@ -2,11 +2,11 @@
|
|
|
2
2
|
import VPAutoLink from '@theme/VPAutoLink.vue'
|
|
3
3
|
import VPEditIcon from '@theme/VPEditIcon.vue'
|
|
4
4
|
import { useContributors } from '@theme/useContributors'
|
|
5
|
+
import { useData } from '@theme/useData'
|
|
5
6
|
import { useEditLink } from '@theme/useEditLink'
|
|
6
7
|
import { useLastUpdated } from '@theme/useLastUpdated'
|
|
7
|
-
import { useThemeLocaleData } from '@theme/useThemeData'
|
|
8
8
|
|
|
9
|
-
const themeLocale =
|
|
9
|
+
const { themeLocale } = useData()
|
|
10
10
|
const editLink = useEditLink()
|
|
11
11
|
const lastUpdated = useLastUpdated()
|
|
12
12
|
const contributors = useContributors()
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
<script setup lang="ts">
|
|
2
2
|
import VPAutoLink from '@theme/VPAutoLink.vue'
|
|
3
|
+
import { useData } from '@theme/useData'
|
|
3
4
|
import { useNavigate } from '@theme/useNavigate'
|
|
4
5
|
import { useRelatedLinks } from '@theme/useRelatedLinks'
|
|
5
|
-
import { useThemeLocaleData } from '@theme/useThemeData'
|
|
6
6
|
import { useEventListener } from '@vueuse/core'
|
|
7
7
|
import { computed } from 'vue'
|
|
8
8
|
|
|
9
|
-
const themeLocale =
|
|
9
|
+
const { themeLocale } = useData()
|
|
10
10
|
const navigate = useNavigate()
|
|
11
11
|
|
|
12
12
|
const { prevLink, nextLink } = useRelatedLinks()
|
|
@@ -32,7 +32,6 @@ useEventListener('keydown', (event): void => {
|
|
|
32
32
|
})
|
|
33
33
|
</script>
|
|
34
34
|
|
|
35
|
-
<!-- eslint-disable-next-line vue/no-root-v-if -->
|
|
36
35
|
<template>
|
|
37
36
|
<nav
|
|
38
37
|
v-if="prevLink || nextLink"
|
|
@@ -45,7 +44,7 @@ useEventListener('keydown', (event): void => {
|
|
|
45
44
|
{{ themeLocale.prev ?? 'Prev' }}
|
|
46
45
|
</div>
|
|
47
46
|
<div class="link">
|
|
48
|
-
<span>{{ prevLink.text }}</span>
|
|
47
|
+
<span class="external-link">{{ prevLink.text }}</span>
|
|
49
48
|
</div>
|
|
50
49
|
</VPAutoLink>
|
|
51
50
|
|
|
@@ -55,7 +54,7 @@ useEventListener('keydown', (event): void => {
|
|
|
55
54
|
<span class="arrow right" />
|
|
56
55
|
</div>
|
|
57
56
|
<div class="link">
|
|
58
|
-
<span>{{ nextLink.text }}</span>
|
|
57
|
+
<span class="external-link">{{ nextLink.text }}</span>
|
|
59
58
|
</div>
|
|
60
59
|
</VPAutoLink>
|
|
61
60
|
</nav>
|
|
@@ -100,6 +99,14 @@ useEventListener('keydown', (event): void => {
|
|
|
100
99
|
background: var(--vp-c-control);
|
|
101
100
|
}
|
|
102
101
|
|
|
102
|
+
&.external-link::after {
|
|
103
|
+
display: none;
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
&:not(.external-link) .external-link::after {
|
|
107
|
+
display: none;
|
|
108
|
+
}
|
|
109
|
+
|
|
103
110
|
.hint {
|
|
104
111
|
color: var(--vp-c-text-mute);
|
|
105
112
|
font-size: 0.875rem;
|
|
@@ -2,9 +2,9 @@
|
|
|
2
2
|
import VPDarkIcon from '@theme/VPDarkIcon.vue'
|
|
3
3
|
import VPLightIcon from '@theme/VPLightIcon.vue'
|
|
4
4
|
import { useDarkMode } from '@theme/useDarkMode'
|
|
5
|
-
import {
|
|
5
|
+
import { useData } from '@theme/useData'
|
|
6
6
|
|
|
7
|
-
const themeLocale =
|
|
7
|
+
const { themeLocale } = useData()
|
|
8
8
|
const isDarkMode = useDarkMode()
|
|
9
9
|
|
|
10
10
|
const toggleColorMode = (): void => {
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
<script setup lang="ts">
|
|
2
|
-
import {
|
|
2
|
+
import { useData } from '@theme/useData'
|
|
3
3
|
|
|
4
4
|
defineEmits<{ toggle: [] }>()
|
|
5
5
|
|
|
6
|
-
const themeLocale =
|
|
6
|
+
const { themeLocale } = useData()
|
|
7
7
|
</script>
|
|
8
8
|
|
|
9
9
|
<template>
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
export * from './useContributors.js';
|
|
2
2
|
export * from './useDarkMode.js';
|
|
3
|
+
export * from './useData.js';
|
|
3
4
|
export * from './useEditLink.js';
|
|
4
5
|
export * from './useLastUpdated.js';
|
|
5
6
|
export * from './useNavigate.js';
|
|
@@ -9,5 +10,4 @@ export * from './useNavbarSelectLanguage.js';
|
|
|
9
10
|
export * from './useRelatedLinks.js';
|
|
10
11
|
export * from './useScrollPromise.js';
|
|
11
12
|
export * from './useSidebarItems.js';
|
|
12
|
-
export * from './useThemeData.js';
|
|
13
13
|
export * from './useUpdateDeviceStatus.js';
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
export * from './useContributors.js';
|
|
2
2
|
export * from './useDarkMode.js';
|
|
3
|
+
export * from './useData.js';
|
|
3
4
|
export * from './useEditLink.js';
|
|
4
5
|
export * from './useLastUpdated.js';
|
|
5
6
|
export * from './useNavigate.js';
|
|
@@ -9,5 +10,4 @@ export * from './useNavbarSelectLanguage.js';
|
|
|
9
10
|
export * from './useRelatedLinks.js';
|
|
10
11
|
export * from './useScrollPromise.js';
|
|
11
12
|
export * from './useSidebarItems.js';
|
|
12
|
-
export * from './useThemeData.js';
|
|
13
13
|
export * from './useUpdateDeviceStatus.js';
|
|
@@ -1,10 +1,7 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { useData } from '@theme/useData';
|
|
2
2
|
import { computed } from 'vue';
|
|
3
|
-
import { usePageData, usePageFrontmatter } from 'vuepress/client';
|
|
4
3
|
export const useContributors = () => {
|
|
5
|
-
const themeLocale =
|
|
6
|
-
const page = usePageData();
|
|
7
|
-
const frontmatter = usePageFrontmatter();
|
|
4
|
+
const { themeLocale, page, frontmatter } = useData();
|
|
8
5
|
return computed(() => {
|
|
9
6
|
const showContributors = frontmatter.value.contributors ?? themeLocale.value.contributors ?? true;
|
|
10
7
|
if (!showContributors)
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { useData } from '@theme/useData';
|
|
2
2
|
import { usePreferredDark, useStorage, watchImmediate } from '@vueuse/core';
|
|
3
3
|
import { computed, inject, onMounted, onUnmounted, provide } from 'vue';
|
|
4
4
|
export const darkModeSymbol = Symbol(__VUEPRESS_DEV__ ? 'darkMode' : '');
|
|
@@ -30,7 +30,7 @@ export const useDarkMode = () => {
|
|
|
30
30
|
* Create dark mode ref and provide as global computed in setup
|
|
31
31
|
*/
|
|
32
32
|
export const setupDarkMode = () => {
|
|
33
|
-
const themeLocale =
|
|
33
|
+
const { themeLocale } = useData();
|
|
34
34
|
const isDarkPreferred = usePreferredDark();
|
|
35
35
|
const darkStorage = useStorage('vuepress-color-scheme', themeLocale.value.colorMode);
|
|
36
36
|
const isDarkMode = computed({
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { ThemeDataRef, ThemeLocaleDataRef } from '@vuepress/plugin-theme-data/client';
|
|
2
|
+
import type { ClientData, PageDataRef, PageFrontmatterRef, PageLangRef, SiteDataRef, SiteLocaleDataRef } from 'vuepress/client';
|
|
3
|
+
import type { DefaultThemeData, DefaultThemeNormalPageFrontmatter, DefaultThemePageData } from '../../shared/index.js';
|
|
4
|
+
export interface Data<PageFrontmatter extends Record<string, unknown> = DefaultThemeNormalPageFrontmatter, PageData extends Record<string, unknown> = DefaultThemePageData> extends Pick<ClientData, 'layouts' | 'pageComponent' | 'pageHead' | 'pageHeadTitle' | 'pageLayout' | 'redirects' | 'routeLocale' | 'routePath' | 'routes'> {
|
|
5
|
+
page: PageDataRef<PageData>;
|
|
6
|
+
frontmatter: PageFrontmatterRef<PageFrontmatter>;
|
|
7
|
+
lang: PageLangRef;
|
|
8
|
+
site: SiteDataRef;
|
|
9
|
+
siteLocale: SiteLocaleDataRef;
|
|
10
|
+
theme: ThemeDataRef<DefaultThemeData>;
|
|
11
|
+
themeLocale: ThemeLocaleDataRef<DefaultThemeData>;
|
|
12
|
+
}
|
|
13
|
+
export declare const useData: <PageFrontmatter extends Record<string, unknown> = DefaultThemeNormalPageFrontmatter, PageData extends Record<string, unknown> = DefaultThemePageData>() => Data<PageFrontmatter, PageData>;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { useThemeData, useThemeLocaleData, } from '@vuepress/plugin-theme-data/client';
|
|
2
|
+
import { useClientData } from 'vuepress/client';
|
|
3
|
+
export const useData = () => {
|
|
4
|
+
const { pageData, pageFrontmatter, pageLang, siteData, siteLocaleData, ...rest } = useClientData();
|
|
5
|
+
return {
|
|
6
|
+
...rest,
|
|
7
|
+
page: pageData,
|
|
8
|
+
frontmatter: pageFrontmatter,
|
|
9
|
+
lang: pageLang,
|
|
10
|
+
site: siteData,
|
|
11
|
+
siteLocale: siteLocaleData,
|
|
12
|
+
theme: useThemeData(),
|
|
13
|
+
themeLocale: useThemeLocaleData(),
|
|
14
|
+
};
|
|
15
|
+
};
|
|
@@ -1,11 +1,8 @@
|
|
|
1
1
|
import { resolveEditLink } from '@theme/resolveEditLink';
|
|
2
|
-
import {
|
|
2
|
+
import { useData } from '@theme/useData';
|
|
3
3
|
import { computed } from 'vue';
|
|
4
|
-
import { usePageData, usePageFrontmatter } from 'vuepress/client';
|
|
5
4
|
export const useEditLink = () => {
|
|
6
|
-
const themeLocale =
|
|
7
|
-
const page = usePageData();
|
|
8
|
-
const frontmatter = usePageFrontmatter();
|
|
5
|
+
const { frontmatter, page, themeLocale } = useData();
|
|
9
6
|
return computed(() => {
|
|
10
7
|
const showEditLink = frontmatter.value.editLink ?? themeLocale.value.editLink ?? true;
|
|
11
8
|
if (!showEditLink) {
|
|
@@ -1,8 +1,7 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { useData } from '@theme/useData';
|
|
2
2
|
import { getHeaders } from '@vuepress/helper/client';
|
|
3
3
|
import { injectLocal, provideLocal, watchImmediate } from '@vueuse/core';
|
|
4
4
|
import { computed, onMounted, ref } from 'vue';
|
|
5
|
-
import { usePageFrontmatter, useRoutePath } from 'vuepress/client';
|
|
6
5
|
export const headersSymbol = Symbol('headers');
|
|
7
6
|
/**
|
|
8
7
|
* Inject headers
|
|
@@ -15,10 +14,8 @@ export const useHeaders = () => {
|
|
|
15
14
|
return headers;
|
|
16
15
|
};
|
|
17
16
|
export const setupHeaders = () => {
|
|
17
|
+
const { frontmatter, routePath, themeLocale } = useData();
|
|
18
18
|
const headersRef = ref([]);
|
|
19
|
-
const routePath = useRoutePath();
|
|
20
|
-
const themeLocale = useThemeLocaleData();
|
|
21
|
-
const frontmatter = usePageFrontmatter();
|
|
22
19
|
const levels = computed(() => frontmatter.value.sidebarDepth ?? themeLocale.value.sidebarDepth ?? 2);
|
|
23
20
|
const updateHeaders = () => {
|
|
24
21
|
if (levels.value <= 0) {
|
|
@@ -1,10 +1,7 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { useData } from '@theme/useData';
|
|
2
2
|
import { computed } from 'vue';
|
|
3
|
-
import { usePageData, usePageFrontmatter } from 'vuepress/client';
|
|
4
3
|
export const useLastUpdated = () => {
|
|
5
|
-
const themeLocale =
|
|
6
|
-
const page = usePageData();
|
|
7
|
-
const frontmatter = usePageFrontmatter();
|
|
4
|
+
const { frontmatter, page, themeLocale } = useData();
|
|
8
5
|
return computed(() => {
|
|
9
6
|
const showLastUpdated = frontmatter.value.lastUpdated ?? themeLocale.value.lastUpdated ?? true;
|
|
10
7
|
if (!showLastUpdated)
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { resolveAutoLink } from '@theme/resolveAutoLink';
|
|
2
2
|
import { resolvePrefix } from '@theme/resolvePrefix';
|
|
3
|
-
import {
|
|
3
|
+
import { useData } from '@theme/useData';
|
|
4
4
|
import { isLinkRelative } from '@vuepress/helper/client';
|
|
5
5
|
import { computed } from 'vue';
|
|
6
6
|
import { isString } from 'vuepress/shared';
|
|
@@ -22,7 +22,7 @@ const resolveNavbarItem = (item, prefix = '') => {
|
|
|
22
22
|
};
|
|
23
23
|
};
|
|
24
24
|
export const useNavbarConfig = () => {
|
|
25
|
-
const themeLocale =
|
|
25
|
+
const { themeLocale } = useData();
|
|
26
26
|
return computed(() =>
|
|
27
27
|
// eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing
|
|
28
28
|
(themeLocale.value.navbar || []).map((item) => resolveNavbarItem(item)));
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { resolveRepoType } from '@theme/resolveRepoType';
|
|
2
|
-
import {
|
|
2
|
+
import { useData } from '@theme/useData';
|
|
3
3
|
import { computed } from 'vue';
|
|
4
4
|
import { isLinkHttp } from 'vuepress/shared';
|
|
5
5
|
/**
|
|
6
6
|
* Get navbar config of repository link
|
|
7
7
|
*/
|
|
8
8
|
export const useNavbarRepo = () => {
|
|
9
|
-
const themeLocale =
|
|
9
|
+
const { themeLocale } = useData();
|
|
10
10
|
const repo = computed(() => themeLocale.value.repo);
|
|
11
11
|
const repoType = computed(() => repo.value ? resolveRepoType(repo.value) : null);
|
|
12
12
|
const repoLink = computed(() => {
|
|
@@ -1,18 +1,14 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { useData } from '@theme/useData';
|
|
2
2
|
import { useRoutePaths } from '@vuepress/helper/client';
|
|
3
3
|
import { computed } from 'vue';
|
|
4
|
-
import { useRoute
|
|
4
|
+
import { useRoute } from 'vuepress/client';
|
|
5
5
|
/**
|
|
6
6
|
* Get navbar config of select language dropdown
|
|
7
7
|
*/
|
|
8
8
|
export const useNavbarSelectLanguage = () => {
|
|
9
9
|
const route = useRoute();
|
|
10
10
|
const routePaths = useRoutePaths();
|
|
11
|
-
const routeLocale =
|
|
12
|
-
const site = useSiteData();
|
|
13
|
-
const siteLocale = useSiteLocaleData();
|
|
14
|
-
const theme = useThemeData();
|
|
15
|
-
const themeLocale = useThemeLocaleData();
|
|
11
|
+
const { routeLocale, site, siteLocale, theme, themeLocale } = useData();
|
|
16
12
|
return computed(() => {
|
|
17
13
|
const localePaths = Object.keys(site.value.locales);
|
|
18
14
|
// do not display language selection dropdown if there is only one language
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { resolveAutoLink } from '@theme/resolveAutoLink';
|
|
2
|
+
import { useData } from '@theme/useData';
|
|
2
3
|
import { useSidebarItems } from '@theme/useSidebarItems';
|
|
3
|
-
import { useThemeLocaleData } from '@theme/useThemeData';
|
|
4
4
|
import { computed } from 'vue';
|
|
5
|
-
import { resolveRoute,
|
|
5
|
+
import { resolveRoute, useRoute } from 'vuepress/client';
|
|
6
6
|
import { isPlainObject, isString } from 'vuepress/shared';
|
|
7
7
|
const resolveFromFrontmatterConfig = (config, currentPath) => {
|
|
8
8
|
if (config === false) {
|
|
@@ -62,8 +62,7 @@ const resolveFromSidebarItems = (sidebarItems, currentPath, offset) => {
|
|
|
62
62
|
return null;
|
|
63
63
|
};
|
|
64
64
|
export const useRelatedLinks = () => {
|
|
65
|
-
const frontmatter =
|
|
66
|
-
const themeLocale = useThemeLocaleData();
|
|
65
|
+
const { frontmatter, themeLocale } = useData();
|
|
67
66
|
const sidebarItems = useSidebarItems();
|
|
68
67
|
const route = useRoute();
|
|
69
68
|
const prevLink = computed(() => {
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { resolveAutoLink } from '@theme/resolveAutoLink';
|
|
2
2
|
import { resolvePrefix } from '@theme/resolvePrefix';
|
|
3
|
-
import {
|
|
3
|
+
import { useData } from '@theme/useData';
|
|
4
4
|
import { isLinkRelative, keys, startsWith } from '@vuepress/helper/client';
|
|
5
5
|
import { computed, inject, provide } from 'vue';
|
|
6
|
-
import {
|
|
6
|
+
import { useRoute } from 'vuepress/client';
|
|
7
7
|
import { isPlainObject, isString } from 'vuepress/shared';
|
|
8
8
|
/**
|
|
9
9
|
* Util to transform page header to sidebar item
|
|
@@ -114,11 +114,8 @@ export const resolveSidebarItems = (sidebarConfig, page, path, routeLocale, head
|
|
|
114
114
|
* Create sidebar items ref and provide as global computed in setup
|
|
115
115
|
*/
|
|
116
116
|
export const setupSidebarItems = () => {
|
|
117
|
-
const themeLocale =
|
|
118
|
-
const frontmatter = usePageFrontmatter();
|
|
119
|
-
const page = usePageData();
|
|
117
|
+
const { frontmatter, page, routeLocale, themeLocale } = useData();
|
|
120
118
|
const route = useRoute();
|
|
121
|
-
const routeLocale = useRouteLocale();
|
|
122
119
|
const sidebarConfig = computed(() => frontmatter.value.home
|
|
123
120
|
? false
|
|
124
121
|
: (frontmatter.value.sidebar ??
|
|
@@ -3,13 +3,12 @@ import VPHome from '@theme/VPHome.vue'
|
|
|
3
3
|
import VPNavbar from '@theme/VPNavbar.vue'
|
|
4
4
|
import VPPage from '@theme/VPPage.vue'
|
|
5
5
|
import VPSidebar from '@theme/VPSidebar.vue'
|
|
6
|
+
import { useData } from '@theme/useData'
|
|
6
7
|
import { useScrollPromise } from '@theme/useScrollPromise'
|
|
7
8
|
import { useSidebarItems } from '@theme/useSidebarItems'
|
|
8
|
-
import { useThemeLocaleData } from '@theme/useThemeData'
|
|
9
9
|
import type { VNode } from 'vue'
|
|
10
10
|
import { computed, onMounted, onUnmounted, ref } from 'vue'
|
|
11
|
-
import {
|
|
12
|
-
import type { DefaultThemePageFrontmatter } from '../../shared/index.js'
|
|
11
|
+
import { useRouter } from 'vuepress/client'
|
|
13
12
|
|
|
14
13
|
defineSlots<{
|
|
15
14
|
'navbar'?: (props: Record<never, never>) => VNode | VNode[] | null
|
|
@@ -27,9 +26,8 @@ defineSlots<{
|
|
|
27
26
|
) => VNode | VNode[] | null
|
|
28
27
|
}>()
|
|
29
28
|
|
|
30
|
-
const page =
|
|
31
|
-
const
|
|
32
|
-
const themeLocale = useThemeLocaleData()
|
|
29
|
+
const { frontmatter, page, themeLocale } = useData()
|
|
30
|
+
const router = useRouter()
|
|
33
31
|
|
|
34
32
|
// navbar
|
|
35
33
|
const shouldShowNavbar = computed(
|
|
@@ -81,8 +79,8 @@ const containerClass = computed(() => [
|
|
|
81
79
|
|
|
82
80
|
// close sidebar after navigation
|
|
83
81
|
let unregisterRouterHook: () => void
|
|
82
|
+
|
|
84
83
|
onMounted(() => {
|
|
85
|
-
const router = useRouter()
|
|
86
84
|
unregisterRouterHook = router.afterEach(() => {
|
|
87
85
|
toggleSidebar(false)
|
|
88
86
|
})
|
|
@@ -1,15 +1,17 @@
|
|
|
1
1
|
<script setup lang="ts">
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
2
|
+
import { useData } from '@theme/useData'
|
|
3
|
+
import { computed } from 'vue'
|
|
4
|
+
import { RouteLink } from 'vuepress/client'
|
|
4
5
|
|
|
5
|
-
const routeLocale =
|
|
6
|
-
|
|
6
|
+
const { routeLocale, themeLocale } = useData()
|
|
7
|
+
|
|
8
|
+
const messages = computed(() => themeLocale.value.notFound ?? ['Not Found'])
|
|
7
9
|
|
|
8
|
-
const messages = themeLocale.value.notFound ?? ['Not Found']
|
|
9
10
|
const getMsg = (): string =>
|
|
10
|
-
messages[Math.floor(Math.random() * messages.length)]
|
|
11
|
-
|
|
12
|
-
const
|
|
11
|
+
messages.value[Math.floor(Math.random() * messages.value.length)]
|
|
12
|
+
|
|
13
|
+
const homeLink = computed(() => themeLocale.value.home ?? routeLocale.value)
|
|
14
|
+
const homeText = computed(() => themeLocale.value.backToHome ?? 'Back to home')
|
|
13
15
|
</script>
|
|
14
16
|
|
|
15
17
|
<template>
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vuepress/theme-default",
|
|
3
|
-
"version": "2.0.0-rc.
|
|
3
|
+
"version": "2.0.0-rc.79",
|
|
4
4
|
"description": "Default theme of VuePress",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"vuepress-theme",
|
|
@@ -37,29 +37,29 @@
|
|
|
37
37
|
"templates"
|
|
38
38
|
],
|
|
39
39
|
"dependencies": {
|
|
40
|
-
"@vuepress/helper": "2.0.0-rc.
|
|
41
|
-
"@vuepress/plugin-active-header-links": "2.0.0-rc.
|
|
42
|
-
"@vuepress/plugin-back-to-top": "2.0.0-rc.
|
|
43
|
-
"@vuepress/plugin-copy-code": "2.0.0-rc.
|
|
44
|
-
"@vuepress/plugin-git": "2.0.0-rc.
|
|
45
|
-
"@vuepress/plugin-links-check": "2.0.0-rc.
|
|
46
|
-
"@vuepress/plugin-markdown-hint": "2.0.0-rc.
|
|
47
|
-
"@vuepress/plugin-markdown-tab": "2.0.0-rc.
|
|
48
|
-
"@vuepress/plugin-medium-zoom": "2.0.0-rc.
|
|
49
|
-
"@vuepress/plugin-nprogress": "2.0.0-rc.
|
|
50
|
-
"@vuepress/plugin-palette": "2.0.0-rc.
|
|
51
|
-
"@vuepress/plugin-prismjs": "2.0.0-rc.
|
|
52
|
-
"@vuepress/plugin-seo": "2.0.0-rc.
|
|
53
|
-
"@vuepress/plugin-sitemap": "2.0.0-rc.
|
|
54
|
-
"@vuepress/plugin-theme-data": "2.0.0-rc.
|
|
40
|
+
"@vuepress/helper": "2.0.0-rc.79",
|
|
41
|
+
"@vuepress/plugin-active-header-links": "2.0.0-rc.79",
|
|
42
|
+
"@vuepress/plugin-back-to-top": "2.0.0-rc.79",
|
|
43
|
+
"@vuepress/plugin-copy-code": "2.0.0-rc.79",
|
|
44
|
+
"@vuepress/plugin-git": "2.0.0-rc.79",
|
|
45
|
+
"@vuepress/plugin-links-check": "2.0.0-rc.79",
|
|
46
|
+
"@vuepress/plugin-markdown-hint": "2.0.0-rc.79",
|
|
47
|
+
"@vuepress/plugin-markdown-tab": "2.0.0-rc.79",
|
|
48
|
+
"@vuepress/plugin-medium-zoom": "2.0.0-rc.79",
|
|
49
|
+
"@vuepress/plugin-nprogress": "2.0.0-rc.79",
|
|
50
|
+
"@vuepress/plugin-palette": "2.0.0-rc.79",
|
|
51
|
+
"@vuepress/plugin-prismjs": "2.0.0-rc.79",
|
|
52
|
+
"@vuepress/plugin-seo": "2.0.0-rc.79",
|
|
53
|
+
"@vuepress/plugin-sitemap": "2.0.0-rc.79",
|
|
54
|
+
"@vuepress/plugin-theme-data": "2.0.0-rc.79",
|
|
55
55
|
"@vueuse/core": "^12.7.0",
|
|
56
56
|
"vue": "^3.5.13"
|
|
57
57
|
},
|
|
58
58
|
"peerDependencies": {
|
|
59
|
-
"sass": "^1.
|
|
60
|
-
"sass-embedded": "^1.
|
|
61
|
-
"sass-loader": "^16.0.
|
|
62
|
-
"vuepress": "2.0.0-rc.
|
|
59
|
+
"sass": "^1.85.0",
|
|
60
|
+
"sass-embedded": "^1.85.0",
|
|
61
|
+
"sass-loader": "^16.0.5",
|
|
62
|
+
"vuepress": "2.0.0-rc.20"
|
|
63
63
|
},
|
|
64
64
|
"peerDependenciesMeta": {
|
|
65
65
|
"sass": {
|
|
@@ -75,5 +75,5 @@
|
|
|
75
75
|
"publishConfig": {
|
|
76
76
|
"access": "public"
|
|
77
77
|
},
|
|
78
|
-
"gitHead": "
|
|
78
|
+
"gitHead": "cc0eb07ab76e8852022d979dc48f9e2636d96190"
|
|
79
79
|
}
|
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
import type { ThemeDataRef, ThemeLocaleDataRef } from '@vuepress/plugin-theme-data/client';
|
|
2
|
-
import type { DefaultThemeData } from '../../shared/index.js';
|
|
3
|
-
export declare const useThemeData: () => ThemeDataRef<DefaultThemeData>;
|
|
4
|
-
export declare const useThemeLocaleData: () => ThemeLocaleDataRef<DefaultThemeData>;
|