@vuepress/theme-default 2.0.0-rc.3 → 2.0.0-rc.31
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/HomeHero.vue +2 -2
- package/lib/client/components/Navbar.vue +10 -9
- package/lib/client/components/NavbarBrand.vue +3 -2
- package/lib/client/components/NavbarDropdown.vue +4 -5
- package/lib/client/components/NavbarItems.vue +36 -37
- package/lib/client/components/PageMeta.vue +123 -27
- package/lib/client/components/PageNav.vue +133 -27
- package/lib/client/components/SidebarItem.vue +2 -3
- package/lib/client/components/SidebarItems.vue +1 -1
- package/lib/client/composables/index.d.ts +1 -0
- package/lib/client/composables/index.js +1 -0
- package/lib/client/composables/useNavigate.d.ts +1 -0
- package/lib/client/composables/useNavigate.js +25 -0
- package/lib/client/composables/useSidebarItems.d.ts +3 -4
- package/lib/client/composables/useSidebarItems.js +10 -12
- package/lib/client/composables/useUpdateDeviceStatus.js +5 -4
- package/lib/client/config.js +7 -11
- package/lib/client/index.d.ts +1 -1
- package/lib/client/index.js +0 -1
- package/lib/client/layouts/Layout.vue +10 -2
- package/lib/client/layouts/NotFound.vue +2 -2
- package/lib/client/shim.d.ts +3 -3
- package/lib/client/styles/arrow.scss +18 -24
- package/lib/client/styles/code.scss +105 -9
- package/lib/client/styles/custom-container.scss +4 -8
- package/lib/client/styles/external-link-icon.scss +33 -0
- package/lib/client/styles/index.scss +1 -0
- package/lib/client/styles/layout.scss +4 -0
- package/lib/client/styles/navbar-dropdown.scss +2 -2
- package/lib/client/styles/navbar.scss +4 -4
- package/lib/client/styles/normalize.scss +1 -1
- package/lib/client/styles/page.scss +0 -76
- package/lib/client/styles/sidebar.scss +1 -1
- package/lib/client/styles/vars-dark.scss +7 -0
- package/lib/client/styles/vars.scss +69 -14
- package/lib/client/utils/getNavLink.d.ts +3 -9
- package/lib/client/utils/getNavLink.js +10 -11
- package/lib/client/utils/index.d.ts +0 -1
- package/lib/client/utils/index.js +0 -1
- package/lib/client/utils/isActiveSidebarItem.d.ts +1 -1
- package/lib/client/utils/resolveEditLink.d.ts +1 -1
- package/lib/node/defaultTheme.js +31 -23
- package/lib/node/index.d.ts +2 -1
- package/lib/node/index.js +1 -1
- package/lib/node/utils/resolveContainerPluginOptions.d.ts +3 -3
- package/lib/node/utils/resolveContainerPluginOptions.js +2 -2
- package/lib/shared/nav.d.ts +3 -11
- package/lib/shared/options.d.ts +27 -5
- package/lib/shared/page.d.ts +5 -3
- package/package.json +21 -20
- package/templates/build.html +13 -10
- package/lib/client/components/AutoLink.vue +0 -113
- package/lib/client/utils/getResolveRouteWithRedirect.d.ts +0 -5
- package/lib/client/utils/getResolveRouteWithRedirect.js +0 -22
package/templates/build.html
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
<!
|
|
1
|
+
<!doctype html>
|
|
2
2
|
<html lang="{{ lang }}">
|
|
3
3
|
<head>
|
|
4
|
-
<meta charset="utf-8"
|
|
5
|
-
<meta name="viewport" content="width=device-width,initial-scale=1"
|
|
6
|
-
<meta name="generator" content="VuePress {{ version }}"
|
|
4
|
+
<meta charset="utf-8" />
|
|
5
|
+
<meta name="viewport" content="width=device-width,initial-scale=1" />
|
|
6
|
+
<meta name="generator" content="VuePress {{ version }}" />
|
|
7
7
|
<style>
|
|
8
8
|
:root {
|
|
9
9
|
--c-bg: #fff;
|
|
@@ -11,16 +11,19 @@
|
|
|
11
11
|
html.dark {
|
|
12
12
|
--c-bg: #22272e;
|
|
13
13
|
}
|
|
14
|
-
html,
|
|
14
|
+
html,
|
|
15
|
+
body {
|
|
15
16
|
background-color: var(--c-bg);
|
|
16
17
|
}
|
|
17
18
|
</style>
|
|
18
19
|
<script>
|
|
19
|
-
const userMode = localStorage.getItem('vuepress-color-scheme')
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
20
|
+
const userMode = localStorage.getItem('vuepress-color-scheme')
|
|
21
|
+
const systemDarkMode =
|
|
22
|
+
window.matchMedia &&
|
|
23
|
+
window.matchMedia('(prefers-color-scheme: dark)').matches
|
|
24
|
+
if (userMode === 'dark' || (userMode !== 'light' && systemDarkMode)) {
|
|
25
|
+
document.documentElement.classList.toggle('dark', true)
|
|
26
|
+
}
|
|
24
27
|
</script>
|
|
25
28
|
<!--vuepress-ssr-head-->
|
|
26
29
|
<!--vuepress-ssr-styles-->
|
|
@@ -1,113 +0,0 @@
|
|
|
1
|
-
<script setup lang="ts">
|
|
2
|
-
import { computed, toRefs } from 'vue'
|
|
3
|
-
import type { PropType } from 'vue'
|
|
4
|
-
import { useRoute } from 'vue-router'
|
|
5
|
-
import { useSiteData } from 'vuepress/client'
|
|
6
|
-
import { isLinkHttp, isLinkWithProtocol } from 'vuepress/shared'
|
|
7
|
-
import type { NavLink } from '../../shared/index.js'
|
|
8
|
-
|
|
9
|
-
defineOptions({
|
|
10
|
-
inheritAttrs: false,
|
|
11
|
-
})
|
|
12
|
-
|
|
13
|
-
const props = defineProps({
|
|
14
|
-
item: {
|
|
15
|
-
type: Object as PropType<NavLink>,
|
|
16
|
-
required: true,
|
|
17
|
-
},
|
|
18
|
-
})
|
|
19
|
-
|
|
20
|
-
defineSlots<{
|
|
21
|
-
before?: (props: Record<never, never>) => any
|
|
22
|
-
after?: (props: Record<never, never>) => any
|
|
23
|
-
}>()
|
|
24
|
-
|
|
25
|
-
const route = useRoute()
|
|
26
|
-
const site = useSiteData()
|
|
27
|
-
const { item } = toRefs(props)
|
|
28
|
-
|
|
29
|
-
// if the link has http protocol
|
|
30
|
-
const hasHttpProtocol = computed(() => isLinkHttp(item.value.link))
|
|
31
|
-
// if the link has non-http protocol
|
|
32
|
-
const hasNonHttpProtocol = computed(
|
|
33
|
-
() => !hasHttpProtocol.value && isLinkWithProtocol(item.value.link),
|
|
34
|
-
)
|
|
35
|
-
// resolve the `target` attr
|
|
36
|
-
const linkTarget = computed(() => {
|
|
37
|
-
if (hasNonHttpProtocol.value) return undefined
|
|
38
|
-
if (item.value.target) return item.value.target
|
|
39
|
-
if (hasHttpProtocol.value) return '_blank'
|
|
40
|
-
return undefined
|
|
41
|
-
})
|
|
42
|
-
// if the `target` attr is '_blank'
|
|
43
|
-
const isBlankTarget = computed(() => linkTarget.value === '_blank')
|
|
44
|
-
// is `<RouterLink>` or not
|
|
45
|
-
const isRouterLink = computed(
|
|
46
|
-
() =>
|
|
47
|
-
!hasHttpProtocol.value && !hasNonHttpProtocol.value && !isBlankTarget.value,
|
|
48
|
-
)
|
|
49
|
-
// resolve the `rel` attr
|
|
50
|
-
const linkRel = computed(() => {
|
|
51
|
-
if (hasNonHttpProtocol.value) return undefined
|
|
52
|
-
if (item.value.rel) return item.value.rel
|
|
53
|
-
if (isBlankTarget.value) return 'noopener noreferrer'
|
|
54
|
-
return undefined
|
|
55
|
-
})
|
|
56
|
-
// resolve the `aria-label` attr
|
|
57
|
-
const linkAriaLabel = computed(() => item.value.ariaLabel || item.value.text)
|
|
58
|
-
|
|
59
|
-
// should be active when current route is a subpath of this link
|
|
60
|
-
const shouldBeActiveInSubpath = computed(() => {
|
|
61
|
-
const localeKeys = Object.keys(site.value.locales)
|
|
62
|
-
if (localeKeys.length) {
|
|
63
|
-
return !localeKeys.some((key) => key === item.value.link)
|
|
64
|
-
}
|
|
65
|
-
return item.value.link !== '/'
|
|
66
|
-
})
|
|
67
|
-
// if this link is active in subpath
|
|
68
|
-
const isActiveInSubpath = computed(() => {
|
|
69
|
-
if (!shouldBeActiveInSubpath.value) {
|
|
70
|
-
return false
|
|
71
|
-
}
|
|
72
|
-
return route.path.startsWith(item.value.link)
|
|
73
|
-
})
|
|
74
|
-
|
|
75
|
-
// if this link is active
|
|
76
|
-
const isActive = computed(() => {
|
|
77
|
-
if (!isRouterLink.value) {
|
|
78
|
-
return false
|
|
79
|
-
}
|
|
80
|
-
if (item.value.activeMatch) {
|
|
81
|
-
return new RegExp(item.value.activeMatch).test(route.path)
|
|
82
|
-
}
|
|
83
|
-
return isActiveInSubpath.value
|
|
84
|
-
})
|
|
85
|
-
</script>
|
|
86
|
-
|
|
87
|
-
<template>
|
|
88
|
-
<RouterLink
|
|
89
|
-
v-if="isRouterLink"
|
|
90
|
-
:class="{ 'router-link-active': isActive }"
|
|
91
|
-
:to="item.link"
|
|
92
|
-
:aria-label="linkAriaLabel"
|
|
93
|
-
v-bind="$attrs"
|
|
94
|
-
>
|
|
95
|
-
<slot name="before" />
|
|
96
|
-
{{ item.text }}
|
|
97
|
-
<slot name="after" />
|
|
98
|
-
</RouterLink>
|
|
99
|
-
<a
|
|
100
|
-
v-else
|
|
101
|
-
class="external-link"
|
|
102
|
-
:href="item.link"
|
|
103
|
-
:rel="linkRel"
|
|
104
|
-
:target="linkTarget"
|
|
105
|
-
:aria-label="linkAriaLabel"
|
|
106
|
-
v-bind="$attrs"
|
|
107
|
-
>
|
|
108
|
-
<slot name="before" />
|
|
109
|
-
{{ item.text }}
|
|
110
|
-
<AutoLinkExternalIcon v-if="isBlankTarget" />
|
|
111
|
-
<slot name="after" />
|
|
112
|
-
</a>
|
|
113
|
-
</template>
|
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
import type { Router } from 'vue-router';
|
|
2
|
-
/**
|
|
3
|
-
* Resolve a route with redirection
|
|
4
|
-
*/
|
|
5
|
-
export declare const getResolveRouteWithRedirect: (router: Router, to: import("vue-router").RouteLocationRaw, currentLocation?: import("vue-router").RouteLocationNormalizedLoaded | undefined) => ReturnType<Router['resolve']>;
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import { isFunction, isString } from 'vuepress/shared';
|
|
2
|
-
/**
|
|
3
|
-
* Resolve a route with redirection
|
|
4
|
-
*/
|
|
5
|
-
export const getResolveRouteWithRedirect = (router, ...args) => {
|
|
6
|
-
const route = router.resolve(...args);
|
|
7
|
-
const lastMatched = route.matched[route.matched.length - 1];
|
|
8
|
-
if (!lastMatched?.redirect) {
|
|
9
|
-
return route;
|
|
10
|
-
}
|
|
11
|
-
const { redirect } = lastMatched;
|
|
12
|
-
const resolvedRedirect = isFunction(redirect) ? redirect(route) : redirect;
|
|
13
|
-
const resolvedRedirectObj = isString(resolvedRedirect)
|
|
14
|
-
? { path: resolvedRedirect }
|
|
15
|
-
: resolvedRedirect;
|
|
16
|
-
return getResolveRouteWithRedirect(router, {
|
|
17
|
-
hash: route.hash,
|
|
18
|
-
query: route.query,
|
|
19
|
-
params: route.params,
|
|
20
|
-
...resolvedRedirectObj,
|
|
21
|
-
});
|
|
22
|
-
};
|