@vuepress/theme-default 2.0.0-beta.5 → 2.0.0-beta.50
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 +114 -0
- package/lib/client/components/DropdownTransition.vue +21 -0
- package/lib/client/components/Home.vue +15 -0
- 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 +75 -0
- package/lib/client/components/NavbarBrand.vue +55 -0
- package/lib/client/components/NavbarDropdown.vue +126 -0
- package/lib/{components/NavbarLinks.vue → client/components/NavbarItems.vue} +41 -52
- package/lib/{components → client/components}/Page.vue +9 -15
- package/lib/{components → client/components}/PageMeta.vue +51 -66
- package/lib/{components → client/components}/PageNav.vue +44 -57
- package/lib/client/components/Sidebar.vue +13 -0
- package/lib/client/components/SidebarItem.vue +87 -0
- package/lib/client/components/SidebarItems.vue +57 -0
- package/lib/client/components/ToggleColorModeButton.vue +57 -0
- package/lib/client/components/ToggleSidebarButton.vue +24 -0
- package/lib/client/components/global/Badge.vue +31 -0
- package/lib/{components → client/components}/global/CodeGroup.d.ts +2 -3
- package/lib/client/components/global/CodeGroup.js +106 -0
- package/lib/client/components/global/CodeGroupItem.vue +31 -0
- package/lib/client/components/global/index.d.ts +4 -0
- package/lib/client/components/global/index.js +4 -0
- package/lib/client/composables/index.d.ts +6 -0
- package/lib/client/composables/index.js +6 -0
- package/lib/client/composables/useDarkMode.d.ts +12 -0
- package/lib/client/composables/useDarkMode.js +57 -0
- package/lib/{composables → client/composables}/useNavLink.d.ts +6 -1
- package/lib/{composables → client/composables}/useNavLink.js +5 -2
- package/lib/{composables → client/composables}/useResolveRouteWithRedirect.d.ts +1 -1
- package/lib/{composables → client/composables}/useResolveRouteWithRedirect.js +2 -2
- package/lib/{composables → client/composables}/useScrollPromise.d.ts +0 -0
- package/lib/{composables → client/composables}/useScrollPromise.js +1 -1
- package/lib/{composables → client/composables}/useSidebarItems.d.ts +12 -7
- package/lib/client/composables/useSidebarItems.js +118 -0
- package/lib/{composables → client/composables}/useThemeData.d.ts +2 -2
- package/lib/{composables → client/composables}/useThemeData.js +1 -1
- package/lib/client/config.d.ts +3 -0
- package/lib/client/config.js +38 -0
- package/lib/client/index.d.ts +3 -0
- package/lib/client/index.js +3 -0
- package/lib/client/layouts/404.vue +27 -0
- package/lib/client/layouts/Layout.vue +134 -0
- package/lib/{shim.d.ts → client/shim.d.ts} +0 -0
- package/lib/{styles/_wrapper.scss → client/styles/_mixins.scss} +7 -2
- package/lib/client/styles/_variables.scss +11 -0
- package/lib/{styles → client/styles}/arrow.scss +4 -6
- package/lib/{styles → client/styles}/badge.scss +9 -11
- package/lib/{styles → client/styles}/code-group.scss +9 -2
- package/lib/{styles → client/styles}/code.scss +26 -37
- package/lib/client/styles/custom-container.scss +88 -0
- package/lib/{styles → client/styles}/home.scss +32 -24
- package/lib/{styles → client/styles}/index.scss +4 -4
- package/lib/{styles → client/styles}/layout.scss +70 -66
- package/lib/{styles/dropdown.scss → client/styles/navbar-dropdown.scss} +37 -47
- package/lib/{styles → client/styles}/navbar.scss +70 -34
- package/lib/client/styles/normalize.scss +177 -0
- package/lib/{styles → client/styles}/page.scss +20 -8
- package/lib/client/styles/sidebar.scss +134 -0
- package/lib/{styles → client/styles}/toc.scss +0 -0
- package/lib/client/styles/transitions.scss +22 -0
- package/lib/client/styles/vars-dark.scss +46 -0
- package/lib/client/styles/vars.scss +133 -0
- package/lib/client/utils/index.d.ts +3 -0
- package/lib/client/utils/index.js +3 -0
- package/lib/client/utils/isActiveSidebarItem.d.ts +3 -0
- package/lib/client/utils/isActiveSidebarItem.js +20 -0
- package/lib/{utils → client/utils}/resolveEditLink.d.ts +2 -2
- package/lib/{utils → client/utils}/resolveEditLink.js +15 -9
- package/lib/client/utils/resolveRepoType.d.ts +2 -0
- package/lib/{utils → client/utils}/resolveRepoType.js +3 -1
- package/lib/node/defaultTheme.d.ts +10 -0
- package/lib/node/defaultTheme.js +120 -0
- package/lib/node/index.d.ts +5 -5
- package/lib/node/index.js +5 -17
- package/lib/node/utils/assignDefaultLocaleOptions.d.ts +7 -0
- package/lib/node/{assignDefaultLocaleOptions.js → utils/assignDefaultLocaleOptions.js} +13 -13
- package/lib/node/utils/index.d.ts +2 -0
- package/lib/node/utils/index.js +2 -0
- package/lib/node/utils/resolveContainerPluginOptions.d.ts +8 -0
- package/lib/node/utils/resolveContainerPluginOptions.js +17 -0
- package/lib/shared/index.d.ts +3 -0
- package/lib/shared/index.js +3 -0
- package/lib/{types → shared}/nav.d.ts +11 -12
- package/lib/shared/nav.js +1 -0
- package/lib/{types → shared}/options.d.ts +49 -11
- package/lib/shared/options.js +1 -0
- package/lib/{types → shared}/page.d.ts +14 -6
- package/lib/shared/page.js +1 -0
- package/package.json +47 -29
- package/templates/build.html +33 -0
- package/CHANGELOG.md +0 -368
- package/lib/clientAppEnhance.d.ts +0 -3
- package/lib/clientAppEnhance.js +0 -30
- package/lib/clientAppSetup.d.ts +0 -2
- package/lib/clientAppSetup.js +0 -11
- package/lib/components/DropdownLink.vue +0 -141
- package/lib/components/DropdownTransition.vue +0 -34
- package/lib/components/Home.vue +0 -133
- package/lib/components/NavLink.vue +0 -115
- package/lib/components/Navbar.vue +0 -114
- package/lib/components/Sidebar.vue +0 -38
- package/lib/components/SidebarChild.d.ts +0 -6
- package/lib/components/SidebarChild.js +0 -91
- package/lib/components/ToggleSidebarButton.vue +0 -27
- package/lib/components/global/Badge.vue +0 -37
- package/lib/components/global/CodeGroup.js +0 -52
- package/lib/components/global/CodeGroupItem.vue +0 -25
- package/lib/components/global/OutboundLink.vue +0 -30
- package/lib/composables/index.d.ts +0 -5
- package/lib/composables/index.js +0 -5
- package/lib/composables/useSidebarItems.js +0 -114
- package/lib/index.d.ts +0 -6
- package/lib/index.js +0 -67
- package/lib/layouts/404.vue +0 -38
- package/lib/layouts/Layout.vue +0 -152
- package/lib/node/assignDefaultLocaleOptions.d.ts +0 -5
- package/lib/node/resolveActiveHeaderLinksPluginOptions.d.ts +0 -6
- package/lib/node/resolveActiveHeaderLinksPluginOptions.js +0 -16
- package/lib/node/resolveContainerPluginOptions.d.ts +0 -26
- package/lib/node/resolveContainerPluginOptions.js +0 -79
- package/lib/node/resolveGitPluginOptions.d.ts +0 -6
- package/lib/node/resolveGitPluginOptions.js +0 -22
- package/lib/node/resolveMediumZoomPluginOptions.d.ts +0 -6
- package/lib/node/resolveMediumZoomPluginOptions.js +0 -17
- package/lib/styles/_normalize.scss +0 -148
- package/lib/styles/_variables.scss +0 -34
- package/lib/styles/custom-container.scss +0 -78
- package/lib/styles/plugins.scss +0 -18
- package/lib/styles/sidebar.scss +0 -152
- package/lib/styles/sr-only.scss +0 -12
- package/lib/styles/transitions.scss +0 -13
- package/lib/types/index.d.ts +0 -3
- package/lib/types/index.js +0 -15
- package/lib/types/nav.js +0 -2
- package/lib/types/options.js +0 -2
- package/lib/types/page.js +0 -2
- package/lib/utils/index.d.ts +0 -2
- package/lib/utils/index.js +0 -2
- package/lib/utils/resolveRepoType.d.ts +0 -2
|
@@ -1,9 +1,18 @@
|
|
|
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" />
|
|
4
9
|
|
|
5
10
|
<div class="theme-default-content">
|
|
11
|
+
<slot name="content-top" />
|
|
12
|
+
|
|
6
13
|
<Content />
|
|
14
|
+
|
|
15
|
+
<slot name="content-bottom" />
|
|
7
16
|
</div>
|
|
8
17
|
|
|
9
18
|
<PageMeta />
|
|
@@ -13,18 +22,3 @@
|
|
|
13
22
|
<slot name="bottom" />
|
|
14
23
|
</main>
|
|
15
24
|
</template>
|
|
16
|
-
|
|
17
|
-
<script>
|
|
18
|
-
import { defineComponent } from 'vue'
|
|
19
|
-
import PageMeta from './PageMeta.vue'
|
|
20
|
-
import PageNav from './PageNav.vue'
|
|
21
|
-
|
|
22
|
-
export default defineComponent({
|
|
23
|
-
name: 'Page',
|
|
24
|
-
|
|
25
|
-
components: {
|
|
26
|
-
PageMeta,
|
|
27
|
-
PageNav,
|
|
28
|
-
},
|
|
29
|
-
})
|
|
30
|
-
</script>
|
|
@@ -1,48 +1,20 @@
|
|
|
1
|
-
<
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
</div>
|
|
6
|
-
|
|
7
|
-
<div v-if="lastUpdated" class="meta-item last-updated">
|
|
8
|
-
<span class="meta-item-label">{{ themeLocale.lastUpdatedText }}: </span>
|
|
9
|
-
<span class="meta-item-info">{{ lastUpdated }}</span>
|
|
10
|
-
</div>
|
|
11
|
-
|
|
12
|
-
<div
|
|
13
|
-
v-if="contributors && contributors.length"
|
|
14
|
-
class="meta-item contributors"
|
|
15
|
-
>
|
|
16
|
-
<span class="meta-item-label">{{ themeLocale.contributorsText }}: </span>
|
|
17
|
-
<span class="meta-item-info">
|
|
18
|
-
<template v-for="(contributor, index) in contributors" :key="index">
|
|
19
|
-
<span class="contributor" :title="`email: ${contributor.email}`">
|
|
20
|
-
{{ contributor.name }}
|
|
21
|
-
</span>
|
|
22
|
-
<template v-if="index !== contributors.length - 1">, </template>
|
|
23
|
-
</template>
|
|
24
|
-
</span>
|
|
25
|
-
</div>
|
|
26
|
-
</footer>
|
|
27
|
-
</template>
|
|
28
|
-
|
|
29
|
-
<script lang="ts">
|
|
30
|
-
import { computed, defineComponent } from 'vue'
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
import AutoLink from '@theme/AutoLink.vue'
|
|
3
|
+
import { usePageData, usePageFrontmatter } from '@vuepress/client'
|
|
4
|
+
import { computed } from 'vue'
|
|
31
5
|
import type { ComputedRef } from 'vue'
|
|
32
|
-
import {
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
} from '
|
|
37
|
-
import { useThemeLocaleData } from '../composables'
|
|
38
|
-
import
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
const useEditNavLink = (): ComputedRef<null | NavLinkType> => {
|
|
6
|
+
import type {
|
|
7
|
+
DefaultThemeNormalPageFrontmatter,
|
|
8
|
+
DefaultThemePageData,
|
|
9
|
+
NavLink,
|
|
10
|
+
} from '../../shared/index.js'
|
|
11
|
+
import { useThemeLocaleData } from '../composables/index.js'
|
|
12
|
+
import { resolveEditLink } from '../utils/index.js'
|
|
13
|
+
|
|
14
|
+
const useEditNavLink = (): ComputedRef<null | NavLink> => {
|
|
43
15
|
const themeLocale = useThemeLocaleData()
|
|
44
16
|
const page = usePageData<DefaultThemePageData>()
|
|
45
|
-
const frontmatter = usePageFrontmatter()
|
|
17
|
+
const frontmatter = usePageFrontmatter<DefaultThemeNormalPageFrontmatter>()
|
|
46
18
|
|
|
47
19
|
return computed(() => {
|
|
48
20
|
const showEditLink =
|
|
@@ -66,7 +38,8 @@ const useEditNavLink = (): ComputedRef<null | NavLinkType> => {
|
|
|
66
38
|
docsBranch,
|
|
67
39
|
docsDir,
|
|
68
40
|
filePathRelative: page.value.filePathRelative,
|
|
69
|
-
editLinkPattern:
|
|
41
|
+
editLinkPattern:
|
|
42
|
+
frontmatter.value.editLinkPattern ?? themeLocale.value.editLinkPattern,
|
|
70
43
|
})
|
|
71
44
|
|
|
72
45
|
if (!editLink) return null
|
|
@@ -79,10 +52,9 @@ const useEditNavLink = (): ComputedRef<null | NavLinkType> => {
|
|
|
79
52
|
}
|
|
80
53
|
|
|
81
54
|
const useLastUpdated = (): ComputedRef<null | string> => {
|
|
82
|
-
const siteLocale = useSiteLocaleData()
|
|
83
55
|
const themeLocale = useThemeLocaleData()
|
|
84
56
|
const page = usePageData<DefaultThemePageData>()
|
|
85
|
-
const frontmatter = usePageFrontmatter()
|
|
57
|
+
const frontmatter = usePageFrontmatter<DefaultThemeNormalPageFrontmatter>()
|
|
86
58
|
|
|
87
59
|
return computed(() => {
|
|
88
60
|
const showLastUpdated =
|
|
@@ -94,7 +66,7 @@ const useLastUpdated = (): ComputedRef<null | string> => {
|
|
|
94
66
|
|
|
95
67
|
const updatedDate = new Date(page.value.git?.updatedTime)
|
|
96
68
|
|
|
97
|
-
return updatedDate.toLocaleString(
|
|
69
|
+
return updatedDate.toLocaleString()
|
|
98
70
|
})
|
|
99
71
|
}
|
|
100
72
|
|
|
@@ -103,7 +75,7 @@ const useContributors = (): ComputedRef<
|
|
|
103
75
|
> => {
|
|
104
76
|
const themeLocale = useThemeLocaleData()
|
|
105
77
|
const page = usePageData<DefaultThemePageData>()
|
|
106
|
-
const frontmatter = usePageFrontmatter()
|
|
78
|
+
const frontmatter = usePageFrontmatter<DefaultThemeNormalPageFrontmatter>()
|
|
107
79
|
|
|
108
80
|
return computed(() => {
|
|
109
81
|
const showContributors =
|
|
@@ -115,25 +87,38 @@ const useContributors = (): ComputedRef<
|
|
|
115
87
|
})
|
|
116
88
|
}
|
|
117
89
|
|
|
118
|
-
|
|
119
|
-
|
|
90
|
+
const themeLocale = useThemeLocaleData()
|
|
91
|
+
const editNavLink = useEditNavLink()
|
|
92
|
+
const lastUpdated = useLastUpdated()
|
|
93
|
+
const contributors = useContributors()
|
|
94
|
+
</script>
|
|
120
95
|
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
96
|
+
<template>
|
|
97
|
+
<footer class="page-meta">
|
|
98
|
+
<div v-if="editNavLink" class="meta-item edit-link">
|
|
99
|
+
<AutoLink class="meta-item-label" :item="editNavLink" />
|
|
100
|
+
</div>
|
|
124
101
|
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
102
|
+
<div v-if="lastUpdated" class="meta-item last-updated">
|
|
103
|
+
<span class="meta-item-label">{{ themeLocale.lastUpdatedText }}: </span>
|
|
104
|
+
<ClientOnly>
|
|
105
|
+
<span class="meta-item-info">{{ lastUpdated }}</span>
|
|
106
|
+
</ClientOnly>
|
|
107
|
+
</div>
|
|
130
108
|
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
}
|
|
139
|
-
|
|
109
|
+
<div
|
|
110
|
+
v-if="contributors && contributors.length"
|
|
111
|
+
class="meta-item contributors"
|
|
112
|
+
>
|
|
113
|
+
<span class="meta-item-label">{{ themeLocale.contributorsText }}: </span>
|
|
114
|
+
<span class="meta-item-info">
|
|
115
|
+
<template v-for="(contributor, index) in contributors" :key="index">
|
|
116
|
+
<span class="contributor" :title="`email: ${contributor.email}`">
|
|
117
|
+
{{ contributor.name }}
|
|
118
|
+
</span>
|
|
119
|
+
<template v-if="index !== contributors.length - 1">, </template>
|
|
120
|
+
</template>
|
|
121
|
+
</span>
|
|
122
|
+
</div>
|
|
123
|
+
</footer>
|
|
124
|
+
</template>
|
|
@@ -1,34 +1,22 @@
|
|
|
1
|
-
<
|
|
2
|
-
|
|
3
|
-
<p class="inner">
|
|
4
|
-
<span v-if="prevNavLink" class="prev">
|
|
5
|
-
←
|
|
6
|
-
<NavLink :item="prevNavLink" />
|
|
7
|
-
</span>
|
|
8
|
-
|
|
9
|
-
<span v-if="nextNavLink" class="next">
|
|
10
|
-
<NavLink :item="nextNavLink" />
|
|
11
|
-
→
|
|
12
|
-
</span>
|
|
13
|
-
</p>
|
|
14
|
-
</nav>
|
|
15
|
-
</template>
|
|
16
|
-
|
|
17
|
-
<script lang="ts">
|
|
18
|
-
import { computed, defineComponent } from 'vue'
|
|
19
|
-
import { useRoute } from 'vue-router'
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
import AutoLink from '@theme/AutoLink.vue'
|
|
20
3
|
import { usePageFrontmatter } from '@vuepress/client'
|
|
21
4
|
import { isPlainObject, isString } from '@vuepress/shared'
|
|
22
|
-
import {
|
|
23
|
-
import
|
|
24
|
-
import
|
|
5
|
+
import { computed } from 'vue'
|
|
6
|
+
import { useRoute } from 'vue-router'
|
|
7
|
+
import type {
|
|
8
|
+
DefaultThemeNormalPageFrontmatter,
|
|
9
|
+
NavLink,
|
|
10
|
+
ResolvedSidebarItem,
|
|
11
|
+
} from '../../shared/index.js'
|
|
12
|
+
import { useNavLink, useSidebarItems } from '../composables/index.js'
|
|
25
13
|
|
|
26
14
|
/**
|
|
27
15
|
* Resolve `prev` or `next` config from frontmatter
|
|
28
16
|
*/
|
|
29
17
|
const resolveFromFrontmatterConfig = (
|
|
30
18
|
conf: unknown
|
|
31
|
-
): null | false |
|
|
19
|
+
): null | false | NavLink => {
|
|
32
20
|
if (conf === false) {
|
|
33
21
|
return null
|
|
34
22
|
}
|
|
@@ -37,7 +25,7 @@ const resolveFromFrontmatterConfig = (
|
|
|
37
25
|
return useNavLink(conf)
|
|
38
26
|
}
|
|
39
27
|
|
|
40
|
-
if (isPlainObject<
|
|
28
|
+
if (isPlainObject<NavLink>(conf)) {
|
|
41
29
|
return conf
|
|
42
30
|
}
|
|
43
31
|
|
|
@@ -51,14 +39,14 @@ const resolveFromSidebarItems = (
|
|
|
51
39
|
sidebarItems: ResolvedSidebarItem[],
|
|
52
40
|
currentPath: string,
|
|
53
41
|
offset: number
|
|
54
|
-
): null |
|
|
42
|
+
): null | NavLink => {
|
|
55
43
|
const index = sidebarItems.findIndex((item) => item.link === currentPath)
|
|
56
44
|
if (index !== -1) {
|
|
57
45
|
const targetItem = sidebarItems[index + offset]
|
|
58
46
|
if (!targetItem?.link) {
|
|
59
47
|
return null
|
|
60
48
|
}
|
|
61
|
-
return targetItem as
|
|
49
|
+
return targetItem as NavLink
|
|
62
50
|
}
|
|
63
51
|
|
|
64
52
|
for (const item of sidebarItems) {
|
|
@@ -77,40 +65,39 @@ const resolveFromSidebarItems = (
|
|
|
77
65
|
return null
|
|
78
66
|
}
|
|
79
67
|
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
components: {
|
|
84
|
-
NavLink,
|
|
85
|
-
},
|
|
86
|
-
|
|
87
|
-
setup() {
|
|
88
|
-
const frontmatter = usePageFrontmatter()
|
|
89
|
-
const sidebarItems = useSidebarItems()
|
|
90
|
-
const route = useRoute()
|
|
91
|
-
|
|
92
|
-
const prevNavLink = computed(() => {
|
|
93
|
-
const prevConfig = resolveFromFrontmatterConfig(frontmatter.value.prev)
|
|
94
|
-
if (prevConfig !== false) {
|
|
95
|
-
return prevConfig
|
|
96
|
-
}
|
|
68
|
+
const frontmatter = usePageFrontmatter<DefaultThemeNormalPageFrontmatter>()
|
|
69
|
+
const sidebarItems = useSidebarItems()
|
|
70
|
+
const route = useRoute()
|
|
97
71
|
|
|
98
|
-
|
|
99
|
-
|
|
72
|
+
const prevNavLink = computed(() => {
|
|
73
|
+
const prevConfig = resolveFromFrontmatterConfig(frontmatter.value.prev)
|
|
74
|
+
if (prevConfig !== false) {
|
|
75
|
+
return prevConfig
|
|
76
|
+
}
|
|
100
77
|
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
if (nextConfig !== false) {
|
|
104
|
-
return nextConfig
|
|
105
|
-
}
|
|
78
|
+
return resolveFromSidebarItems(sidebarItems.value, route.path, -1)
|
|
79
|
+
})
|
|
106
80
|
|
|
107
|
-
|
|
108
|
-
|
|
81
|
+
const nextNavLink = computed(() => {
|
|
82
|
+
const nextConfig = resolveFromFrontmatterConfig(frontmatter.value.next)
|
|
83
|
+
if (nextConfig !== false) {
|
|
84
|
+
return nextConfig
|
|
85
|
+
}
|
|
109
86
|
|
|
110
|
-
|
|
111
|
-
prevNavLink,
|
|
112
|
-
nextNavLink,
|
|
113
|
-
}
|
|
114
|
-
},
|
|
87
|
+
return resolveFromSidebarItems(sidebarItems.value, route.path, 1)
|
|
115
88
|
})
|
|
116
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>
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
import NavbarItems from '@theme/NavbarItems.vue'
|
|
3
|
+
import SidebarItems from '@theme/SidebarItems.vue'
|
|
4
|
+
</script>
|
|
5
|
+
|
|
6
|
+
<template>
|
|
7
|
+
<aside class="sidebar">
|
|
8
|
+
<NavbarItems />
|
|
9
|
+
<slot name="top" />
|
|
10
|
+
<SidebarItems />
|
|
11
|
+
<slot name="bottom" />
|
|
12
|
+
</aside>
|
|
13
|
+
</template>
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
import AutoLink from '@theme/AutoLink.vue'
|
|
3
|
+
import DropdownTransition from '@theme/DropdownTransition.vue'
|
|
4
|
+
import { useToggle } from '@vueuse/core'
|
|
5
|
+
import { computed, nextTick, onBeforeUnmount, toRefs } from 'vue'
|
|
6
|
+
import type { PropType } from 'vue'
|
|
7
|
+
import { useRoute, useRouter } from 'vue-router'
|
|
8
|
+
import type { ResolvedSidebarItem } from '../../shared/index.js'
|
|
9
|
+
import { isActiveSidebarItem } from '../utils/index.js'
|
|
10
|
+
|
|
11
|
+
const props = defineProps({
|
|
12
|
+
item: {
|
|
13
|
+
type: Object as PropType<ResolvedSidebarItem>,
|
|
14
|
+
required: true,
|
|
15
|
+
},
|
|
16
|
+
depth: {
|
|
17
|
+
type: Number,
|
|
18
|
+
required: false,
|
|
19
|
+
default: 0,
|
|
20
|
+
},
|
|
21
|
+
})
|
|
22
|
+
|
|
23
|
+
const { item, depth } = toRefs(props)
|
|
24
|
+
const route = useRoute()
|
|
25
|
+
const router = useRouter()
|
|
26
|
+
|
|
27
|
+
const isActive = computed(() => isActiveSidebarItem(item.value, route))
|
|
28
|
+
const itemClass = computed(() => ({
|
|
29
|
+
'sidebar-item': true,
|
|
30
|
+
'sidebar-heading': depth.value === 0,
|
|
31
|
+
'active': isActive.value,
|
|
32
|
+
'collapsible': item.value.collapsible,
|
|
33
|
+
}))
|
|
34
|
+
|
|
35
|
+
const isOpenDefault = computed(() =>
|
|
36
|
+
item.value.collapsible ? isActive.value : true
|
|
37
|
+
)
|
|
38
|
+
const [isOpen, toggleIsOpen] = useToggle(isOpenDefault.value)
|
|
39
|
+
const onClick = (e: Event): void => {
|
|
40
|
+
if (item.value.collapsible) {
|
|
41
|
+
e.preventDefault()
|
|
42
|
+
// toggle open status on click
|
|
43
|
+
toggleIsOpen()
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
// reset open status after navigation
|
|
48
|
+
const unregisterRouterHook = router.afterEach((to) => {
|
|
49
|
+
nextTick(() => {
|
|
50
|
+
isOpen.value = isOpenDefault.value
|
|
51
|
+
})
|
|
52
|
+
})
|
|
53
|
+
onBeforeUnmount(() => {
|
|
54
|
+
unregisterRouterHook()
|
|
55
|
+
})
|
|
56
|
+
</script>
|
|
57
|
+
|
|
58
|
+
<template>
|
|
59
|
+
<li>
|
|
60
|
+
<AutoLink v-if="item.link" :class="itemClass" :item="item" />
|
|
61
|
+
<p
|
|
62
|
+
v-else
|
|
63
|
+
tabindex="0"
|
|
64
|
+
:class="itemClass"
|
|
65
|
+
@click="onClick"
|
|
66
|
+
@keydown.enter="onClick"
|
|
67
|
+
>
|
|
68
|
+
{{ item.text }}
|
|
69
|
+
<span
|
|
70
|
+
v-if="item.collapsible"
|
|
71
|
+
class="arrow"
|
|
72
|
+
:class="isOpen ? 'down' : 'right'"
|
|
73
|
+
/>
|
|
74
|
+
</p>
|
|
75
|
+
|
|
76
|
+
<DropdownTransition v-if="item.children?.length">
|
|
77
|
+
<ul v-show="isOpen" class="sidebar-item-children">
|
|
78
|
+
<SidebarItem
|
|
79
|
+
v-for="child in item.children"
|
|
80
|
+
:key="`${depth}${child.text}${child.link}`"
|
|
81
|
+
:item="child"
|
|
82
|
+
:depth="depth + 1"
|
|
83
|
+
/>
|
|
84
|
+
</ul>
|
|
85
|
+
</DropdownTransition>
|
|
86
|
+
</li>
|
|
87
|
+
</template>
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
import SidebarItem from '@theme/SidebarItem.vue'
|
|
3
|
+
import { onMounted, watch } from 'vue'
|
|
4
|
+
import { useRoute } from 'vue-router'
|
|
5
|
+
import { useSidebarItems } from '../composables/index.js'
|
|
6
|
+
|
|
7
|
+
const route = useRoute()
|
|
8
|
+
const sidebarItems = useSidebarItems()
|
|
9
|
+
|
|
10
|
+
onMounted(() => {
|
|
11
|
+
watch(
|
|
12
|
+
() => route.hash,
|
|
13
|
+
(hash) => {
|
|
14
|
+
// get the sidebar DOM
|
|
15
|
+
const sidebar = document.querySelector('.sidebar')
|
|
16
|
+
if (!sidebar) return
|
|
17
|
+
|
|
18
|
+
// get the active sidebar item DOM, whose href equals to the current route
|
|
19
|
+
const activeSidebarItem = document.querySelector(
|
|
20
|
+
`.sidebar a.sidebar-item[href="${route.path}${hash}"]`
|
|
21
|
+
)
|
|
22
|
+
if (!activeSidebarItem) return
|
|
23
|
+
|
|
24
|
+
// get the top and height of the sidebar
|
|
25
|
+
const { top: sidebarTop, height: sidebarHeight } =
|
|
26
|
+
sidebar.getBoundingClientRect()
|
|
27
|
+
// get the top and height of the active sidebar item
|
|
28
|
+
const { top: activeSidebarItemTop, height: activeSidebarItemHeight } =
|
|
29
|
+
activeSidebarItem.getBoundingClientRect()
|
|
30
|
+
|
|
31
|
+
// when the active sidebar item overflows the top edge of sidebar
|
|
32
|
+
if (activeSidebarItemTop < sidebarTop) {
|
|
33
|
+
// scroll to the top edge of sidebar
|
|
34
|
+
activeSidebarItem.scrollIntoView(true)
|
|
35
|
+
}
|
|
36
|
+
// when the active sidebar item overflows the bottom edge of sidebar
|
|
37
|
+
else if (
|
|
38
|
+
activeSidebarItemTop + activeSidebarItemHeight >
|
|
39
|
+
sidebarTop + sidebarHeight
|
|
40
|
+
) {
|
|
41
|
+
// scroll to the bottom edge of sidebar
|
|
42
|
+
activeSidebarItem.scrollIntoView(false)
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
)
|
|
46
|
+
})
|
|
47
|
+
</script>
|
|
48
|
+
|
|
49
|
+
<template>
|
|
50
|
+
<ul v-if="sidebarItems.length" class="sidebar-items">
|
|
51
|
+
<SidebarItem
|
|
52
|
+
v-for="item in sidebarItems"
|
|
53
|
+
:key="`${item.text}${item.link}`"
|
|
54
|
+
:item="item"
|
|
55
|
+
/>
|
|
56
|
+
</ul>
|
|
57
|
+
</template>
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
import { useDarkMode, useThemeLocaleData } from '../composables/index.js'
|
|
3
|
+
|
|
4
|
+
const themeLocale = useThemeLocaleData()
|
|
5
|
+
const isDarkMode = useDarkMode()
|
|
6
|
+
|
|
7
|
+
const toggleColorMode = (): void => {
|
|
8
|
+
isDarkMode.value = !isDarkMode.value
|
|
9
|
+
}
|
|
10
|
+
</script>
|
|
11
|
+
|
|
12
|
+
<template>
|
|
13
|
+
<button
|
|
14
|
+
class="toggle-color-mode-button"
|
|
15
|
+
:title="themeLocale.toggleColorMode"
|
|
16
|
+
@click="toggleColorMode"
|
|
17
|
+
>
|
|
18
|
+
<svg
|
|
19
|
+
v-show="!isDarkMode"
|
|
20
|
+
class="icon"
|
|
21
|
+
focusable="false"
|
|
22
|
+
viewBox="0 0 32 32"
|
|
23
|
+
>
|
|
24
|
+
<path
|
|
25
|
+
d="M16 12.005a4 4 0 1 1-4 4a4.005 4.005 0 0 1 4-4m0-2a6 6 0 1 0 6 6a6 6 0 0 0-6-6z"
|
|
26
|
+
fill="currentColor"
|
|
27
|
+
/>
|
|
28
|
+
<path
|
|
29
|
+
d="M5.394 6.813l1.414-1.415l3.506 3.506L8.9 10.318z"
|
|
30
|
+
fill="currentColor"
|
|
31
|
+
/>
|
|
32
|
+
<path d="M2 15.005h5v2H2z" fill="currentColor" />
|
|
33
|
+
<path
|
|
34
|
+
d="M5.394 25.197L8.9 21.691l1.414 1.415l-3.506 3.505z"
|
|
35
|
+
fill="currentColor"
|
|
36
|
+
/>
|
|
37
|
+
<path d="M15 25.005h2v5h-2z" fill="currentColor" />
|
|
38
|
+
<path
|
|
39
|
+
d="M21.687 23.106l1.414-1.415l3.506 3.506l-1.414 1.414z"
|
|
40
|
+
fill="currentColor"
|
|
41
|
+
/>
|
|
42
|
+
<path d="M25 15.005h5v2h-5z" fill="currentColor" />
|
|
43
|
+
<path
|
|
44
|
+
d="M21.687 8.904l3.506-3.506l1.414 1.415l-3.506 3.505z"
|
|
45
|
+
fill="currentColor"
|
|
46
|
+
/>
|
|
47
|
+
<path d="M15 2.005h2v5h-2z" fill="currentColor" />
|
|
48
|
+
</svg>
|
|
49
|
+
|
|
50
|
+
<svg v-show="isDarkMode" class="icon" focusable="false" viewBox="0 0 32 32">
|
|
51
|
+
<path
|
|
52
|
+
d="M13.502 5.414a15.075 15.075 0 0 0 11.594 18.194a11.113 11.113 0 0 1-7.975 3.39c-.138 0-.278.005-.418 0a11.094 11.094 0 0 1-3.2-21.584M14.98 3a1.002 1.002 0 0 0-.175.016a13.096 13.096 0 0 0 1.825 25.981c.164.006.328 0 .49 0a13.072 13.072 0 0 0 10.703-5.555a1.01 1.01 0 0 0-.783-1.565A13.08 13.08 0 0 1 15.89 4.38A1.015 1.015 0 0 0 14.98 3z"
|
|
53
|
+
fill="currentColor"
|
|
54
|
+
/>
|
|
55
|
+
</svg>
|
|
56
|
+
</button>
|
|
57
|
+
</template>
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
import { useThemeLocaleData } from '../composables/index.js'
|
|
3
|
+
|
|
4
|
+
defineEmits(['toggle'])
|
|
5
|
+
|
|
6
|
+
const themeLocale = useThemeLocaleData()
|
|
7
|
+
</script>
|
|
8
|
+
|
|
9
|
+
<template>
|
|
10
|
+
<div
|
|
11
|
+
class="toggle-sidebar-button"
|
|
12
|
+
:title="themeLocale.toggleSidebar"
|
|
13
|
+
aria-expanded="false"
|
|
14
|
+
role="button"
|
|
15
|
+
tabindex="0"
|
|
16
|
+
@click="$emit('toggle')"
|
|
17
|
+
>
|
|
18
|
+
<div class="icon" aria-hidden="true">
|
|
19
|
+
<span></span>
|
|
20
|
+
<span></span>
|
|
21
|
+
<span></span>
|
|
22
|
+
</div>
|
|
23
|
+
</div>
|
|
24
|
+
</template>
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
defineProps({
|
|
3
|
+
type: {
|
|
4
|
+
type: String,
|
|
5
|
+
required: false,
|
|
6
|
+
default: 'tip',
|
|
7
|
+
},
|
|
8
|
+
text: {
|
|
9
|
+
type: String,
|
|
10
|
+
required: false,
|
|
11
|
+
default: '',
|
|
12
|
+
},
|
|
13
|
+
vertical: {
|
|
14
|
+
type: String,
|
|
15
|
+
required: false,
|
|
16
|
+
default: undefined,
|
|
17
|
+
},
|
|
18
|
+
})
|
|
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,5 +1,4 @@
|
|
|
1
1
|
import type { VNode } from 'vue';
|
|
2
|
-
declare const
|
|
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, import("vue").EmitsOptions, string, import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, Readonly<{}
|
|
5
|
-
export default _default;
|
|
4
|
+
}> | null, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, import("vue").EmitsOptions, string, import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, Readonly<import("vue").ExtractPropTypes<{}>>, {}>;
|