@vuepress/theme-default 2.0.0-beta.61 → 2.0.0-beta.63
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 +5 -0
- package/lib/client/components/DropdownTransition.vue +4 -0
- package/lib/client/components/Navbar.vue +23 -17
- package/lib/client/components/NavbarItems.vue +28 -24
- package/lib/client/components/Page.vue +7 -0
- package/lib/client/components/Sidebar.vue +5 -0
- package/lib/client/components/ToggleSidebarButton.vue +3 -1
- package/lib/client/components/global/Badge.vue +4 -0
- package/lib/client/components/global/CodeGroup.d.ts +4 -2
- package/lib/client/components/global/CodeGroup.js +1 -0
- package/lib/client/composables/index.d.ts +1 -0
- package/lib/client/composables/index.js +1 -0
- package/lib/client/composables/useUpdateDeviceStatus.d.ts +7 -0
- package/lib/client/composables/useUpdateDeviceStatus.js +25 -0
- package/lib/client/layouts/Layout.vue +14 -0
- package/lib/client/shim.d.ts +5 -0
- package/lib/client/styles/_variables.module.scss +5 -0
- package/package.json +21 -20
|
@@ -23,6 +23,11 @@ const props = defineProps({
|
|
|
23
23
|
},
|
|
24
24
|
})
|
|
25
25
|
|
|
26
|
+
defineSlots<{
|
|
27
|
+
before?: (props: Record<never, never>) => any
|
|
28
|
+
after?: (props: Record<never, never>) => any
|
|
29
|
+
}>()
|
|
30
|
+
|
|
26
31
|
const route = useRoute()
|
|
27
32
|
const site = useSiteData()
|
|
28
33
|
const { item } = toRefs(props)
|
|
@@ -3,10 +3,21 @@ import NavbarBrand from '@theme/NavbarBrand.vue'
|
|
|
3
3
|
import NavbarItems from '@theme/NavbarItems.vue'
|
|
4
4
|
import ToggleColorModeButton from '@theme/ToggleColorModeButton.vue'
|
|
5
5
|
import ToggleSidebarButton from '@theme/ToggleSidebarButton.vue'
|
|
6
|
-
import { computed,
|
|
7
|
-
import {
|
|
6
|
+
import { computed, ref } from 'vue'
|
|
7
|
+
import {
|
|
8
|
+
DeviceType,
|
|
9
|
+
useThemeLocaleData,
|
|
10
|
+
useUpdateDeviceStatus,
|
|
11
|
+
} from '../composables/index.js'
|
|
8
12
|
|
|
9
|
-
defineEmits
|
|
13
|
+
defineEmits<{
|
|
14
|
+
(e: 'toggle-sidebar'): void
|
|
15
|
+
}>()
|
|
16
|
+
|
|
17
|
+
defineSlots<{
|
|
18
|
+
before?: (props: Record<never, never>) => any
|
|
19
|
+
after?: (props: Record<never, never>) => any
|
|
20
|
+
}>()
|
|
10
21
|
|
|
11
22
|
const themeLocale = useThemeLocaleData()
|
|
12
23
|
|
|
@@ -23,16 +34,14 @@ const linksWrapperStyle = computed(() => {
|
|
|
23
34
|
}
|
|
24
35
|
})
|
|
25
36
|
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
const handleLinksWrapWidth = (): void => {
|
|
35
|
-
if (window.innerWidth < MOBILE_DESKTOP_BREAKPOINT) {
|
|
37
|
+
useUpdateDeviceStatus(
|
|
38
|
+
DeviceType.MOBILE,
|
|
39
|
+
(mobileDesktopBreakpoint: number): void => {
|
|
40
|
+
// avoid overlapping of long title and long navbar links
|
|
41
|
+
const navbarHorizontalPadding =
|
|
42
|
+
getCssValue(navbar.value, 'paddingLeft') +
|
|
43
|
+
getCssValue(navbar.value, 'paddingRight')
|
|
44
|
+
if (window.innerWidth < mobileDesktopBreakpoint) {
|
|
36
45
|
linksWrapperMaxWidth.value = 0
|
|
37
46
|
} else {
|
|
38
47
|
linksWrapperMaxWidth.value =
|
|
@@ -41,10 +50,7 @@ onMounted(() => {
|
|
|
41
50
|
(navbarBrand.value?.offsetWidth || 0)
|
|
42
51
|
}
|
|
43
52
|
}
|
|
44
|
-
|
|
45
|
-
window.addEventListener('resize', handleLinksWrapWidth, false)
|
|
46
|
-
window.addEventListener('orientationchange', handleLinksWrapWidth, false)
|
|
47
|
-
})
|
|
53
|
+
)
|
|
48
54
|
|
|
49
55
|
function getCssValue(el: HTMLElement | null, property: string): number {
|
|
50
56
|
// NOTE: Known bug, will return 'auto' if style value is 'auto'
|
|
@@ -1,9 +1,13 @@
|
|
|
1
1
|
<script setup lang="ts">
|
|
2
2
|
import AutoLink from '@theme/AutoLink.vue'
|
|
3
3
|
import NavbarDropdown from '@theme/NavbarDropdown.vue'
|
|
4
|
-
import {
|
|
4
|
+
import {
|
|
5
|
+
useRouteLocale,
|
|
6
|
+
useSiteData,
|
|
7
|
+
useSiteLocaleData,
|
|
8
|
+
} from '@vuepress/client'
|
|
5
9
|
import { isLinkHttp, isString } from '@vuepress/shared'
|
|
6
|
-
import { computed,
|
|
10
|
+
import { computed, ref } from 'vue'
|
|
7
11
|
import type { ComputedRef } from 'vue'
|
|
8
12
|
import { useRouter } from 'vue-router'
|
|
9
13
|
import type {
|
|
@@ -11,7 +15,13 @@ import type {
|
|
|
11
15
|
NavbarItem,
|
|
12
16
|
ResolvedNavbarItem,
|
|
13
17
|
} from '../../shared/index.js'
|
|
14
|
-
import {
|
|
18
|
+
import {
|
|
19
|
+
DeviceType,
|
|
20
|
+
useNavLink,
|
|
21
|
+
useThemeData,
|
|
22
|
+
useThemeLocaleData,
|
|
23
|
+
useUpdateDeviceStatus,
|
|
24
|
+
} from '../composables/index.js'
|
|
15
25
|
import { resolveRepoType } from '../utils/index.js'
|
|
16
26
|
|
|
17
27
|
/**
|
|
@@ -20,11 +30,13 @@ import { resolveRepoType } from '../utils/index.js'
|
|
|
20
30
|
const useNavbarSelectLanguage = (): ComputedRef<ResolvedNavbarItem[]> => {
|
|
21
31
|
const router = useRouter()
|
|
22
32
|
const routeLocale = useRouteLocale()
|
|
33
|
+
const site = useSiteData()
|
|
23
34
|
const siteLocale = useSiteLocaleData()
|
|
35
|
+
const theme = useThemeData()
|
|
24
36
|
const themeLocale = useThemeLocaleData()
|
|
25
37
|
|
|
26
38
|
return computed<ResolvedNavbarItem[]>(() => {
|
|
27
|
-
const localePaths = Object.keys(
|
|
39
|
+
const localePaths = Object.keys(site.value.locales)
|
|
28
40
|
// do not display language selection dropdown if there is only one language
|
|
29
41
|
if (localePaths.length < 2) {
|
|
30
42
|
return []
|
|
@@ -33,17 +45,15 @@ const useNavbarSelectLanguage = (): ComputedRef<ResolvedNavbarItem[]> => {
|
|
|
33
45
|
const currentFullPath = router.currentRoute.value.fullPath
|
|
34
46
|
|
|
35
47
|
const languageDropdown: ResolvedNavbarItem = {
|
|
36
|
-
text: themeLocale.value.selectLanguageText
|
|
37
|
-
ariaLabel:
|
|
48
|
+
text: `${themeLocale.value.selectLanguageText}`,
|
|
49
|
+
ariaLabel: `${
|
|
38
50
|
themeLocale.value.selectLanguageAriaLabel ??
|
|
39
|
-
themeLocale.value.selectLanguageText
|
|
40
|
-
|
|
51
|
+
themeLocale.value.selectLanguageText
|
|
52
|
+
}`,
|
|
41
53
|
children: localePaths.map((targetLocalePath) => {
|
|
42
54
|
// target locale config of this language link
|
|
43
|
-
const targetSiteLocale =
|
|
44
|
-
|
|
45
|
-
const targetThemeLocale =
|
|
46
|
-
themeLocale.value.locales?.[targetLocalePath] ?? {}
|
|
55
|
+
const targetSiteLocale = site.value.locales?.[targetLocalePath] ?? {}
|
|
56
|
+
const targetThemeLocale = theme.value.locales?.[targetLocalePath] ?? {}
|
|
47
57
|
const targetLang = `${targetSiteLocale.lang}`
|
|
48
58
|
|
|
49
59
|
const text = targetThemeLocale.selectLanguageName ?? targetLang
|
|
@@ -152,23 +162,17 @@ const navbarLinks = computed(() => [
|
|
|
152
162
|
...navbarRepo.value,
|
|
153
163
|
])
|
|
154
164
|
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
const handleMobile = (): void => {
|
|
162
|
-
if (window.innerWidth < MOBILE_DESKTOP_BREAKPOINT) {
|
|
165
|
+
useUpdateDeviceStatus(
|
|
166
|
+
DeviceType.MOBILE,
|
|
167
|
+
(mobileDesktopBreakpoint: number): void => {
|
|
168
|
+
// avoid overlapping of long title and long navbar links
|
|
169
|
+
if (window.innerWidth < mobileDesktopBreakpoint) {
|
|
163
170
|
isMobile.value = true
|
|
164
171
|
} else {
|
|
165
172
|
isMobile.value = false
|
|
166
173
|
}
|
|
167
174
|
}
|
|
168
|
-
|
|
169
|
-
window.addEventListener('resize', handleMobile, false)
|
|
170
|
-
window.addEventListener('orientationchange', handleMobile, false)
|
|
171
|
-
})
|
|
175
|
+
)
|
|
172
176
|
</script>
|
|
173
177
|
|
|
174
178
|
<template>
|
|
@@ -1,6 +1,13 @@
|
|
|
1
1
|
<script setup lang="ts">
|
|
2
2
|
import PageMeta from '@theme/PageMeta.vue'
|
|
3
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
|
+
}>()
|
|
4
11
|
</script>
|
|
5
12
|
|
|
6
13
|
<template>
|
|
@@ -1,6 +1,11 @@
|
|
|
1
1
|
<script setup lang="ts">
|
|
2
2
|
import NavbarItems from '@theme/NavbarItems.vue'
|
|
3
3
|
import SidebarItems from '@theme/SidebarItems.vue'
|
|
4
|
+
|
|
5
|
+
defineSlots<{
|
|
6
|
+
top?: (props: Record<never, never>) => any
|
|
7
|
+
bottom?: (props: Record<never, never>) => any
|
|
8
|
+
}>()
|
|
4
9
|
</script>
|
|
5
10
|
|
|
6
11
|
<template>
|
|
@@ -1,4 +1,6 @@
|
|
|
1
|
-
import type { VNode } from 'vue';
|
|
1
|
+
import type { SlotsType, VNode } from 'vue';
|
|
2
2
|
export declare const CodeGroup: import("vue").DefineComponent<{}, () => VNode<import("vue").RendererNode, import("vue").RendererElement, {
|
|
3
3
|
[key: string]: any;
|
|
4
|
-
}> | null, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, Readonly<import("vue").ExtractPropTypes<{}>>, {}
|
|
4
|
+
}> | null, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, Readonly<import("vue").ExtractPropTypes<{}>>, {}, SlotsType<{
|
|
5
|
+
default: () => VNode[];
|
|
6
|
+
}>>;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { onMounted } from 'vue';
|
|
2
|
+
import cssVars from '../styles/_variables.module.scss?module';
|
|
3
|
+
export var DeviceType;
|
|
4
|
+
(function (DeviceType) {
|
|
5
|
+
DeviceType["MOBILE"] = "mobile";
|
|
6
|
+
})(DeviceType || (DeviceType = {}));
|
|
7
|
+
const DeviceTypeMap = {
|
|
8
|
+
[DeviceType.MOBILE]: Number.parseInt(cssVars.mobile?.replace('px', ''), 10),
|
|
9
|
+
};
|
|
10
|
+
/**
|
|
11
|
+
* add listener to detect screen though device type
|
|
12
|
+
*/
|
|
13
|
+
export const useUpdateDeviceStatus = (deviceType, callback) => {
|
|
14
|
+
const width = DeviceTypeMap[deviceType];
|
|
15
|
+
if (!Number.isInteger(width)) {
|
|
16
|
+
if (__VUEPRESS_DEV__)
|
|
17
|
+
throw new Error('device width must be a integer');
|
|
18
|
+
return;
|
|
19
|
+
}
|
|
20
|
+
onMounted(() => {
|
|
21
|
+
callback(width);
|
|
22
|
+
window.addEventListener('resize', () => callback(width), false);
|
|
23
|
+
window.addEventListener('orientationchange', () => callback(width), false);
|
|
24
|
+
});
|
|
25
|
+
};
|
|
@@ -13,6 +13,20 @@ import {
|
|
|
13
13
|
useThemeLocaleData,
|
|
14
14
|
} from '../composables/index.js'
|
|
15
15
|
|
|
16
|
+
defineSlots<{
|
|
17
|
+
'navbar'?: (props: Record<never, never>) => any
|
|
18
|
+
'navbar-before'?: (props: Record<never, never>) => any
|
|
19
|
+
'navbar-after'?: (props: Record<never, never>) => any
|
|
20
|
+
'sidebar'?: (props: Record<never, never>) => any
|
|
21
|
+
'sidebar-top'?: (props: Record<never, never>) => any
|
|
22
|
+
'sidebar-bottom'?: (props: Record<never, never>) => any
|
|
23
|
+
'page'?: (props: Record<never, never>) => any
|
|
24
|
+
'page-top'?: (props: Record<never, never>) => any
|
|
25
|
+
'page-bottom'?: (props: Record<never, never>) => any
|
|
26
|
+
'page-content-top'?: (props: Record<never, never>) => any
|
|
27
|
+
'page-content-bottom'?: (props: Record<never, never>) => any
|
|
28
|
+
}>()
|
|
29
|
+
|
|
16
30
|
const page = usePageData()
|
|
17
31
|
const frontmatter = usePageFrontmatter<DefaultThemePageFrontmatter>()
|
|
18
32
|
const themeLocale = useThemeLocaleData()
|
package/lib/client/shim.d.ts
CHANGED
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.63",
|
|
4
4
|
"description": "Default theme of VuePress",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"vuepress-theme",
|
|
@@ -36,27 +36,28 @@
|
|
|
36
36
|
"templates"
|
|
37
37
|
],
|
|
38
38
|
"dependencies": {
|
|
39
|
-
"@vueuse/core": "^
|
|
40
|
-
"sass": "^1.
|
|
41
|
-
"
|
|
42
|
-
"vue
|
|
43
|
-
"
|
|
44
|
-
"@vuepress/
|
|
45
|
-
"@vuepress/plugin-
|
|
46
|
-
"@vuepress/plugin-
|
|
47
|
-
"@vuepress/plugin-
|
|
48
|
-
"@vuepress/plugin-external-link-icon": "2.0.0-beta.
|
|
49
|
-
"@vuepress/plugin-
|
|
50
|
-
"@vuepress/plugin-
|
|
51
|
-
"@vuepress/plugin-nprogress": "2.0.0-beta.
|
|
52
|
-
"@vuepress/
|
|
53
|
-
"@vuepress/plugin-
|
|
54
|
-
"@vuepress/
|
|
55
|
-
"@vuepress/
|
|
56
|
-
"@vuepress/
|
|
39
|
+
"@vueuse/core": "^10.1.2",
|
|
40
|
+
"sass": "^1.63.2",
|
|
41
|
+
"sass-loader": "^13.3.1",
|
|
42
|
+
"vue": "^3.3.4",
|
|
43
|
+
"vue-router": "^4.2.2",
|
|
44
|
+
"@vuepress/client": "2.0.0-beta.63",
|
|
45
|
+
"@vuepress/plugin-back-to-top": "2.0.0-beta.63",
|
|
46
|
+
"@vuepress/plugin-active-header-links": "2.0.0-beta.63",
|
|
47
|
+
"@vuepress/plugin-container": "2.0.0-beta.63",
|
|
48
|
+
"@vuepress/plugin-external-link-icon": "2.0.0-beta.63",
|
|
49
|
+
"@vuepress/plugin-medium-zoom": "2.0.0-beta.63",
|
|
50
|
+
"@vuepress/plugin-git": "2.0.0-beta.63",
|
|
51
|
+
"@vuepress/plugin-nprogress": "2.0.0-beta.63",
|
|
52
|
+
"@vuepress/core": "2.0.0-beta.63",
|
|
53
|
+
"@vuepress/plugin-palette": "2.0.0-beta.63",
|
|
54
|
+
"@vuepress/plugin-prismjs": "2.0.0-beta.63",
|
|
55
|
+
"@vuepress/utils": "2.0.0-beta.63",
|
|
56
|
+
"@vuepress/plugin-theme-data": "2.0.0-beta.63",
|
|
57
|
+
"@vuepress/shared": "2.0.0-beta.63"
|
|
57
58
|
},
|
|
58
59
|
"peerDependencies": {
|
|
59
|
-
"sass-loader": "^13.2.
|
|
60
|
+
"sass-loader": "^13.2.1"
|
|
60
61
|
},
|
|
61
62
|
"peerDependenciesMeta": {
|
|
62
63
|
"sass-loader": {
|