@vuepress/theme-default 2.0.0-beta.30 → 2.0.0-beta.34
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/clientAppEnhance.js +0 -4
- package/lib/client/components/{NavLink.vue → AutoLink.vue} +1 -2
- package/lib/client/components/Home.vue +4 -4
- package/lib/client/components/HomeHero.vue +2 -2
- package/lib/client/components/Navbar.vue +6 -6
- package/lib/client/components/{DropdownLink.vue → NavbarDropdown.vue} +17 -17
- package/lib/client/components/{NavbarLinks.vue → NavbarItems.vue} +8 -14
- package/lib/client/components/Page.vue +2 -2
- package/lib/client/components/PageMeta.vue +4 -5
- package/lib/client/components/PageNav.vue +8 -8
- package/lib/client/components/Sidebar.vue +4 -16
- package/lib/client/components/SidebarItem.vue +80 -0
- package/lib/client/components/SidebarItems.vue +16 -0
- package/lib/client/index.d.ts +2 -2
- package/lib/client/layouts/Layout.vue +4 -4
- 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 -2
- 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 +12 -8
- package/lib/client/styles/normalize.scss +10 -2
- package/lib/client/styles/page.scss +3 -3
- package/lib/client/styles/sidebar.scss +70 -66
- 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 +13 -1
- package/lib/node/utils/index.d.ts +1 -0
- package/lib/node/utils/index.js +1 -0
- package/lib/node/utils/resolveExternalLinkIconPluginOptions.d.ts +6 -0
- package/lib/node/utils/resolveExternalLinkIconPluginOptions.js +21 -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
- package/lib/client/components/global/ExternalLinkIcon.vue +0 -12
- package/lib/client/styles/sr-only.scss +0 -12
|
@@ -3,16 +3,12 @@ import { h } from 'vue';
|
|
|
3
3
|
import Badge from './components/global/Badge.vue';
|
|
4
4
|
import CodeGroup from './components/global/CodeGroup';
|
|
5
5
|
import CodeGroupItem from './components/global/CodeGroupItem.vue';
|
|
6
|
-
import ExternalLinkIcon from './components/global/ExternalLinkIcon.vue';
|
|
7
6
|
import { useScrollPromise } from './composables';
|
|
8
7
|
import './styles/index.scss';
|
|
9
8
|
export default defineClientAppEnhance(({ app, router }) => {
|
|
10
9
|
app.component('Badge', Badge);
|
|
11
10
|
app.component('CodeGroup', CodeGroup);
|
|
12
11
|
app.component('CodeGroupItem', CodeGroupItem);
|
|
13
|
-
// override the `<ExternalLinkIcon>` provided by @vuepress/plugin-external-link-icon
|
|
14
|
-
delete app._context.components.ExternalLinkIcon;
|
|
15
|
-
app.component('ExternalLinkIcon', ExternalLinkIcon);
|
|
16
12
|
// compat with @vuepress/plugin-docsearch and @vuepress/plugin-search
|
|
17
13
|
app.component('NavbarSearch', () => {
|
|
18
14
|
const SearchComponent = app.component('Docsearch') || app.component('SearchBox');
|
|
@@ -87,7 +87,6 @@ const isActive = computed(() => {
|
|
|
87
87
|
<template>
|
|
88
88
|
<RouterLink
|
|
89
89
|
v-if="isRouterLink"
|
|
90
|
-
class="nav-link"
|
|
91
90
|
:class="{ 'router-link-active': isActive }"
|
|
92
91
|
:to="item.link"
|
|
93
92
|
:aria-label="linkAriaLabel"
|
|
@@ -99,7 +98,7 @@ const isActive = computed(() => {
|
|
|
99
98
|
</RouterLink>
|
|
100
99
|
<a
|
|
101
100
|
v-else
|
|
102
|
-
class="
|
|
101
|
+
class="external-link"
|
|
103
102
|
:href="item.link"
|
|
104
103
|
:rel="linkRel"
|
|
105
104
|
:target="linkTarget"
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
<script setup lang="ts">
|
|
2
|
-
import HomeContent from '
|
|
3
|
-
import HomeFeatures from '
|
|
4
|
-
import HomeFooter from '
|
|
5
|
-
import HomeHero from '
|
|
2
|
+
import HomeContent from '@theme/HomeContent.vue'
|
|
3
|
+
import HomeFeatures from '@theme/HomeFeatures.vue'
|
|
4
|
+
import HomeFooter from '@theme/HomeFooter.vue'
|
|
5
|
+
import HomeHero from '@theme/HomeHero.vue'
|
|
6
6
|
</script>
|
|
7
7
|
|
|
8
8
|
<template>
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
<script setup lang="ts">
|
|
2
|
+
import AutoLink from '@theme/AutoLink.vue'
|
|
2
3
|
import {
|
|
3
4
|
ClientOnly,
|
|
4
5
|
usePageFrontmatter,
|
|
@@ -10,7 +11,6 @@ import type { FunctionalComponent } from 'vue'
|
|
|
10
11
|
import { computed, h } from 'vue'
|
|
11
12
|
import type { DefaultThemeHomePageFrontmatter } from '../../shared'
|
|
12
13
|
import { useDarkMode } from '../composables'
|
|
13
|
-
import NavLink from './NavLink.vue'
|
|
14
14
|
|
|
15
15
|
const frontmatter = usePageFrontmatter<DefaultThemeHomePageFrontmatter>()
|
|
16
16
|
const siteLocale = useSiteLocaleData()
|
|
@@ -85,7 +85,7 @@ const HomeHeroImage: FunctionalComponent = () => {
|
|
|
85
85
|
</p>
|
|
86
86
|
|
|
87
87
|
<p v-if="actions.length" class="actions">
|
|
88
|
-
<
|
|
88
|
+
<AutoLink
|
|
89
89
|
v-for="action in actions"
|
|
90
90
|
:key="action.text"
|
|
91
91
|
class="action-button"
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
<script setup lang="ts">
|
|
2
|
+
import NavbarBrand from '@theme/NavbarBrand.vue'
|
|
3
|
+
import NavbarItems from '@theme/NavbarItems.vue'
|
|
4
|
+
import ToggleDarkModeButton from '@theme/ToggleDarkModeButton.vue'
|
|
5
|
+
import ToggleSidebarButton from '@theme/ToggleSidebarButton.vue'
|
|
2
6
|
import { computed, onMounted, ref } from 'vue'
|
|
3
7
|
import { useThemeLocaleData } from '../composables'
|
|
4
|
-
import NavbarBrand from './NavbarBrand.vue'
|
|
5
|
-
import NavbarLinks from './NavbarLinks.vue'
|
|
6
|
-
import ToggleDarkModeButton from './ToggleDarkModeButton.vue'
|
|
7
|
-
import ToggleSidebarButton from './ToggleSidebarButton.vue'
|
|
8
8
|
|
|
9
9
|
defineEmits(['toggle-sidebar'])
|
|
10
10
|
|
|
@@ -65,9 +65,9 @@ function getCssValue(el: HTMLElement | null, property: string): number {
|
|
|
65
65
|
<NavbarBrand />
|
|
66
66
|
</span>
|
|
67
67
|
|
|
68
|
-
<div class="navbar-
|
|
68
|
+
<div class="navbar-items-wrapper" :style="linksWrapperStyle">
|
|
69
69
|
<slot name="before" />
|
|
70
|
-
<
|
|
70
|
+
<NavbarItems class="can-hide" />
|
|
71
71
|
<slot name="after" />
|
|
72
72
|
<ToggleDarkModeButton v-if="enableDarkMode" />
|
|
73
73
|
<NavbarSearch />
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
<script setup lang="ts">
|
|
2
|
+
import AutoLink from '@theme/AutoLink.vue'
|
|
3
|
+
import DropdownTransition from '@theme/DropdownTransition.vue'
|
|
2
4
|
import { computed, ref, toRefs, watch } from 'vue'
|
|
3
5
|
import type { PropType } from 'vue'
|
|
4
6
|
import { useRoute } from 'vue-router'
|
|
5
|
-
import type {
|
|
6
|
-
import DropdownTransition from './DropdownTransition.vue'
|
|
7
|
-
import NavLink from './NavLink.vue'
|
|
7
|
+
import type { NavbarItem, ResolvedNavbarItem } from '../../shared'
|
|
8
8
|
|
|
9
9
|
const props = defineProps({
|
|
10
10
|
item: {
|
|
11
|
-
type: Object as PropType<
|
|
11
|
+
type: Object as PropType<Exclude<ResolvedNavbarItem, NavbarItem>>,
|
|
12
12
|
required: true,
|
|
13
13
|
},
|
|
14
14
|
})
|
|
@@ -50,9 +50,9 @@ const isLastItemOfArray = (item: unknown, arr: unknown[]): boolean =>
|
|
|
50
50
|
</script>
|
|
51
51
|
|
|
52
52
|
<template>
|
|
53
|
-
<div class="dropdown-wrapper" :class="{ open }">
|
|
53
|
+
<div class="navbar-dropdown-wrapper" :class="{ open }">
|
|
54
54
|
<button
|
|
55
|
-
class="dropdown-title"
|
|
55
|
+
class="navbar-dropdown-title"
|
|
56
56
|
type="button"
|
|
57
57
|
:aria-label="dropdownAriaLabel"
|
|
58
58
|
@click="handleDropdown"
|
|
@@ -62,7 +62,7 @@ const isLastItemOfArray = (item: unknown, arr: unknown[]): boolean =>
|
|
|
62
62
|
</button>
|
|
63
63
|
|
|
64
64
|
<button
|
|
65
|
-
class="
|
|
65
|
+
class="navbar-dropdown-title-mobile"
|
|
66
66
|
type="button"
|
|
67
67
|
:aria-label="dropdownAriaLabel"
|
|
68
68
|
@click="open = !open"
|
|
@@ -72,15 +72,15 @@ const isLastItemOfArray = (item: unknown, arr: unknown[]): boolean =>
|
|
|
72
72
|
</button>
|
|
73
73
|
|
|
74
74
|
<DropdownTransition>
|
|
75
|
-
<ul v-show="open" class="
|
|
75
|
+
<ul v-show="open" class="navbar-dropdown">
|
|
76
76
|
<li
|
|
77
|
-
v-for="
|
|
78
|
-
:key="child.
|
|
79
|
-
class="dropdown-item"
|
|
77
|
+
v-for="child in item.children"
|
|
78
|
+
:key="child.text"
|
|
79
|
+
class="navbar-dropdown-item"
|
|
80
80
|
>
|
|
81
81
|
<template v-if="child.children">
|
|
82
|
-
<h4 class="dropdown-subtitle">
|
|
83
|
-
<
|
|
82
|
+
<h4 class="navbar-dropdown-subtitle">
|
|
83
|
+
<AutoLink
|
|
84
84
|
v-if="child.link"
|
|
85
85
|
:item="child"
|
|
86
86
|
@focusout="
|
|
@@ -93,13 +93,13 @@ const isLastItemOfArray = (item: unknown, arr: unknown[]): boolean =>
|
|
|
93
93
|
<span v-else>{{ child.text }}</span>
|
|
94
94
|
</h4>
|
|
95
95
|
|
|
96
|
-
<ul class="dropdown-subitem-wrapper">
|
|
96
|
+
<ul class="navbar-dropdown-subitem-wrapper">
|
|
97
97
|
<li
|
|
98
98
|
v-for="grandchild in child.children"
|
|
99
99
|
:key="grandchild.link"
|
|
100
|
-
class="dropdown-subitem"
|
|
100
|
+
class="navbar-dropdown-subitem"
|
|
101
101
|
>
|
|
102
|
-
<
|
|
102
|
+
<AutoLink
|
|
103
103
|
:item="grandchild"
|
|
104
104
|
@focusout="
|
|
105
105
|
isLastItemOfArray(grandchild, child.children) &&
|
|
@@ -112,7 +112,7 @@ const isLastItemOfArray = (item: unknown, arr: unknown[]): boolean =>
|
|
|
112
112
|
</template>
|
|
113
113
|
|
|
114
114
|
<template v-else>
|
|
115
|
-
<
|
|
115
|
+
<AutoLink
|
|
116
116
|
:item="child"
|
|
117
117
|
@focusout="
|
|
118
118
|
isLastItemOfArray(child, item.children) && (open = false)
|
|
@@ -1,20 +1,14 @@
|
|
|
1
1
|
<script setup lang="ts">
|
|
2
|
+
import AutoLink from '@theme/AutoLink.vue'
|
|
3
|
+
import NavbarDropdown from '@theme/NavbarDropdown.vue'
|
|
2
4
|
import { useRouteLocale, useSiteLocaleData } from '@vuepress/client'
|
|
3
5
|
import { isLinkHttp, isString } from '@vuepress/shared'
|
|
4
6
|
import { computed } from 'vue'
|
|
5
7
|
import type { ComputedRef } from 'vue'
|
|
6
8
|
import { useRouter } from 'vue-router'
|
|
7
|
-
import type {
|
|
8
|
-
NavbarGroup,
|
|
9
|
-
NavbarItem,
|
|
10
|
-
NavGroup,
|
|
11
|
-
NavLink as NavLinkType,
|
|
12
|
-
ResolvedNavbarItem,
|
|
13
|
-
} from '../../shared'
|
|
9
|
+
import type { NavbarGroup, NavbarItem, ResolvedNavbarItem } from '../../shared'
|
|
14
10
|
import { useNavLink, useThemeLocaleData } from '../composables'
|
|
15
11
|
import { resolveRepoType } from '../utils'
|
|
16
|
-
import DropdownLink from './DropdownLink.vue'
|
|
17
|
-
import NavLink from './NavLink.vue'
|
|
18
12
|
|
|
19
13
|
/**
|
|
20
14
|
* Get navbar config of select language dropdown
|
|
@@ -35,7 +29,7 @@ const useNavbarSelectLanguage = (): ComputedRef<ResolvedNavbarItem[]> => {
|
|
|
35
29
|
const currentFullPath = router.currentRoute.value.fullPath
|
|
36
30
|
|
|
37
31
|
const languageDropdown: ResolvedNavbarItem = {
|
|
38
|
-
text: themeLocale.value.selectLanguageText ?? '
|
|
32
|
+
text: themeLocale.value.selectLanguageText ?? 'unknown language',
|
|
39
33
|
ariaLabel: themeLocale.value.selectLanguageAriaLabel ?? 'unkown language',
|
|
40
34
|
children: localePaths.map((targetLocalePath) => {
|
|
41
35
|
// target locale config of this langauge link
|
|
@@ -151,10 +145,10 @@ const navbarLinks = computed(() => [
|
|
|
151
145
|
</script>
|
|
152
146
|
|
|
153
147
|
<template>
|
|
154
|
-
<nav v-if="navbarLinks.length" class="navbar-
|
|
155
|
-
<div v-for="item in navbarLinks" :key="item.text" class="navbar-
|
|
156
|
-
<
|
|
157
|
-
<
|
|
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" />
|
|
158
152
|
</div>
|
|
159
153
|
</nav>
|
|
160
154
|
</template>
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
<script setup lang="ts">
|
|
2
|
+
import AutoLink from '@theme/AutoLink.vue'
|
|
2
3
|
import {
|
|
3
4
|
usePageData,
|
|
4
5
|
usePageFrontmatter,
|
|
@@ -9,13 +10,12 @@ import type { ComputedRef } from 'vue'
|
|
|
9
10
|
import type {
|
|
10
11
|
DefaultThemeNormalPageFrontmatter,
|
|
11
12
|
DefaultThemePageData,
|
|
12
|
-
NavLink
|
|
13
|
+
NavLink,
|
|
13
14
|
} from '../../shared'
|
|
14
15
|
import { useThemeLocaleData } from '../composables'
|
|
15
16
|
import { resolveEditLink } from '../utils'
|
|
16
|
-
import NavLink from './NavLink.vue'
|
|
17
17
|
|
|
18
|
-
const useEditNavLink = (): ComputedRef<null |
|
|
18
|
+
const useEditNavLink = (): ComputedRef<null | NavLink> => {
|
|
19
19
|
const themeLocale = useThemeLocaleData()
|
|
20
20
|
const page = usePageData<DefaultThemePageData>()
|
|
21
21
|
const frontmatter = usePageFrontmatter<DefaultThemeNormalPageFrontmatter>()
|
|
@@ -56,7 +56,6 @@ const useEditNavLink = (): ComputedRef<null | NavLinkType> => {
|
|
|
56
56
|
}
|
|
57
57
|
|
|
58
58
|
const useLastUpdated = (): ComputedRef<null | string> => {
|
|
59
|
-
const siteLocale = useSiteLocaleData()
|
|
60
59
|
const themeLocale = useThemeLocaleData()
|
|
61
60
|
const page = usePageData<DefaultThemePageData>()
|
|
62
61
|
const frontmatter = usePageFrontmatter<DefaultThemeNormalPageFrontmatter>()
|
|
@@ -101,7 +100,7 @@ const contributors = useContributors()
|
|
|
101
100
|
<template>
|
|
102
101
|
<footer class="page-meta">
|
|
103
102
|
<div v-if="editNavLink" class="meta-item edit-link">
|
|
104
|
-
<
|
|
103
|
+
<AutoLink class="meta-item-label" :item="editNavLink" />
|
|
105
104
|
</div>
|
|
106
105
|
|
|
107
106
|
<div v-if="lastUpdated" class="meta-item last-updated">
|
|
@@ -1,22 +1,22 @@
|
|
|
1
1
|
<script setup lang="ts">
|
|
2
|
+
import AutoLink from '@theme/AutoLink.vue'
|
|
2
3
|
import { usePageFrontmatter } from '@vuepress/client'
|
|
3
4
|
import { isPlainObject, isString } from '@vuepress/shared'
|
|
4
5
|
import { computed } from 'vue'
|
|
5
6
|
import { useRoute } from 'vue-router'
|
|
6
7
|
import type {
|
|
7
8
|
DefaultThemeNormalPageFrontmatter,
|
|
8
|
-
NavLink
|
|
9
|
+
NavLink,
|
|
9
10
|
ResolvedSidebarItem,
|
|
10
11
|
} from '../../shared'
|
|
11
12
|
import { useNavLink, useSidebarItems } from '../composables'
|
|
12
|
-
import NavLink from './NavLink.vue'
|
|
13
13
|
|
|
14
14
|
/**
|
|
15
15
|
* Resolve `prev` or `next` config from frontmatter
|
|
16
16
|
*/
|
|
17
17
|
const resolveFromFrontmatterConfig = (
|
|
18
18
|
conf: unknown
|
|
19
|
-
): null | false |
|
|
19
|
+
): null | false | NavLink => {
|
|
20
20
|
if (conf === false) {
|
|
21
21
|
return null
|
|
22
22
|
}
|
|
@@ -25,7 +25,7 @@ const resolveFromFrontmatterConfig = (
|
|
|
25
25
|
return useNavLink(conf)
|
|
26
26
|
}
|
|
27
27
|
|
|
28
|
-
if (isPlainObject<
|
|
28
|
+
if (isPlainObject<NavLink>(conf)) {
|
|
29
29
|
return conf
|
|
30
30
|
}
|
|
31
31
|
|
|
@@ -39,14 +39,14 @@ const resolveFromSidebarItems = (
|
|
|
39
39
|
sidebarItems: ResolvedSidebarItem[],
|
|
40
40
|
currentPath: string,
|
|
41
41
|
offset: number
|
|
42
|
-
): null |
|
|
42
|
+
): null | NavLink => {
|
|
43
43
|
const index = sidebarItems.findIndex((item) => item.link === currentPath)
|
|
44
44
|
if (index !== -1) {
|
|
45
45
|
const targetItem = sidebarItems[index + offset]
|
|
46
46
|
if (!targetItem?.link) {
|
|
47
47
|
return null
|
|
48
48
|
}
|
|
49
|
-
return targetItem as
|
|
49
|
+
return targetItem as NavLink
|
|
50
50
|
}
|
|
51
51
|
|
|
52
52
|
for (const item of sidebarItems) {
|
|
@@ -92,11 +92,11 @@ const nextNavLink = computed(() => {
|
|
|
92
92
|
<nav v-if="prevNavLink || nextNavLink" class="page-nav">
|
|
93
93
|
<p class="inner">
|
|
94
94
|
<span v-if="prevNavLink" class="prev">
|
|
95
|
-
<
|
|
95
|
+
<AutoLink :item="prevNavLink" />
|
|
96
96
|
</span>
|
|
97
97
|
|
|
98
98
|
<span v-if="nextNavLink" class="next">
|
|
99
|
-
<
|
|
99
|
+
<AutoLink :item="nextNavLink" />
|
|
100
100
|
</span>
|
|
101
101
|
</p>
|
|
102
102
|
</nav>
|
|
@@ -1,25 +1,13 @@
|
|
|
1
1
|
<script setup lang="ts">
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import { SidebarChild } from './SidebarChild'
|
|
5
|
-
|
|
6
|
-
const sidebarItems = useSidebarItems()
|
|
2
|
+
import NavbarItems from '@theme/NavbarItems.vue'
|
|
3
|
+
import SidebarItems from '@theme/SidebarItems.vue'
|
|
7
4
|
</script>
|
|
8
5
|
|
|
9
6
|
<template>
|
|
10
7
|
<aside class="sidebar">
|
|
11
|
-
<
|
|
12
|
-
|
|
8
|
+
<NavbarItems />
|
|
13
9
|
<slot name="top" />
|
|
14
|
-
|
|
15
|
-
<ul class="sidebar-links">
|
|
16
|
-
<SidebarChild
|
|
17
|
-
v-for="item in sidebarItems"
|
|
18
|
-
:key="item.link || item.text"
|
|
19
|
-
:item="item"
|
|
20
|
-
/>
|
|
21
|
-
</ul>
|
|
22
|
-
|
|
10
|
+
<SidebarItems />
|
|
23
11
|
<slot name="bottom" />
|
|
24
12
|
</aside>
|
|
25
13
|
</template>
|
|
@@ -0,0 +1,80 @@
|
|
|
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
|
|
55
|
+
v-else
|
|
56
|
+
tabindex="0"
|
|
57
|
+
:class="itemClass"
|
|
58
|
+
@click="onClick"
|
|
59
|
+
@keydown.enter="onClick"
|
|
60
|
+
>
|
|
61
|
+
{{ item.text }}
|
|
62
|
+
<span
|
|
63
|
+
v-if="item.collapsible"
|
|
64
|
+
class="arrow"
|
|
65
|
+
:class="isOpen ? 'down' : 'right'"
|
|
66
|
+
/>
|
|
67
|
+
</p>
|
|
68
|
+
|
|
69
|
+
<DropdownTransition v-if="item.children?.length">
|
|
70
|
+
<ul v-show="isOpen" class="sidebar-item-children">
|
|
71
|
+
<SidebarItem
|
|
72
|
+
v-for="child in item.children"
|
|
73
|
+
:key="`${depth}${child.text}${child.link}`"
|
|
74
|
+
:item="child"
|
|
75
|
+
:depth="depth + 1"
|
|
76
|
+
/>
|
|
77
|
+
</ul>
|
|
78
|
+
</DropdownTransition>
|
|
79
|
+
</li>
|
|
80
|
+
</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>
|
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';
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
<script setup lang="ts">
|
|
2
|
+
import Home from '@theme/Home.vue'
|
|
3
|
+
import Navbar from '@theme/Navbar.vue'
|
|
4
|
+
import Page from '@theme/Page.vue'
|
|
5
|
+
import Sidebar from '@theme/Sidebar.vue'
|
|
2
6
|
import { usePageData, usePageFrontmatter } from '@vuepress/client'
|
|
3
7
|
import { computed, onMounted, onUnmounted, ref, Transition } from 'vue'
|
|
4
8
|
import { useRouter } from 'vue-router'
|
|
5
9
|
import type { DefaultThemePageFrontmatter } from '../../shared'
|
|
6
|
-
import Home from '../components/Home.vue'
|
|
7
|
-
import Navbar from '../components/Navbar.vue'
|
|
8
|
-
import Page from '../components/Page.vue'
|
|
9
|
-
import Sidebar from '../components/Sidebar.vue'
|
|
10
10
|
import {
|
|
11
11
|
useScrollPromise,
|
|
12
12
|
useSidebarItems,
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
@import '_variables';
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
@mixin content_wrapper {
|
|
4
4
|
max-width: var(--content-width);
|
|
5
5
|
margin: 0 auto;
|
|
6
6
|
padding: 2rem 2.5rem;
|
|
@@ -13,3 +13,8 @@
|
|
|
13
13
|
padding: 1.5rem;
|
|
14
14
|
}
|
|
15
15
|
}
|
|
16
|
+
|
|
17
|
+
@mixin dropdown_wrapper {
|
|
18
|
+
transition: height 0.1s ease-out;
|
|
19
|
+
overflow: hidden;
|
|
20
|
+
}
|
|
@@ -125,7 +125,7 @@ pre[class*='language-'] {
|
|
|
125
125
|
pre,
|
|
126
126
|
pre[class*='language-'] {
|
|
127
127
|
line-height: 1.4;
|
|
128
|
-
padding: 1.
|
|
128
|
+
padding: 1.3rem 1.5rem;
|
|
129
129
|
margin: 0.85rem 0;
|
|
130
130
|
border-radius: 6px;
|
|
131
131
|
overflow: auto;
|
|
@@ -228,6 +228,7 @@ div[class*='language-'] {
|
|
|
228
228
|
z-index: 3;
|
|
229
229
|
user-select: none;
|
|
230
230
|
font-size: 0.85em;
|
|
231
|
+
line-height: 0;
|
|
231
232
|
}
|
|
232
233
|
}
|
|
233
234
|
|
|
@@ -7,13 +7,12 @@
|
|
|
7
7
|
@use 'code';
|
|
8
8
|
@use 'code-group';
|
|
9
9
|
@use 'custom-container';
|
|
10
|
-
@use 'dropdown';
|
|
11
10
|
@use 'home';
|
|
12
11
|
@use 'layout';
|
|
13
12
|
@use 'navbar';
|
|
13
|
+
@use 'navbar-dropdown';
|
|
14
14
|
@use 'page';
|
|
15
15
|
@use 'sidebar';
|
|
16
|
-
@use 'sr-only';
|
|
17
16
|
@use 'toc';
|
|
18
17
|
@use 'transitions';
|
|
19
18
|
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
+
@import '_mixins';
|
|
1
2
|
@import '_variables';
|
|
2
|
-
@import '_wrapper';
|
|
3
3
|
|
|
4
4
|
.page {
|
|
5
5
|
padding-top: var(--navbar-height);
|
|
@@ -142,7 +142,7 @@ h6 {
|
|
|
142
142
|
}
|
|
143
143
|
|
|
144
144
|
.theme-default-content:not(.custom) {
|
|
145
|
-
@
|
|
145
|
+
@include content_wrapper;
|
|
146
146
|
|
|
147
147
|
padding-top: 0;
|
|
148
148
|
|