@vuepress/theme-default 2.0.0-beta.29 → 2.0.0-beta.33
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/{NavLink.vue → AutoLink.vue} +28 -29
- package/lib/client/components/DropdownTransition.vue +11 -11
- package/lib/client/components/Home.vue +12 -110
- 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 +97 -0
- package/lib/client/components/Navbar.vue +26 -60
- package/lib/client/components/NavbarBrand.vue +55 -0
- package/lib/client/components/{DropdownLink.vue → NavbarDropdown.vue} +64 -64
- package/lib/client/components/{NavbarLinks.vue → NavbarItems.vue} +12 -13
- package/lib/client/components/Page.vue +5 -5
- package/lib/client/components/PageMeta.vue +33 -34
- package/lib/client/components/PageNav.vue +20 -20
- package/lib/client/components/Sidebar.vue +7 -19
- package/lib/client/components/SidebarItem.vue +74 -0
- package/lib/client/components/SidebarItems.vue +16 -0
- package/lib/client/components/ToggleDarkModeButton.vue +11 -11
- package/lib/client/components/ToggleSidebarButton.vue +8 -8
- package/lib/client/components/global/Badge.vue +12 -12
- package/lib/client/components/global/CodeGroupItem.vue +10 -10
- package/lib/client/components/global/ExternalLinkIcon.vue +6 -6
- package/lib/client/index.d.ts +2 -2
- package/lib/client/layouts/404.vue +12 -12
- package/lib/client/layouts/Layout.vue +58 -58
- package/lib/client/styles/{_wrapper.scss → _mixins.scss} +6 -1
- package/lib/client/styles/code.scss +2 -1
- package/lib/client/styles/index.scss +1 -1
- package/lib/client/styles/layout.scss +2 -2
- package/lib/client/styles/{dropdown.scss → navbar-dropdown.scss} +25 -33
- package/lib/client/styles/navbar.scss +8 -8
- package/lib/client/styles/normalize.scss +4 -0
- package/lib/client/styles/page.scss +5 -5
- package/lib/client/styles/sidebar.scss +67 -70
- package/lib/client/styles/transitions.scss +11 -2
- package/lib/client/utils/index.d.ts +1 -0
- package/lib/client/utils/index.js +1 -0
- package/lib/client/utils/isActiveSidebarItem.d.ts +3 -0
- package/lib/client/utils/isActiveSidebarItem.js +20 -0
- package/lib/node/defaultTheme.js +9 -0
- package/lib/shared/nav.d.ts +10 -4
- package/package.json +21 -20
- package/templates/index.build.html +33 -0
- package/lib/client/components/SidebarChild.d.ts +0 -6
- package/lib/client/components/SidebarChild.js +0 -76
|
@@ -1,7 +1,58 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
import AutoLink from '@theme/AutoLink.vue'
|
|
3
|
+
import DropdownTransition from '@theme/DropdownTransition.vue'
|
|
4
|
+
import { computed, ref, toRefs, watch } from 'vue'
|
|
5
|
+
import type { PropType } from 'vue'
|
|
6
|
+
import { useRoute } from 'vue-router'
|
|
7
|
+
import type { NavbarItem, ResolvedNavbarItem } from '../../shared'
|
|
8
|
+
|
|
9
|
+
const props = defineProps({
|
|
10
|
+
item: {
|
|
11
|
+
type: Object as PropType<Exclude<ResolvedNavbarItem, NavbarItem>>,
|
|
12
|
+
required: true,
|
|
13
|
+
},
|
|
14
|
+
})
|
|
15
|
+
|
|
16
|
+
const { item } = toRefs(props)
|
|
17
|
+
|
|
18
|
+
const dropdownAriaLabel = computed(
|
|
19
|
+
() => item.value.ariaLabel || item.value.text
|
|
20
|
+
)
|
|
21
|
+
|
|
22
|
+
const open = ref(false)
|
|
23
|
+
const route = useRoute()
|
|
24
|
+
watch(
|
|
25
|
+
() => route.path,
|
|
26
|
+
() => {
|
|
27
|
+
open.value = false
|
|
28
|
+
}
|
|
29
|
+
)
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* Open the dropdown when user tab and click from keyboard.
|
|
33
|
+
*
|
|
34
|
+
* Use event.detail to detect tab and click from keyboard.
|
|
35
|
+
* The Tab + Click is UIEvent > KeyboardEvent, so the detail is 0.
|
|
36
|
+
*
|
|
37
|
+
* @see https://developer.mozilla.org/en-US/docs/Web/API/UIEvent/detail
|
|
38
|
+
*/
|
|
39
|
+
const handleDropdown = (e): void => {
|
|
40
|
+
const isTriggerByTab = e.detail === 0
|
|
41
|
+
if (isTriggerByTab) {
|
|
42
|
+
open.value = !open.value
|
|
43
|
+
} else {
|
|
44
|
+
open.value = false
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
const isLastItemOfArray = (item: unknown, arr: unknown[]): boolean =>
|
|
49
|
+
arr[arr.length - 1] === item
|
|
50
|
+
</script>
|
|
51
|
+
|
|
1
52
|
<template>
|
|
2
|
-
<div class="dropdown-wrapper" :class="{ open }">
|
|
53
|
+
<div class="navbar-dropdown-wrapper" :class="{ open }">
|
|
3
54
|
<button
|
|
4
|
-
class="dropdown-title"
|
|
55
|
+
class="navbar-dropdown-title"
|
|
5
56
|
type="button"
|
|
6
57
|
:aria-label="dropdownAriaLabel"
|
|
7
58
|
@click="handleDropdown"
|
|
@@ -11,7 +62,7 @@
|
|
|
11
62
|
</button>
|
|
12
63
|
|
|
13
64
|
<button
|
|
14
|
-
class="
|
|
65
|
+
class="navbar-dropdown-title-mobile"
|
|
15
66
|
type="button"
|
|
16
67
|
:aria-label="dropdownAriaLabel"
|
|
17
68
|
@click="open = !open"
|
|
@@ -21,15 +72,15 @@
|
|
|
21
72
|
</button>
|
|
22
73
|
|
|
23
74
|
<DropdownTransition>
|
|
24
|
-
<ul v-show="open" class="
|
|
75
|
+
<ul v-show="open" class="navbar-dropdown">
|
|
25
76
|
<li
|
|
26
|
-
v-for="
|
|
27
|
-
:key="child.
|
|
28
|
-
class="dropdown-item"
|
|
77
|
+
v-for="child in item.children"
|
|
78
|
+
:key="child.text"
|
|
79
|
+
class="navbar-dropdown-item"
|
|
29
80
|
>
|
|
30
81
|
<template v-if="child.children">
|
|
31
|
-
<h4 class="dropdown-subtitle">
|
|
32
|
-
<
|
|
82
|
+
<h4 class="navbar-dropdown-subtitle">
|
|
83
|
+
<AutoLink
|
|
33
84
|
v-if="child.link"
|
|
34
85
|
:item="child"
|
|
35
86
|
@focusout="
|
|
@@ -42,13 +93,13 @@
|
|
|
42
93
|
<span v-else>{{ child.text }}</span>
|
|
43
94
|
</h4>
|
|
44
95
|
|
|
45
|
-
<ul class="dropdown-subitem-wrapper">
|
|
96
|
+
<ul class="navbar-dropdown-subitem-wrapper">
|
|
46
97
|
<li
|
|
47
98
|
v-for="grandchild in child.children"
|
|
48
99
|
:key="grandchild.link"
|
|
49
|
-
class="dropdown-subitem"
|
|
100
|
+
class="navbar-dropdown-subitem"
|
|
50
101
|
>
|
|
51
|
-
<
|
|
102
|
+
<AutoLink
|
|
52
103
|
:item="grandchild"
|
|
53
104
|
@focusout="
|
|
54
105
|
isLastItemOfArray(grandchild, child.children) &&
|
|
@@ -61,7 +112,7 @@
|
|
|
61
112
|
</template>
|
|
62
113
|
|
|
63
114
|
<template v-else>
|
|
64
|
-
<
|
|
115
|
+
<AutoLink
|
|
65
116
|
:item="child"
|
|
66
117
|
@focusout="
|
|
67
118
|
isLastItemOfArray(child, item.children) && (open = false)
|
|
@@ -73,54 +124,3 @@
|
|
|
73
124
|
</DropdownTransition>
|
|
74
125
|
</div>
|
|
75
126
|
</template>
|
|
76
|
-
|
|
77
|
-
<script setup lang="ts">
|
|
78
|
-
import { computed, ref, toRefs, watch } from 'vue'
|
|
79
|
-
import type { PropType } from 'vue'
|
|
80
|
-
import { useRoute } from 'vue-router'
|
|
81
|
-
import type { NavGroup, NavItem } from '../../shared'
|
|
82
|
-
import DropdownTransition from './DropdownTransition.vue'
|
|
83
|
-
import NavLink from './NavLink.vue'
|
|
84
|
-
|
|
85
|
-
const props = defineProps({
|
|
86
|
-
item: {
|
|
87
|
-
type: Object as PropType<NavGroup<NavItem>>,
|
|
88
|
-
required: true,
|
|
89
|
-
},
|
|
90
|
-
})
|
|
91
|
-
|
|
92
|
-
const { item } = toRefs(props)
|
|
93
|
-
|
|
94
|
-
const dropdownAriaLabel = computed(
|
|
95
|
-
() => item.value.ariaLabel || item.value.text
|
|
96
|
-
)
|
|
97
|
-
|
|
98
|
-
const open = ref(false)
|
|
99
|
-
const route = useRoute()
|
|
100
|
-
watch(
|
|
101
|
-
() => route.path,
|
|
102
|
-
() => {
|
|
103
|
-
open.value = false
|
|
104
|
-
}
|
|
105
|
-
)
|
|
106
|
-
|
|
107
|
-
/**
|
|
108
|
-
* Open the dropdown when user tab and click from keyboard.
|
|
109
|
-
*
|
|
110
|
-
* Use event.detail to detect tab and click from keyboard.
|
|
111
|
-
* The Tab + Click is UIEvent > KeyboardEvent, so the detail is 0.
|
|
112
|
-
*
|
|
113
|
-
* @see https://developer.mozilla.org/en-US/docs/Web/API/UIEvent/detail
|
|
114
|
-
*/
|
|
115
|
-
const handleDropdown = (e): void => {
|
|
116
|
-
const isTriggerByTab = e.detail === 0
|
|
117
|
-
if (isTriggerByTab) {
|
|
118
|
-
open.value = !open.value
|
|
119
|
-
} else {
|
|
120
|
-
open.value = false
|
|
121
|
-
}
|
|
122
|
-
}
|
|
123
|
-
|
|
124
|
-
const isLastItemOfArray = (item: unknown, arr: unknown[]): boolean =>
|
|
125
|
-
arr[arr.length - 1] === item
|
|
126
|
-
</script>
|
|
@@ -1,14 +1,6 @@
|
|
|
1
|
-
<template>
|
|
2
|
-
<nav v-if="navbarLinks.length" class="navbar-links">
|
|
3
|
-
<div v-for="item in navbarLinks" :key="item.text" class="navbar-links-item">
|
|
4
|
-
<DropdownLink v-if="item.children" :item="item" />
|
|
5
|
-
|
|
6
|
-
<NavLink v-else :item="item" />
|
|
7
|
-
</div>
|
|
8
|
-
</nav>
|
|
9
|
-
</template>
|
|
10
|
-
|
|
11
1
|
<script setup lang="ts">
|
|
2
|
+
import AutoLink from '@theme/AutoLink.vue'
|
|
3
|
+
import NavbarDropdown from '@theme/NavbarDropdown.vue'
|
|
12
4
|
import { useRouteLocale, useSiteLocaleData } from '@vuepress/client'
|
|
13
5
|
import { isLinkHttp, isString } from '@vuepress/shared'
|
|
14
6
|
import { computed } from 'vue'
|
|
@@ -17,8 +9,6 @@ import { useRouter } from 'vue-router'
|
|
|
17
9
|
import type { NavbarGroup, NavbarItem, ResolvedNavbarItem } from '../../shared'
|
|
18
10
|
import { useNavLink, useThemeLocaleData } from '../composables'
|
|
19
11
|
import { resolveRepoType } from '../utils'
|
|
20
|
-
import DropdownLink from './DropdownLink.vue'
|
|
21
|
-
import NavLink from './NavLink.vue'
|
|
22
12
|
|
|
23
13
|
/**
|
|
24
14
|
* Get navbar config of select language dropdown
|
|
@@ -39,7 +29,7 @@ const useNavbarSelectLanguage = (): ComputedRef<ResolvedNavbarItem[]> => {
|
|
|
39
29
|
const currentFullPath = router.currentRoute.value.fullPath
|
|
40
30
|
|
|
41
31
|
const languageDropdown: ResolvedNavbarItem = {
|
|
42
|
-
text: themeLocale.value.selectLanguageText ?? '
|
|
32
|
+
text: themeLocale.value.selectLanguageText ?? 'unknown language',
|
|
43
33
|
ariaLabel: themeLocale.value.selectLanguageAriaLabel ?? 'unkown language',
|
|
44
34
|
children: localePaths.map((targetLocalePath) => {
|
|
45
35
|
// target locale config of this langauge link
|
|
@@ -153,3 +143,12 @@ const navbarLinks = computed(() => [
|
|
|
153
143
|
...navbarRepo.value,
|
|
154
144
|
])
|
|
155
145
|
</script>
|
|
146
|
+
|
|
147
|
+
<template>
|
|
148
|
+
<nav v-if="navbarLinks.length" class="navbar-items">
|
|
149
|
+
<div v-for="item in navbarLinks" :key="item.text" class="navbar-item">
|
|
150
|
+
<NavbarDropdown v-if="item.children" :item="item" />
|
|
151
|
+
<AutoLink v-else :item="item" />
|
|
152
|
+
</div>
|
|
153
|
+
</nav>
|
|
154
|
+
</template>
|
|
@@ -1,3 +1,8 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
import PageMeta from '@theme/PageMeta.vue'
|
|
3
|
+
import PageNav from '@theme/PageNav.vue'
|
|
4
|
+
</script>
|
|
5
|
+
|
|
1
6
|
<template>
|
|
2
7
|
<main class="page">
|
|
3
8
|
<slot name="top" />
|
|
@@ -13,8 +18,3 @@
|
|
|
13
18
|
<slot name="bottom" />
|
|
14
19
|
</main>
|
|
15
20
|
</template>
|
|
16
|
-
|
|
17
|
-
<script setup lang="ts">
|
|
18
|
-
import PageMeta from './PageMeta.vue'
|
|
19
|
-
import PageNav from './PageNav.vue'
|
|
20
|
-
</script>
|
|
@@ -1,34 +1,5 @@
|
|
|
1
|
-
<template>
|
|
2
|
-
<footer class="page-meta">
|
|
3
|
-
<div v-if="editNavLink" class="meta-item edit-link">
|
|
4
|
-
<NavLink class="meta-item-label" :item="editNavLink" />
|
|
5
|
-
</div>
|
|
6
|
-
|
|
7
|
-
<div v-if="lastUpdated" class="meta-item last-updated">
|
|
8
|
-
<span class="meta-item-label">{{ themeLocale.lastUpdatedText }}: </span>
|
|
9
|
-
<ClientOnly>
|
|
10
|
-
<span class="meta-item-info">{{ lastUpdated }}</span>
|
|
11
|
-
</ClientOnly>
|
|
12
|
-
</div>
|
|
13
|
-
|
|
14
|
-
<div
|
|
15
|
-
v-if="contributors && contributors.length"
|
|
16
|
-
class="meta-item contributors"
|
|
17
|
-
>
|
|
18
|
-
<span class="meta-item-label">{{ themeLocale.contributorsText }}: </span>
|
|
19
|
-
<span class="meta-item-info">
|
|
20
|
-
<template v-for="(contributor, index) in contributors" :key="index">
|
|
21
|
-
<span class="contributor" :title="`email: ${contributor.email}`">
|
|
22
|
-
{{ contributor.name }}
|
|
23
|
-
</span>
|
|
24
|
-
<template v-if="index !== contributors.length - 1">, </template>
|
|
25
|
-
</template>
|
|
26
|
-
</span>
|
|
27
|
-
</div>
|
|
28
|
-
</footer>
|
|
29
|
-
</template>
|
|
30
|
-
|
|
31
1
|
<script setup lang="ts">
|
|
2
|
+
import AutoLink from '@theme/AutoLink.vue'
|
|
32
3
|
import {
|
|
33
4
|
usePageData,
|
|
34
5
|
usePageFrontmatter,
|
|
@@ -39,13 +10,12 @@ import type { ComputedRef } from 'vue'
|
|
|
39
10
|
import type {
|
|
40
11
|
DefaultThemeNormalPageFrontmatter,
|
|
41
12
|
DefaultThemePageData,
|
|
42
|
-
NavLink
|
|
13
|
+
NavLink,
|
|
43
14
|
} from '../../shared'
|
|
44
15
|
import { useThemeLocaleData } from '../composables'
|
|
45
16
|
import { resolveEditLink } from '../utils'
|
|
46
|
-
import NavLink from './NavLink.vue'
|
|
47
17
|
|
|
48
|
-
const useEditNavLink = (): ComputedRef<null |
|
|
18
|
+
const useEditNavLink = (): ComputedRef<null | NavLink> => {
|
|
49
19
|
const themeLocale = useThemeLocaleData()
|
|
50
20
|
const page = usePageData<DefaultThemePageData>()
|
|
51
21
|
const frontmatter = usePageFrontmatter<DefaultThemeNormalPageFrontmatter>()
|
|
@@ -86,7 +56,6 @@ const useEditNavLink = (): ComputedRef<null | NavLinkType> => {
|
|
|
86
56
|
}
|
|
87
57
|
|
|
88
58
|
const useLastUpdated = (): ComputedRef<null | string> => {
|
|
89
|
-
const siteLocale = useSiteLocaleData()
|
|
90
59
|
const themeLocale = useThemeLocaleData()
|
|
91
60
|
const page = usePageData<DefaultThemePageData>()
|
|
92
61
|
const frontmatter = usePageFrontmatter<DefaultThemeNormalPageFrontmatter>()
|
|
@@ -127,3 +96,33 @@ const editNavLink = useEditNavLink()
|
|
|
127
96
|
const lastUpdated = useLastUpdated()
|
|
128
97
|
const contributors = useContributors()
|
|
129
98
|
</script>
|
|
99
|
+
|
|
100
|
+
<template>
|
|
101
|
+
<footer class="page-meta">
|
|
102
|
+
<div v-if="editNavLink" class="meta-item edit-link">
|
|
103
|
+
<AutoLink class="meta-item-label" :item="editNavLink" />
|
|
104
|
+
</div>
|
|
105
|
+
|
|
106
|
+
<div v-if="lastUpdated" class="meta-item last-updated">
|
|
107
|
+
<span class="meta-item-label">{{ themeLocale.lastUpdatedText }}: </span>
|
|
108
|
+
<ClientOnly>
|
|
109
|
+
<span class="meta-item-info">{{ lastUpdated }}</span>
|
|
110
|
+
</ClientOnly>
|
|
111
|
+
</div>
|
|
112
|
+
|
|
113
|
+
<div
|
|
114
|
+
v-if="contributors && contributors.length"
|
|
115
|
+
class="meta-item contributors"
|
|
116
|
+
>
|
|
117
|
+
<span class="meta-item-label">{{ themeLocale.contributorsText }}: </span>
|
|
118
|
+
<span class="meta-item-info">
|
|
119
|
+
<template v-for="(contributor, index) in contributors" :key="index">
|
|
120
|
+
<span class="contributor" :title="`email: ${contributor.email}`">
|
|
121
|
+
{{ contributor.name }}
|
|
122
|
+
</span>
|
|
123
|
+
<template v-if="index !== contributors.length - 1">, </template>
|
|
124
|
+
</template>
|
|
125
|
+
</span>
|
|
126
|
+
</div>
|
|
127
|
+
</footer>
|
|
128
|
+
</template>
|
|
@@ -1,36 +1,22 @@
|
|
|
1
|
-
<template>
|
|
2
|
-
<nav v-if="prevNavLink || nextNavLink" class="page-nav">
|
|
3
|
-
<p class="inner">
|
|
4
|
-
<span v-if="prevNavLink" class="prev">
|
|
5
|
-
<NavLink :item="prevNavLink" />
|
|
6
|
-
</span>
|
|
7
|
-
|
|
8
|
-
<span v-if="nextNavLink" class="next">
|
|
9
|
-
<NavLink :item="nextNavLink" />
|
|
10
|
-
</span>
|
|
11
|
-
</p>
|
|
12
|
-
</nav>
|
|
13
|
-
</template>
|
|
14
|
-
|
|
15
1
|
<script setup lang="ts">
|
|
2
|
+
import AutoLink from '@theme/AutoLink.vue'
|
|
16
3
|
import { usePageFrontmatter } from '@vuepress/client'
|
|
17
4
|
import { isPlainObject, isString } from '@vuepress/shared'
|
|
18
5
|
import { computed } from 'vue'
|
|
19
6
|
import { useRoute } from 'vue-router'
|
|
20
7
|
import type {
|
|
21
8
|
DefaultThemeNormalPageFrontmatter,
|
|
22
|
-
NavLink
|
|
9
|
+
NavLink,
|
|
23
10
|
ResolvedSidebarItem,
|
|
24
11
|
} from '../../shared'
|
|
25
12
|
import { useNavLink, useSidebarItems } from '../composables'
|
|
26
|
-
import NavLink from './NavLink.vue'
|
|
27
13
|
|
|
28
14
|
/**
|
|
29
15
|
* Resolve `prev` or `next` config from frontmatter
|
|
30
16
|
*/
|
|
31
17
|
const resolveFromFrontmatterConfig = (
|
|
32
18
|
conf: unknown
|
|
33
|
-
): null | false |
|
|
19
|
+
): null | false | NavLink => {
|
|
34
20
|
if (conf === false) {
|
|
35
21
|
return null
|
|
36
22
|
}
|
|
@@ -39,7 +25,7 @@ const resolveFromFrontmatterConfig = (
|
|
|
39
25
|
return useNavLink(conf)
|
|
40
26
|
}
|
|
41
27
|
|
|
42
|
-
if (isPlainObject<
|
|
28
|
+
if (isPlainObject<NavLink>(conf)) {
|
|
43
29
|
return conf
|
|
44
30
|
}
|
|
45
31
|
|
|
@@ -53,14 +39,14 @@ const resolveFromSidebarItems = (
|
|
|
53
39
|
sidebarItems: ResolvedSidebarItem[],
|
|
54
40
|
currentPath: string,
|
|
55
41
|
offset: number
|
|
56
|
-
): null |
|
|
42
|
+
): null | NavLink => {
|
|
57
43
|
const index = sidebarItems.findIndex((item) => item.link === currentPath)
|
|
58
44
|
if (index !== -1) {
|
|
59
45
|
const targetItem = sidebarItems[index + offset]
|
|
60
46
|
if (!targetItem?.link) {
|
|
61
47
|
return null
|
|
62
48
|
}
|
|
63
|
-
return targetItem as
|
|
49
|
+
return targetItem as NavLink
|
|
64
50
|
}
|
|
65
51
|
|
|
66
52
|
for (const item of sidebarItems) {
|
|
@@ -101,3 +87,17 @@ const nextNavLink = computed(() => {
|
|
|
101
87
|
return resolveFromSidebarItems(sidebarItems.value, route.path, 1)
|
|
102
88
|
})
|
|
103
89
|
</script>
|
|
90
|
+
|
|
91
|
+
<template>
|
|
92
|
+
<nav v-if="prevNavLink || nextNavLink" class="page-nav">
|
|
93
|
+
<p class="inner">
|
|
94
|
+
<span v-if="prevNavLink" class="prev">
|
|
95
|
+
<AutoLink :item="prevNavLink" />
|
|
96
|
+
</span>
|
|
97
|
+
|
|
98
|
+
<span v-if="nextNavLink" class="next">
|
|
99
|
+
<AutoLink :item="nextNavLink" />
|
|
100
|
+
</span>
|
|
101
|
+
</p>
|
|
102
|
+
</nav>
|
|
103
|
+
</template>
|
|
@@ -1,25 +1,13 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
import NavbarItems from '@theme/NavbarItems.vue'
|
|
3
|
+
import SidebarItems from '@theme/SidebarItems.vue'
|
|
4
|
+
</script>
|
|
5
|
+
|
|
1
6
|
<template>
|
|
2
7
|
<aside class="sidebar">
|
|
3
|
-
<
|
|
4
|
-
|
|
8
|
+
<NavbarItems />
|
|
5
9
|
<slot name="top" />
|
|
6
|
-
|
|
7
|
-
<ul class="sidebar-links">
|
|
8
|
-
<SidebarChild
|
|
9
|
-
v-for="item in sidebarItems"
|
|
10
|
-
:key="item.link || item.text"
|
|
11
|
-
:item="item"
|
|
12
|
-
/>
|
|
13
|
-
</ul>
|
|
14
|
-
|
|
10
|
+
<SidebarItems />
|
|
15
11
|
<slot name="bottom" />
|
|
16
12
|
</aside>
|
|
17
13
|
</template>
|
|
18
|
-
|
|
19
|
-
<script setup lang="ts">
|
|
20
|
-
import { useSidebarItems } from '../composables'
|
|
21
|
-
import NavbarLinks from './NavbarLinks.vue'
|
|
22
|
-
import { SidebarChild } from './SidebarChild'
|
|
23
|
-
|
|
24
|
-
const sidebarItems = useSidebarItems()
|
|
25
|
-
</script>
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
import AutoLink from '@theme/AutoLink.vue'
|
|
3
|
+
import DropdownTransition from '@theme/DropdownTransition.vue'
|
|
4
|
+
import { computed, ref, toRefs } from 'vue'
|
|
5
|
+
import type { PropType } from 'vue'
|
|
6
|
+
import { useRoute, useRouter } from 'vue-router'
|
|
7
|
+
import type { ResolvedSidebarItem } from '../../shared'
|
|
8
|
+
import { isActiveSidebarItem } from '../utils'
|
|
9
|
+
|
|
10
|
+
const props = defineProps({
|
|
11
|
+
item: {
|
|
12
|
+
type: Object as PropType<ResolvedSidebarItem>,
|
|
13
|
+
required: true,
|
|
14
|
+
},
|
|
15
|
+
depth: {
|
|
16
|
+
type: Number,
|
|
17
|
+
required: false,
|
|
18
|
+
default: 0,
|
|
19
|
+
},
|
|
20
|
+
})
|
|
21
|
+
|
|
22
|
+
const { item, depth } = toRefs(props)
|
|
23
|
+
const route = useRoute()
|
|
24
|
+
const router = useRouter()
|
|
25
|
+
|
|
26
|
+
const isActive = computed(() => isActiveSidebarItem(item.value, route))
|
|
27
|
+
const itemClass = computed(() => ({
|
|
28
|
+
'sidebar-item': true,
|
|
29
|
+
'sidebar-heading': depth.value === 0,
|
|
30
|
+
'active': isActive.value,
|
|
31
|
+
'collapsible': item.value.collapsible,
|
|
32
|
+
}))
|
|
33
|
+
|
|
34
|
+
const isOpen = ref(true)
|
|
35
|
+
const onClick = ref<(() => void) | undefined>(undefined)
|
|
36
|
+
|
|
37
|
+
if (item.value.collapsible) {
|
|
38
|
+
// active item is open by default
|
|
39
|
+
isOpen.value = isActive.value
|
|
40
|
+
// toggle open status on click
|
|
41
|
+
onClick.value = () => {
|
|
42
|
+
isOpen.value = !isOpen.value
|
|
43
|
+
}
|
|
44
|
+
// reset open status after navigation
|
|
45
|
+
router.afterEach(() => {
|
|
46
|
+
isOpen.value = isActive.value
|
|
47
|
+
})
|
|
48
|
+
}
|
|
49
|
+
</script>
|
|
50
|
+
|
|
51
|
+
<template>
|
|
52
|
+
<li>
|
|
53
|
+
<AutoLink v-if="item.link" :class="itemClass" :item="item" />
|
|
54
|
+
<p v-else :class="itemClass" @click="onClick">
|
|
55
|
+
{{ item.text }}
|
|
56
|
+
<span
|
|
57
|
+
v-if="item.collapsible"
|
|
58
|
+
class="arrow"
|
|
59
|
+
:class="isOpen ? 'down' : 'right'"
|
|
60
|
+
/>
|
|
61
|
+
</p>
|
|
62
|
+
|
|
63
|
+
<DropdownTransition v-if="item.children?.length">
|
|
64
|
+
<ul v-show="isOpen" class="sidebar-item-children">
|
|
65
|
+
<SidebarItem
|
|
66
|
+
v-for="child in item.children"
|
|
67
|
+
:key="`${depth}${child.text}${child.link}`"
|
|
68
|
+
:item="child"
|
|
69
|
+
:depth="depth + 1"
|
|
70
|
+
/>
|
|
71
|
+
</ul>
|
|
72
|
+
</DropdownTransition>
|
|
73
|
+
</li>
|
|
74
|
+
</template>
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
import SidebarItem from '@theme/SidebarItem.vue'
|
|
3
|
+
import { useSidebarItems } from '../composables'
|
|
4
|
+
|
|
5
|
+
const sidebarItems = useSidebarItems()
|
|
6
|
+
</script>
|
|
7
|
+
|
|
8
|
+
<template>
|
|
9
|
+
<ul v-if="sidebarItems.length" class="sidebar-items">
|
|
10
|
+
<SidebarItem
|
|
11
|
+
v-for="item in sidebarItems"
|
|
12
|
+
:key="item.link || item.text"
|
|
13
|
+
:item="item"
|
|
14
|
+
/>
|
|
15
|
+
</ul>
|
|
16
|
+
</template>
|
|
@@ -1,3 +1,14 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
import { useDarkMode, useThemeLocaleData } from '../composables'
|
|
3
|
+
|
|
4
|
+
const themeLocale = useThemeLocaleData()
|
|
5
|
+
const isDarkMode = useDarkMode()
|
|
6
|
+
|
|
7
|
+
const toggleDarkMode = (): void => {
|
|
8
|
+
isDarkMode.value = !isDarkMode.value
|
|
9
|
+
}
|
|
10
|
+
</script>
|
|
11
|
+
|
|
1
12
|
<template>
|
|
2
13
|
<button
|
|
3
14
|
class="toggle-dark-button"
|
|
@@ -44,14 +55,3 @@
|
|
|
44
55
|
</svg>
|
|
45
56
|
</button>
|
|
46
57
|
</template>
|
|
47
|
-
|
|
48
|
-
<script setup lang="ts">
|
|
49
|
-
import { useDarkMode, useThemeLocaleData } from '../composables'
|
|
50
|
-
|
|
51
|
-
const themeLocale = useThemeLocaleData()
|
|
52
|
-
const isDarkMode = useDarkMode()
|
|
53
|
-
|
|
54
|
-
const toggleDarkMode = (): void => {
|
|
55
|
-
isDarkMode.value = !isDarkMode.value
|
|
56
|
-
}
|
|
57
|
-
</script>
|
|
@@ -1,3 +1,11 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
import { useThemeLocaleData } from '../composables'
|
|
3
|
+
|
|
4
|
+
defineEmits(['toggle'])
|
|
5
|
+
|
|
6
|
+
const themeLocale = useThemeLocaleData()
|
|
7
|
+
</script>
|
|
8
|
+
|
|
1
9
|
<template>
|
|
2
10
|
<div
|
|
3
11
|
class="toggle-sidebar-button"
|
|
@@ -14,11 +22,3 @@
|
|
|
14
22
|
</div>
|
|
15
23
|
</div>
|
|
16
24
|
</template>
|
|
17
|
-
|
|
18
|
-
<script setup lang="ts">
|
|
19
|
-
import { useThemeLocaleData } from '../composables'
|
|
20
|
-
|
|
21
|
-
defineEmits(['toggle'])
|
|
22
|
-
|
|
23
|
-
const themeLocale = useThemeLocaleData()
|
|
24
|
-
</script>
|
|
@@ -1,15 +1,3 @@
|
|
|
1
|
-
<template>
|
|
2
|
-
<span
|
|
3
|
-
class="badge"
|
|
4
|
-
:class="type"
|
|
5
|
-
:style="{
|
|
6
|
-
verticalAlign: vertical,
|
|
7
|
-
}"
|
|
8
|
-
>
|
|
9
|
-
<slot>{{ text }}</slot>
|
|
10
|
-
</span>
|
|
11
|
-
</template>
|
|
12
|
-
|
|
13
1
|
<script setup lang="ts">
|
|
14
2
|
defineProps({
|
|
15
3
|
type: {
|
|
@@ -29,3 +17,15 @@ defineProps({
|
|
|
29
17
|
},
|
|
30
18
|
})
|
|
31
19
|
</script>
|
|
20
|
+
|
|
21
|
+
<template>
|
|
22
|
+
<span
|
|
23
|
+
class="badge"
|
|
24
|
+
:class="type"
|
|
25
|
+
:style="{
|
|
26
|
+
verticalAlign: vertical,
|
|
27
|
+
}"
|
|
28
|
+
>
|
|
29
|
+
<slot>{{ text }}</slot>
|
|
30
|
+
</span>
|
|
31
|
+
</template>
|
|
@@ -1,13 +1,3 @@
|
|
|
1
|
-
<template>
|
|
2
|
-
<div
|
|
3
|
-
class="code-group-item"
|
|
4
|
-
:class="{ 'code-group-item__active': active }"
|
|
5
|
-
:aria-selected="active"
|
|
6
|
-
>
|
|
7
|
-
<slot />
|
|
8
|
-
</div>
|
|
9
|
-
</template>
|
|
10
|
-
|
|
11
1
|
<script lang="ts">
|
|
12
2
|
import { defineComponent } from 'vue'
|
|
13
3
|
|
|
@@ -29,3 +19,13 @@ defineProps({
|
|
|
29
19
|
},
|
|
30
20
|
})
|
|
31
21
|
</script>
|
|
22
|
+
|
|
23
|
+
<template>
|
|
24
|
+
<div
|
|
25
|
+
class="code-group-item"
|
|
26
|
+
:class="{ 'code-group-item__active': active }"
|
|
27
|
+
:aria-selected="active"
|
|
28
|
+
>
|
|
29
|
+
<slot />
|
|
30
|
+
</div>
|
|
31
|
+
</template>
|
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
<template>
|
|
2
|
-
<RawExternalLinkIcon>
|
|
3
|
-
<span class="sr-only">{{ themeLocale.openInNewWindow }}</span>
|
|
4
|
-
</RawExternalLinkIcon>
|
|
5
|
-
</template>
|
|
6
|
-
|
|
7
1
|
<script setup lang="ts">
|
|
8
2
|
import { ExternalLinkIcon as RawExternalLinkIcon } from '@vuepress/plugin-external-link-icon/lib/client'
|
|
9
3
|
import { useThemeLocaleData } from '../../composables'
|
|
10
4
|
|
|
11
5
|
const themeLocale = useThemeLocaleData()
|
|
12
6
|
</script>
|
|
7
|
+
|
|
8
|
+
<template>
|
|
9
|
+
<RawExternalLinkIcon>
|
|
10
|
+
<span class="sr-only">{{ themeLocale.openInNewWindow }}</span>
|
|
11
|
+
</RawExternalLinkIcon>
|
|
12
|
+
</template>
|
package/lib/client/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { DefaultThemeData, DefaultThemeHomePageFrontmatter, DefaultThemeLocaleData, DefaultThemeLocaleOptions, DefaultThemeNormalPageFrontmatter, DefaultThemePageData, DefaultThemePageFrontmatter, DefaultThemePluginsOptions, NavbarConfig, NavbarGroup, NavbarItem, NavGroup, NavItem, NavLink, ResolvedNavbarItem, ResolvedSidebarItem, SidebarConfig, SidebarConfigArray, SidebarConfigObject, SidebarItem } from '../shared';
|
|
2
|
-
export type {
|
|
1
|
+
import type { DefaultThemeData, DefaultThemeHomePageFrontmatter, DefaultThemeLocaleData, DefaultThemeLocaleOptions, DefaultThemeNormalPageFrontmatter, DefaultThemePageData, DefaultThemePageFrontmatter, DefaultThemePluginsOptions, NavbarConfig, NavbarGroup, NavbarItem, NavGroup, NavItem, NavLink, ResolvedNavbarItem, ResolvedSidebarItem, SidebarConfig, SidebarConfigArray, SidebarConfigObject, SidebarGroup, SidebarGroupCollapsible, SidebarItem } from '../shared';
|
|
2
|
+
export type { DefaultThemeData, DefaultThemeHomePageFrontmatter, DefaultThemeLocaleData, DefaultThemeLocaleOptions, DefaultThemeNormalPageFrontmatter, DefaultThemePageData, DefaultThemePageFrontmatter, DefaultThemePluginsOptions, NavbarConfig, NavbarGroup, NavbarItem, NavGroup, NavItem, NavLink, ResolvedNavbarItem, ResolvedSidebarItem, SidebarConfig, SidebarConfigArray, SidebarConfigObject, SidebarGroup, SidebarGroupCollapsible, SidebarItem, };
|
|
3
3
|
export * from './composables';
|
|
4
4
|
export * from './utils';
|