@vuepress/theme-default 2.0.0-beta.46 → 2.0.0-beta.49
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 +3 -2
- package/lib/client/components/HomeContent.vue +1 -1
- package/lib/client/components/Navbar.vue +2 -3
- package/lib/client/components/NavbarItems.vue +8 -3
- package/lib/client/components/PageMeta.vue +1 -5
- package/lib/client/components/SidebarItem.vue +18 -14
- package/lib/client/components/SidebarItems.vue +1 -1
- package/lib/client/components/{ToggleDarkModeButton.vue → ToggleColorModeButton.vue} +4 -4
- package/lib/client/composables/useDarkMode.js +4 -4
- package/lib/client/layouts/404.vue +7 -5
- package/lib/client/layouts/Layout.vue +1 -1
- package/lib/client/styles/home.scss +5 -0
- package/lib/client/styles/layout.scss +25 -38
- package/lib/client/styles/navbar.scss +2 -2
- package/lib/client/styles/normalize.scss +1 -0
- package/lib/client/styles/page.scss +5 -0
- package/lib/client/styles/sidebar.scss +9 -9
- package/lib/node/utils/assignDefaultLocaleOptions.js +4 -2
- package/lib/shared/options.d.ts +16 -10
- package/package.json +19 -19
|
@@ -5,14 +5,15 @@ import { defineComponent } from 'vue'
|
|
|
5
5
|
export default defineComponent({
|
|
6
6
|
inheritAttrs: false,
|
|
7
7
|
})
|
|
8
|
+
/* eslint-enable import/order */
|
|
8
9
|
</script>
|
|
9
10
|
|
|
10
11
|
<script setup lang="ts">
|
|
12
|
+
import { useSiteData } from '@vuepress/client'
|
|
13
|
+
import { isLinkHttp, isLinkMailto, isLinkTel } from '@vuepress/shared'
|
|
11
14
|
import { computed, toRefs } from 'vue'
|
|
12
15
|
import type { PropType } from 'vue'
|
|
13
16
|
import { useRoute } from 'vue-router'
|
|
14
|
-
import { useSiteData } from '@vuepress/client'
|
|
15
|
-
import { isLinkHttp, isLinkMailto, isLinkTel } from '@vuepress/shared'
|
|
16
17
|
import type { NavLink } from '../../shared'
|
|
17
18
|
|
|
18
19
|
const props = defineProps({
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
<script setup lang="ts">
|
|
2
2
|
import NavbarBrand from '@theme/NavbarBrand.vue'
|
|
3
3
|
import NavbarItems from '@theme/NavbarItems.vue'
|
|
4
|
-
import
|
|
4
|
+
import ToggleColorModeButton from '@theme/ToggleColorModeButton.vue'
|
|
5
5
|
import ToggleSidebarButton from '@theme/ToggleSidebarButton.vue'
|
|
6
6
|
import { computed, onMounted, ref } from 'vue'
|
|
7
7
|
import { useThemeLocaleData } from '../composables'
|
|
@@ -22,7 +22,6 @@ const linksWrapperStyle = computed(() => {
|
|
|
22
22
|
maxWidth: linksWrapperMaxWidth.value + 'px',
|
|
23
23
|
}
|
|
24
24
|
})
|
|
25
|
-
const enableDarkMode = computed(() => themeLocale.value.darkMode)
|
|
26
25
|
|
|
27
26
|
// avoid overlapping of long title and long navbar links
|
|
28
27
|
onMounted(() => {
|
|
@@ -69,7 +68,7 @@ function getCssValue(el: HTMLElement | null, property: string): number {
|
|
|
69
68
|
<slot name="before" />
|
|
70
69
|
<NavbarItems class="can-hide" />
|
|
71
70
|
<slot name="after" />
|
|
72
|
-
<
|
|
71
|
+
<ToggleColorModeButton v-if="themeLocale.colorModeSwitch" />
|
|
73
72
|
<NavbarSearch />
|
|
74
73
|
</div>
|
|
75
74
|
</header>
|
|
@@ -27,12 +27,16 @@ const useNavbarSelectLanguage = (): ComputedRef<ResolvedNavbarItem[]> => {
|
|
|
27
27
|
}
|
|
28
28
|
const currentPath = router.currentRoute.value.path
|
|
29
29
|
const currentFullPath = router.currentRoute.value.fullPath
|
|
30
|
+
const currentHash = router.currentRoute.value.hash
|
|
30
31
|
|
|
31
32
|
const languageDropdown: ResolvedNavbarItem = {
|
|
32
33
|
text: themeLocale.value.selectLanguageText ?? 'unknown language',
|
|
33
|
-
ariaLabel:
|
|
34
|
+
ariaLabel:
|
|
35
|
+
themeLocale.value.selectLanguageAriaLabel ??
|
|
36
|
+
themeLocale.value.selectLanguageText ??
|
|
37
|
+
'unknown language',
|
|
34
38
|
children: localePaths.map((targetLocalePath) => {
|
|
35
|
-
// target locale config of this
|
|
39
|
+
// target locale config of this language link
|
|
36
40
|
const targetSiteLocale =
|
|
37
41
|
siteLocale.value.locales?.[targetLocalePath] ?? {}
|
|
38
42
|
const targetThemeLocale =
|
|
@@ -57,7 +61,8 @@ const useNavbarSelectLanguage = (): ComputedRef<ResolvedNavbarItem[]> => {
|
|
|
57
61
|
if (
|
|
58
62
|
router.getRoutes().some((item) => item.path === targetLocalePage)
|
|
59
63
|
) {
|
|
60
|
-
|
|
64
|
+
// try to keep current hash across languages
|
|
65
|
+
link = `${targetLocalePage}${currentHash}`
|
|
61
66
|
} else {
|
|
62
67
|
link = targetThemeLocale.home ?? targetLocalePath
|
|
63
68
|
}
|
|
@@ -1,10 +1,6 @@
|
|
|
1
1
|
<script setup lang="ts">
|
|
2
2
|
import AutoLink from '@theme/AutoLink.vue'
|
|
3
|
-
import {
|
|
4
|
-
usePageData,
|
|
5
|
-
usePageFrontmatter,
|
|
6
|
-
useSiteLocaleData,
|
|
7
|
-
} from '@vuepress/client'
|
|
3
|
+
import { usePageData, usePageFrontmatter } from '@vuepress/client'
|
|
8
4
|
import { computed } from 'vue'
|
|
9
5
|
import type { ComputedRef } from 'vue'
|
|
10
6
|
import type {
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
<script setup lang="ts">
|
|
2
2
|
import AutoLink from '@theme/AutoLink.vue'
|
|
3
3
|
import DropdownTransition from '@theme/DropdownTransition.vue'
|
|
4
|
-
import {
|
|
4
|
+
import { useToggle } from '@vueuse/core'
|
|
5
|
+
import { computed, nextTick, onBeforeUnmount, toRefs } from 'vue'
|
|
5
6
|
import type { PropType } from 'vue'
|
|
6
7
|
import { useRoute, useRouter } from 'vue-router'
|
|
7
8
|
import type { ResolvedSidebarItem } from '../../shared'
|
|
@@ -31,21 +32,24 @@ const itemClass = computed(() => ({
|
|
|
31
32
|
'collapsible': item.value.collapsible,
|
|
32
33
|
}))
|
|
33
34
|
|
|
34
|
-
const isOpen =
|
|
35
|
-
const onClick =
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
// toggle open status on click
|
|
41
|
-
onClick.value = () => {
|
|
42
|
-
isOpen.value = !isOpen.value
|
|
35
|
+
const [isOpen, toggleIsOpen] = useToggle(isActive.value)
|
|
36
|
+
const onClick = (e: Event): void => {
|
|
37
|
+
if (item.value.collapsible) {
|
|
38
|
+
e.preventDefault()
|
|
39
|
+
// toggle open status on click
|
|
40
|
+
toggleIsOpen()
|
|
43
41
|
}
|
|
44
|
-
// reset open status after navigation
|
|
45
|
-
router.afterEach(() => {
|
|
46
|
-
isOpen.value = isActive.value
|
|
47
|
-
})
|
|
48
42
|
}
|
|
43
|
+
|
|
44
|
+
// reset open status after navigation
|
|
45
|
+
const unregisterRouterHook = router.afterEach((to) => {
|
|
46
|
+
nextTick(() => {
|
|
47
|
+
isOpen.value = item.value.collapsible ? isActive.value : true
|
|
48
|
+
})
|
|
49
|
+
})
|
|
50
|
+
onBeforeUnmount(() => {
|
|
51
|
+
unregisterRouterHook()
|
|
52
|
+
})
|
|
49
53
|
</script>
|
|
50
54
|
|
|
51
55
|
<template>
|
|
@@ -4,16 +4,16 @@ import { useDarkMode, useThemeLocaleData } from '../composables'
|
|
|
4
4
|
const themeLocale = useThemeLocaleData()
|
|
5
5
|
const isDarkMode = useDarkMode()
|
|
6
6
|
|
|
7
|
-
const
|
|
7
|
+
const toggleColorMode = (): void => {
|
|
8
8
|
isDarkMode.value = !isDarkMode.value
|
|
9
9
|
}
|
|
10
10
|
</script>
|
|
11
11
|
|
|
12
12
|
<template>
|
|
13
13
|
<button
|
|
14
|
-
class="toggle-
|
|
15
|
-
:title="themeLocale.
|
|
16
|
-
@click="
|
|
14
|
+
class="toggle-color-mode-button"
|
|
15
|
+
:title="themeLocale.toggleColorMode"
|
|
16
|
+
@click="toggleColorMode"
|
|
17
17
|
>
|
|
18
18
|
<svg
|
|
19
19
|
v-show="!isDarkMode"
|
|
@@ -18,12 +18,12 @@ export const useDarkMode = () => {
|
|
|
18
18
|
export const setupDarkMode = () => {
|
|
19
19
|
const themeLocale = useThemeLocaleData();
|
|
20
20
|
const isDarkPreferred = usePreferredDark();
|
|
21
|
-
const darkStorage = useStorage('vuepress-color-scheme',
|
|
21
|
+
const darkStorage = useStorage('vuepress-color-scheme', themeLocale.value.colorMode);
|
|
22
22
|
const isDarkMode = computed({
|
|
23
23
|
get() {
|
|
24
|
-
// disable
|
|
25
|
-
if (!themeLocale.value.
|
|
26
|
-
return
|
|
24
|
+
// disable color mode switching
|
|
25
|
+
if (!themeLocale.value.colorModeSwitch) {
|
|
26
|
+
return themeLocale.value.colorMode === 'dark';
|
|
27
27
|
}
|
|
28
28
|
// auto detected from prefers-color-scheme
|
|
29
29
|
if (darkStorage.value === 'auto') {
|
|
@@ -14,12 +14,14 @@ const homeText = themeLocale.value.backToHome ?? 'Back to home'
|
|
|
14
14
|
|
|
15
15
|
<template>
|
|
16
16
|
<div class="theme-container">
|
|
17
|
-
<
|
|
18
|
-
<
|
|
17
|
+
<main class="page">
|
|
18
|
+
<div class="theme-default-content">
|
|
19
|
+
<h1>404</h1>
|
|
19
20
|
|
|
20
|
-
|
|
21
|
+
<blockquote>{{ getMsg() }}</blockquote>
|
|
21
22
|
|
|
22
|
-
|
|
23
|
-
|
|
23
|
+
<RouterLink :to="homeLink">{{ homeText }}</RouterLink>
|
|
24
|
+
</div>
|
|
25
|
+
</main>
|
|
24
26
|
</div>
|
|
25
27
|
</template>
|
|
@@ -4,7 +4,7 @@ import Navbar from '@theme/Navbar.vue'
|
|
|
4
4
|
import Page from '@theme/Page.vue'
|
|
5
5
|
import Sidebar from '@theme/Sidebar.vue'
|
|
6
6
|
import { usePageData, usePageFrontmatter } from '@vuepress/client'
|
|
7
|
-
import { computed, onMounted, onUnmounted, ref
|
|
7
|
+
import { computed, onMounted, onUnmounted, ref } from 'vue'
|
|
8
8
|
import { useRouter } from 'vue-router'
|
|
9
9
|
import type { DefaultThemePageFrontmatter } from '../../shared'
|
|
10
10
|
import {
|
|
@@ -86,14 +86,16 @@
|
|
|
86
86
|
}
|
|
87
87
|
|
|
88
88
|
&.no-navbar {
|
|
89
|
-
.theme-default-content
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
89
|
+
.theme-default-content {
|
|
90
|
+
h1,
|
|
91
|
+
h2,
|
|
92
|
+
h3,
|
|
93
|
+
h4,
|
|
94
|
+
h5,
|
|
95
|
+
h6 {
|
|
96
|
+
margin-top: 1.5rem;
|
|
97
|
+
padding-top: 0;
|
|
98
|
+
}
|
|
97
99
|
}
|
|
98
100
|
|
|
99
101
|
.page {
|
|
@@ -118,13 +120,21 @@
|
|
|
118
120
|
}
|
|
119
121
|
}
|
|
120
122
|
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
123
|
+
.theme-default-content {
|
|
124
|
+
a:hover {
|
|
125
|
+
text-decoration: underline;
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
img {
|
|
129
|
+
max-width: 100%;
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
h1,
|
|
133
|
+
h2,
|
|
134
|
+
h3,
|
|
135
|
+
h4,
|
|
136
|
+
h5,
|
|
137
|
+
h6 {
|
|
128
138
|
margin-top: calc(0.5rem - var(--navbar-height));
|
|
129
139
|
padding-top: calc(1rem + var(--navbar-height));
|
|
130
140
|
margin-bottom: 0;
|
|
@@ -141,29 +151,6 @@ h6 {
|
|
|
141
151
|
}
|
|
142
152
|
}
|
|
143
153
|
|
|
144
|
-
.theme-default-content:not(.custom) {
|
|
145
|
-
@include content_wrapper;
|
|
146
|
-
|
|
147
|
-
padding-top: 0;
|
|
148
|
-
|
|
149
|
-
a:hover {
|
|
150
|
-
text-decoration: underline;
|
|
151
|
-
}
|
|
152
|
-
|
|
153
|
-
img {
|
|
154
|
-
max-width: 100%;
|
|
155
|
-
}
|
|
156
|
-
}
|
|
157
|
-
|
|
158
|
-
.theme-default-content.custom {
|
|
159
|
-
padding: 0;
|
|
160
|
-
margin: 0;
|
|
161
|
-
|
|
162
|
-
img {
|
|
163
|
-
max-width: 100%;
|
|
164
|
-
}
|
|
165
|
-
}
|
|
166
|
-
|
|
167
154
|
// narrow desktop / iPad
|
|
168
155
|
@media (max-width: $MQNarrow) {
|
|
169
156
|
.sidebar {
|
|
@@ -79,20 +79,20 @@
|
|
|
79
79
|
box-sizing: border-box;
|
|
80
80
|
margin: 0;
|
|
81
81
|
|
|
82
|
+
+ .sidebar-item-children {
|
|
83
|
+
@include dropdown_wrapper;
|
|
84
|
+
margin-bottom: 0.75rem;
|
|
85
|
+
}
|
|
86
|
+
|
|
82
87
|
&.collapsible {
|
|
83
88
|
cursor: pointer;
|
|
84
89
|
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
90
|
+
.arrow {
|
|
91
|
+
position: relative;
|
|
92
|
+
top: -0.12em;
|
|
93
|
+
left: 0.5em;
|
|
88
94
|
}
|
|
89
95
|
}
|
|
90
|
-
|
|
91
|
-
.arrow {
|
|
92
|
-
position: relative;
|
|
93
|
-
top: -0.12em;
|
|
94
|
-
left: 0.5em;
|
|
95
|
-
}
|
|
96
96
|
}
|
|
97
97
|
|
|
98
98
|
&:not(.sidebar-heading) {
|
|
@@ -2,10 +2,12 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.assignDefaultLocaleOptions = exports.DEFAULT_LOCALE_DATA = exports.DEFAULT_LOCALE_OPTIONS = void 0;
|
|
4
4
|
exports.DEFAULT_LOCALE_OPTIONS = {
|
|
5
|
+
// color mode
|
|
6
|
+
colorMode: 'auto',
|
|
7
|
+
colorModeSwitch: true,
|
|
5
8
|
// navbar
|
|
6
9
|
navbar: [],
|
|
7
10
|
logo: null,
|
|
8
|
-
darkMode: true,
|
|
9
11
|
repo: null,
|
|
10
12
|
selectLanguageText: 'Languages',
|
|
11
13
|
selectLanguageAriaLabel: 'Select language',
|
|
@@ -29,7 +31,7 @@ exports.DEFAULT_LOCALE_OPTIONS = {
|
|
|
29
31
|
backToHome: 'Take me home',
|
|
30
32
|
// a11y
|
|
31
33
|
openInNewWindow: 'open in new window',
|
|
32
|
-
|
|
34
|
+
toggleColorMode: 'toggle color mode',
|
|
33
35
|
toggleSidebar: 'toggle sidebar',
|
|
34
36
|
};
|
|
35
37
|
exports.DEFAULT_LOCALE_DATA = {
|
package/lib/shared/options.d.ts
CHANGED
|
@@ -45,6 +45,18 @@ export interface DefaultThemePluginsOptions {
|
|
|
45
45
|
export declare type DefaultThemeLocaleOptions = DefaultThemeData;
|
|
46
46
|
export declare type DefaultThemeData = ThemeData<DefaultThemeLocaleData>;
|
|
47
47
|
export interface DefaultThemeLocaleData extends LocaleData {
|
|
48
|
+
/**
|
|
49
|
+
* Default color mode
|
|
50
|
+
*
|
|
51
|
+
* @default 'auto'
|
|
52
|
+
*/
|
|
53
|
+
colorMode?: 'auto' | 'dark' | 'light';
|
|
54
|
+
/**
|
|
55
|
+
* Enable color mode switching and display a button in navbar or not
|
|
56
|
+
*
|
|
57
|
+
* @default true
|
|
58
|
+
*/
|
|
59
|
+
colorModeSwitch?: boolean;
|
|
48
60
|
/**
|
|
49
61
|
* Home path of current locale
|
|
50
62
|
*
|
|
@@ -69,12 +81,6 @@ export interface DefaultThemeLocaleData extends LocaleData {
|
|
|
69
81
|
* Logo to display in navbar in dark mode
|
|
70
82
|
*/
|
|
71
83
|
logoDark?: null | string;
|
|
72
|
-
/**
|
|
73
|
-
* Navbar dark mode button config
|
|
74
|
-
*
|
|
75
|
-
* Enable dark mode switching and display a button in navbar or not
|
|
76
|
-
*/
|
|
77
|
-
darkMode?: boolean;
|
|
78
84
|
/**
|
|
79
85
|
* Navbar repository config
|
|
80
86
|
*
|
|
@@ -122,9 +128,9 @@ export interface DefaultThemeLocaleData extends LocaleData {
|
|
|
122
128
|
* - ...
|
|
123
129
|
*
|
|
124
130
|
* The max value depends on which headers you have extracted
|
|
125
|
-
* via `markdown.
|
|
131
|
+
* via `markdown.headers.level`.
|
|
126
132
|
*
|
|
127
|
-
* The default value of `markdown.
|
|
133
|
+
* The default value of `markdown.headers.level` is `[2, 3]`,
|
|
128
134
|
* so the default max value of `sidebarDepth` is `2`
|
|
129
135
|
*/
|
|
130
136
|
sidebarDepth?: number;
|
|
@@ -227,9 +233,9 @@ export interface DefaultThemeLocaleData extends LocaleData {
|
|
|
227
233
|
*/
|
|
228
234
|
openInNewWindow?: string;
|
|
229
235
|
/**
|
|
230
|
-
* A11y text for
|
|
236
|
+
* A11y text for color mode toggle button
|
|
231
237
|
*/
|
|
232
|
-
|
|
238
|
+
toggleColorMode?: string;
|
|
233
239
|
/**
|
|
234
240
|
* A11y text for sidebar toggle button
|
|
235
241
|
*/
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vuepress/theme-default",
|
|
3
|
-
"version": "2.0.0-beta.
|
|
3
|
+
"version": "2.0.0-beta.49",
|
|
4
4
|
"description": "Default theme of VuePress",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"vuepress-theme",
|
|
@@ -25,24 +25,24 @@
|
|
|
25
25
|
"templates"
|
|
26
26
|
],
|
|
27
27
|
"dependencies": {
|
|
28
|
-
"@vuepress/client": "2.0.0-beta.
|
|
29
|
-
"@vuepress/core": "2.0.0-beta.
|
|
30
|
-
"@vuepress/plugin-active-header-links": "2.0.0-beta.
|
|
31
|
-
"@vuepress/plugin-back-to-top": "2.0.0-beta.
|
|
32
|
-
"@vuepress/plugin-container": "2.0.0-beta.
|
|
33
|
-
"@vuepress/plugin-external-link-icon": "2.0.0-beta.
|
|
34
|
-
"@vuepress/plugin-git": "2.0.0-beta.
|
|
35
|
-
"@vuepress/plugin-medium-zoom": "2.0.0-beta.
|
|
36
|
-
"@vuepress/plugin-nprogress": "2.0.0-beta.
|
|
37
|
-
"@vuepress/plugin-palette": "2.0.0-beta.
|
|
38
|
-
"@vuepress/plugin-prismjs": "2.0.0-beta.
|
|
39
|
-
"@vuepress/plugin-theme-data": "2.0.0-beta.
|
|
40
|
-
"@vuepress/shared": "2.0.0-beta.
|
|
41
|
-
"@vuepress/utils": "2.0.0-beta.
|
|
42
|
-
"@vueuse/core": "^8.
|
|
43
|
-
"sass": "^1.
|
|
44
|
-
"vue": "^3.2.
|
|
45
|
-
"vue-router": "^4.
|
|
28
|
+
"@vuepress/client": "2.0.0-beta.49",
|
|
29
|
+
"@vuepress/core": "2.0.0-beta.49",
|
|
30
|
+
"@vuepress/plugin-active-header-links": "2.0.0-beta.49",
|
|
31
|
+
"@vuepress/plugin-back-to-top": "2.0.0-beta.49",
|
|
32
|
+
"@vuepress/plugin-container": "2.0.0-beta.49",
|
|
33
|
+
"@vuepress/plugin-external-link-icon": "2.0.0-beta.49",
|
|
34
|
+
"@vuepress/plugin-git": "2.0.0-beta.49",
|
|
35
|
+
"@vuepress/plugin-medium-zoom": "2.0.0-beta.49",
|
|
36
|
+
"@vuepress/plugin-nprogress": "2.0.0-beta.49",
|
|
37
|
+
"@vuepress/plugin-palette": "2.0.0-beta.49",
|
|
38
|
+
"@vuepress/plugin-prismjs": "2.0.0-beta.49",
|
|
39
|
+
"@vuepress/plugin-theme-data": "2.0.0-beta.49",
|
|
40
|
+
"@vuepress/shared": "2.0.0-beta.49",
|
|
41
|
+
"@vuepress/utils": "2.0.0-beta.49",
|
|
42
|
+
"@vueuse/core": "^8.7.5",
|
|
43
|
+
"sass": "^1.53.0",
|
|
44
|
+
"vue": "^3.2.37",
|
|
45
|
+
"vue-router": "^4.1.2"
|
|
46
46
|
},
|
|
47
47
|
"peerDependencies": {
|
|
48
48
|
"sass-loader": "^13.0.0"
|