@vuepress/theme-default 2.0.0-beta.4 → 2.0.0-beta.40

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.
Files changed (132) hide show
  1. package/lib/{clientAppEnhance.d.ts → client/clientAppEnhance.d.ts} +0 -0
  2. package/lib/client/clientAppEnhance.js +34 -0
  3. package/lib/{clientAppSetup.d.ts → client/clientAppSetup.d.ts} +0 -0
  4. package/lib/client/clientAppSetup.js +6 -0
  5. package/lib/client/components/AutoLink.vue +113 -0
  6. package/lib/client/components/DropdownTransition.vue +21 -0
  7. package/lib/client/components/Home.vue +15 -0
  8. package/lib/client/components/HomeContent.vue +5 -0
  9. package/lib/client/components/HomeFeatures.vue +23 -0
  10. package/lib/client/components/HomeFooter.vue +17 -0
  11. package/lib/client/components/HomeHero.vue +97 -0
  12. package/lib/client/components/Navbar.vue +76 -0
  13. package/lib/client/components/NavbarBrand.vue +55 -0
  14. package/lib/client/components/NavbarDropdown.vue +126 -0
  15. package/lib/{components/NavbarLinks.vue → client/components/NavbarItems.vue} +27 -47
  16. package/lib/{components → client/components}/Page.vue +5 -15
  17. package/lib/{components → client/components}/PageMeta.vue +48 -59
  18. package/lib/{components → client/components}/PageNav.vue +43 -56
  19. package/lib/client/components/Sidebar.vue +13 -0
  20. package/lib/client/components/SidebarItem.vue +80 -0
  21. package/lib/client/components/SidebarItems.vue +54 -0
  22. package/lib/client/components/ToggleDarkModeButton.vue +57 -0
  23. package/lib/client/components/ToggleSidebarButton.vue +24 -0
  24. package/lib/client/components/global/Badge.vue +31 -0
  25. package/lib/client/components/global/CodeGroup.d.ts +5 -0
  26. package/lib/client/components/global/CodeGroup.js +107 -0
  27. package/lib/client/components/global/CodeGroupItem.vue +31 -0
  28. package/lib/{composables → client/composables}/index.d.ts +2 -0
  29. package/lib/{composables → client/composables}/index.js +2 -0
  30. package/lib/client/composables/useDarkMode.d.ts +12 -0
  31. package/lib/client/composables/useDarkMode.js +57 -0
  32. package/lib/{composables → client/composables}/useNavLink.d.ts +6 -1
  33. package/lib/{composables → client/composables}/useNavLink.js +0 -0
  34. package/lib/{composables → client/composables}/useResolveRouteWithRedirect.d.ts +1 -1
  35. package/lib/{composables → client/composables}/useResolveRouteWithRedirect.js +1 -1
  36. package/lib/client/composables/useScrollPromise.d.ts +6 -0
  37. package/lib/client/composables/useScrollPromise.js +14 -0
  38. package/lib/{composables → client/composables}/useSidebarItems.d.ts +12 -7
  39. package/lib/client/composables/useSidebarItems.js +120 -0
  40. package/lib/{composables → client/composables}/useThemeData.d.ts +2 -2
  41. package/lib/{composables → client/composables}/useThemeData.js +1 -1
  42. package/lib/client/index.d.ts +4 -0
  43. package/lib/client/index.js +2 -0
  44. package/lib/client/layouts/404.vue +25 -0
  45. package/lib/client/layouts/Layout.vue +128 -0
  46. package/lib/{shim.d.ts → client/shim.d.ts} +0 -0
  47. package/lib/{styles/_wrapper.scss → client/styles/_mixins.scss} +7 -2
  48. package/lib/client/styles/_variables.scss +11 -0
  49. package/lib/{styles → client/styles}/arrow.scss +4 -6
  50. package/lib/{styles → client/styles}/badge.scss +9 -11
  51. package/lib/{styles → client/styles}/code-group.scss +9 -2
  52. package/lib/{styles → client/styles}/code.scss +21 -33
  53. package/lib/client/styles/custom-container.scss +88 -0
  54. package/lib/{styles → client/styles}/home.scss +27 -24
  55. package/lib/{styles → client/styles}/index.scss +4 -4
  56. package/lib/{styles → client/styles}/layout.scss +52 -35
  57. package/lib/{styles/dropdown.scss → client/styles/navbar-dropdown.scss} +37 -47
  58. package/lib/client/styles/navbar.scss +177 -0
  59. package/lib/client/styles/normalize.scss +172 -0
  60. package/lib/{styles → client/styles}/page.scss +15 -8
  61. package/lib/client/styles/sidebar.scss +134 -0
  62. package/lib/{styles → client/styles}/toc.scss +0 -0
  63. package/lib/client/styles/transitions.scss +22 -0
  64. package/lib/client/styles/vars-dark.scss +46 -0
  65. package/lib/client/styles/vars.scss +133 -0
  66. package/lib/{utils → client/utils}/index.d.ts +1 -0
  67. package/lib/{utils → client/utils}/index.js +1 -0
  68. package/lib/client/utils/isActiveSidebarItem.d.ts +3 -0
  69. package/lib/client/utils/isActiveSidebarItem.js +20 -0
  70. package/lib/{utils → client/utils}/resolveEditLink.d.ts +1 -1
  71. package/lib/{utils → client/utils}/resolveEditLink.js +14 -8
  72. package/lib/client/utils/resolveRepoType.d.ts +2 -0
  73. package/lib/{utils → client/utils}/resolveRepoType.js +3 -1
  74. package/lib/node/defaultTheme.d.ts +10 -0
  75. package/lib/node/defaultTheme.js +122 -0
  76. package/lib/node/index.d.ts +5 -5
  77. package/lib/node/index.js +10 -6
  78. package/lib/node/utils/assignDefaultLocaleOptions.d.ts +7 -0
  79. package/lib/node/{assignDefaultLocaleOptions.js → utils/assignDefaultLocaleOptions.js} +11 -9
  80. package/lib/node/utils/index.d.ts +2 -0
  81. package/lib/node/utils/index.js +18 -0
  82. package/lib/node/utils/resolveContainerPluginOptions.d.ts +8 -0
  83. package/lib/node/utils/resolveContainerPluginOptions.js +22 -0
  84. package/lib/{types → shared}/index.d.ts +0 -0
  85. package/lib/{types → shared}/index.js +5 -1
  86. package/lib/{types → shared}/nav.d.ts +11 -12
  87. package/lib/{types → shared}/nav.js +0 -0
  88. package/lib/{types → shared}/options.d.ts +42 -10
  89. package/lib/{types → shared}/options.js +0 -0
  90. package/lib/{types → shared}/page.d.ts +13 -5
  91. package/lib/{types → shared}/page.js +0 -0
  92. package/package.json +38 -29
  93. package/templates/build.html +33 -0
  94. package/CHANGELOG.md +0 -353
  95. package/lib/clientAppEnhance.js +0 -23
  96. package/lib/clientAppSetup.js +0 -11
  97. package/lib/components/DropdownLink.vue +0 -141
  98. package/lib/components/DropdownTransition.vue +0 -34
  99. package/lib/components/Home.vue +0 -133
  100. package/lib/components/NavLink.vue +0 -105
  101. package/lib/components/Navbar.vue +0 -113
  102. package/lib/components/Sidebar.vue +0 -38
  103. package/lib/components/SidebarChild.d.ts +0 -6
  104. package/lib/components/SidebarChild.js +0 -83
  105. package/lib/components/ToggleSidebarButton.vue +0 -27
  106. package/lib/components/global/Badge.vue +0 -37
  107. package/lib/components/global/CodeGroup.vue +0 -85
  108. package/lib/components/global/CodeGroupItem.vue +0 -25
  109. package/lib/components/global/OutboundLink.vue +0 -30
  110. package/lib/composables/useSidebarItems.js +0 -108
  111. package/lib/index.d.ts +0 -6
  112. package/lib/index.js +0 -67
  113. package/lib/layouts/404.vue +0 -38
  114. package/lib/layouts/Layout.vue +0 -132
  115. package/lib/node/assignDefaultLocaleOptions.d.ts +0 -5
  116. package/lib/node/resolveActiveHeaderLinksPluginOptions.d.ts +0 -6
  117. package/lib/node/resolveActiveHeaderLinksPluginOptions.js +0 -16
  118. package/lib/node/resolveContainerPluginOptions.d.ts +0 -26
  119. package/lib/node/resolveContainerPluginOptions.js +0 -79
  120. package/lib/node/resolveGitPluginOptions.d.ts +0 -6
  121. package/lib/node/resolveGitPluginOptions.js +0 -22
  122. package/lib/node/resolveMediumZoomPluginOptions.d.ts +0 -6
  123. package/lib/node/resolveMediumZoomPluginOptions.js +0 -17
  124. package/lib/styles/_normalize.scss +0 -148
  125. package/lib/styles/_variables.scss +0 -34
  126. package/lib/styles/custom-container.scss +0 -78
  127. package/lib/styles/navbar.scss +0 -140
  128. package/lib/styles/plugins.scss +0 -18
  129. package/lib/styles/sidebar.scss +0 -147
  130. package/lib/styles/sr-only.scss +0 -12
  131. package/lib/styles/transitions.scss +0 -13
  132. package/lib/utils/resolveRepoType.d.ts +0 -2
@@ -1,28 +1,14 @@
1
- <template>
2
- <nav v-if="navbarLinks.length" class="navbar-links">
3
- <div v-for="item in navbarLinks" :key="item.link" class="navbar-links-item">
4
- <template v-if="item.children">
5
- <DropdownLink :item="item" />
6
- </template>
7
-
8
- <template v-else>
9
- <NavLink :item="item" />
10
- </template>
11
- </div>
12
- </nav>
13
- </template>
14
-
15
- <script lang="ts">
16
- import { computed, defineComponent } from 'vue'
1
+ <script setup lang="ts">
2
+ import AutoLink from '@theme/AutoLink.vue'
3
+ import NavbarDropdown from '@theme/NavbarDropdown.vue'
4
+ import { useRouteLocale, useSiteLocaleData } from '@vuepress/client'
5
+ import { isLinkHttp, isString } from '@vuepress/shared'
6
+ import { computed } from 'vue'
17
7
  import type { ComputedRef } from 'vue'
18
8
  import { useRouter } from 'vue-router'
19
- import { useRouteLocale, useSiteLocaleData } from '@vuepress/client'
20
- import { isString } from '@vuepress/shared'
9
+ import type { NavbarGroup, NavbarItem, ResolvedNavbarItem } from '../../shared'
21
10
  import { useNavLink, useThemeLocaleData } from '../composables'
22
- import type { NavbarItem, NavbarGroup, ResolvedNavbarItem } from '../types'
23
11
  import { resolveRepoType } from '../utils'
24
- import DropdownLink from './DropdownLink.vue'
25
- import NavLink from './NavLink.vue'
26
12
 
27
13
  /**
28
14
  * Get navbar config of select language dropdown
@@ -43,7 +29,7 @@ const useNavbarSelectLanguage = (): ComputedRef<ResolvedNavbarItem[]> => {
43
29
  const currentFullPath = router.currentRoute.value.fullPath
44
30
 
45
31
  const languageDropdown: ResolvedNavbarItem = {
46
- text: themeLocale.value.selectLanguageText ?? 'unkown language',
32
+ text: themeLocale.value.selectLanguageText ?? 'unknown language',
47
33
  ariaLabel: themeLocale.value.selectLanguageAriaLabel ?? 'unkown language',
48
34
  children: localePaths.map((targetLocalePath) => {
49
35
  // target locale config of this langauge link
@@ -100,9 +86,10 @@ const useNavbarRepo = (): ComputedRef<ResolvedNavbarItem[]> => {
100
86
  )
101
87
 
102
88
  const repoLink = computed(() => {
103
- if (repoType.value === 'GitHub') {
89
+ if (repo.value && !isLinkHttp(repo.value)) {
104
90
  return `https://github.com/${repo.value}`
105
91
  }
92
+
106
93
  return repo.value
107
94
  })
108
95
 
@@ -147,28 +134,21 @@ const useNavbarConfig = (): ComputedRef<ResolvedNavbarItem[]> => {
147
134
  return computed(() => (themeLocale.value.navbar || []).map(resolveNavbarItem))
148
135
  }
149
136
 
150
- export default defineComponent({
151
- name: 'NavbarLinks',
152
-
153
- components: {
154
- NavLink,
155
- DropdownLink,
156
- },
157
-
158
- setup() {
159
- const navbarConfig = useNavbarConfig()
160
- const navbarSelectLanguage = useNavbarSelectLanguage()
161
- const navbarRepo = useNavbarRepo()
162
-
163
- const navbarLinks = computed(() => [
164
- ...navbarConfig.value,
165
- ...navbarSelectLanguage.value,
166
- ...navbarRepo.value,
167
- ])
168
-
169
- return {
170
- navbarLinks,
171
- }
172
- },
173
- })
137
+ const navbarConfig = useNavbarConfig()
138
+ const navbarSelectLanguage = useNavbarSelectLanguage()
139
+ const navbarRepo = useNavbarRepo()
140
+ const navbarLinks = computed(() => [
141
+ ...navbarConfig.value,
142
+ ...navbarSelectLanguage.value,
143
+ ...navbarRepo.value,
144
+ ])
174
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,18 +18,3 @@
13
18
  <slot name="bottom" />
14
19
  </main>
15
20
  </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,24 @@
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
- <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'
31
- import type { ComputedRef } from 'vue'
1
+ <script setup lang="ts">
2
+ import AutoLink from '@theme/AutoLink.vue'
32
3
  import {
33
4
  usePageData,
34
5
  usePageFrontmatter,
35
6
  useSiteLocaleData,
36
7
  } from '@vuepress/client'
8
+ import { computed } from 'vue'
9
+ import type { ComputedRef } from 'vue'
10
+ import type {
11
+ DefaultThemeNormalPageFrontmatter,
12
+ DefaultThemePageData,
13
+ NavLink,
14
+ } from '../../shared'
37
15
  import { useThemeLocaleData } from '../composables'
38
- import type { DefaultThemePageData, NavLink as NavLinkType } from '../types'
39
16
  import { resolveEditLink } from '../utils'
40
- import NavLink from './NavLink.vue'
41
17
 
42
- const useEditNavLink = (): ComputedRef<null | NavLinkType> => {
18
+ const useEditNavLink = (): ComputedRef<null | NavLink> => {
43
19
  const themeLocale = useThemeLocaleData()
44
20
  const page = usePageData<DefaultThemePageData>()
45
- const frontmatter = usePageFrontmatter()
21
+ const frontmatter = usePageFrontmatter<DefaultThemeNormalPageFrontmatter>()
46
22
 
47
23
  return computed(() => {
48
24
  const showEditLink =
@@ -66,7 +42,8 @@ const useEditNavLink = (): ComputedRef<null | NavLinkType> => {
66
42
  docsBranch,
67
43
  docsDir,
68
44
  filePathRelative: page.value.filePathRelative,
69
- editLinkPattern: themeLocale.value.editLinkPattern,
45
+ editLinkPattern:
46
+ frontmatter.value.editLinkPattern ?? themeLocale.value.editLinkPattern,
70
47
  })
71
48
 
72
49
  if (!editLink) return null
@@ -79,10 +56,9 @@ const useEditNavLink = (): ComputedRef<null | NavLinkType> => {
79
56
  }
80
57
 
81
58
  const useLastUpdated = (): ComputedRef<null | string> => {
82
- const siteLocale = useSiteLocaleData()
83
59
  const themeLocale = useThemeLocaleData()
84
60
  const page = usePageData<DefaultThemePageData>()
85
- const frontmatter = usePageFrontmatter()
61
+ const frontmatter = usePageFrontmatter<DefaultThemeNormalPageFrontmatter>()
86
62
 
87
63
  return computed(() => {
88
64
  const showLastUpdated =
@@ -94,7 +70,7 @@ const useLastUpdated = (): ComputedRef<null | string> => {
94
70
 
95
71
  const updatedDate = new Date(page.value.git?.updatedTime)
96
72
 
97
- return updatedDate.toLocaleString(siteLocale.value.lang)
73
+ return updatedDate.toLocaleString()
98
74
  })
99
75
  }
100
76
 
@@ -103,7 +79,7 @@ const useContributors = (): ComputedRef<
103
79
  > => {
104
80
  const themeLocale = useThemeLocaleData()
105
81
  const page = usePageData<DefaultThemePageData>()
106
- const frontmatter = usePageFrontmatter()
82
+ const frontmatter = usePageFrontmatter<DefaultThemeNormalPageFrontmatter>()
107
83
 
108
84
  return computed(() => {
109
85
  const showContributors =
@@ -115,25 +91,38 @@ const useContributors = (): ComputedRef<
115
91
  })
116
92
  }
117
93
 
118
- export default defineComponent({
119
- name: 'PageMeta',
94
+ const themeLocale = useThemeLocaleData()
95
+ const editNavLink = useEditNavLink()
96
+ const lastUpdated = useLastUpdated()
97
+ const contributors = useContributors()
98
+ </script>
120
99
 
121
- components: {
122
- NavLink,
123
- },
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>
124
105
 
125
- setup() {
126
- const themeLocale = useThemeLocaleData()
127
- const editNavLink = useEditNavLink()
128
- const lastUpdated = useLastUpdated()
129
- const contributors = useContributors()
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>
130
112
 
131
- return {
132
- themeLocale,
133
- editNavLink,
134
- lastUpdated,
135
- contributors,
136
- }
137
- },
138
- })
139
- </script>
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,34 +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
- ←
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'
5
+ import { computed } from 'vue'
6
+ import { useRoute } from 'vue-router'
7
+ import type {
8
+ DefaultThemeNormalPageFrontmatter,
9
+ NavLink,
10
+ ResolvedSidebarItem,
11
+ } from '../../shared'
22
12
  import { useNavLink, useSidebarItems } from '../composables'
23
- import type { NavLink as NavLinkType, ResolvedSidebarItem } from '../types'
24
- import NavLink from './NavLink.vue'
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 | NavLinkType => {
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<NavLinkType>(conf)) {
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 | NavLinkType => {
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 NavLinkType
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
- export default defineComponent({
81
- name: 'PageNav',
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
- return resolveFromSidebarItems(sidebarItems.value, route.path, -1)
99
- })
72
+ const prevNavLink = computed(() => {
73
+ const prevConfig = resolveFromFrontmatterConfig(frontmatter.value.prev)
74
+ if (prevConfig !== false) {
75
+ return prevConfig
76
+ }
100
77
 
101
- const nextNavLink = computed(() => {
102
- const nextConfig = resolveFromFrontmatterConfig(frontmatter.value.next)
103
- if (nextConfig !== false) {
104
- return nextConfig
105
- }
78
+ return resolveFromSidebarItems(sidebarItems.value, route.path, -1)
79
+ })
106
80
 
107
- return resolveFromSidebarItems(sidebarItems.value, route.path, 1)
108
- })
81
+ const nextNavLink = computed(() => {
82
+ const nextConfig = resolveFromFrontmatterConfig(frontmatter.value.next)
83
+ if (nextConfig !== false) {
84
+ return nextConfig
85
+ }
109
86
 
110
- return {
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,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,54 @@
1
+ <script setup lang="ts">
2
+ import SidebarItem from '@theme/SidebarItem.vue'
3
+ import { watch } from 'vue'
4
+ import { useRoute } from 'vue-router'
5
+ import { useSidebarItems } from '../composables'
6
+
7
+ const route = useRoute()
8
+ const sidebarItems = useSidebarItems()
9
+
10
+ watch(
11
+ () => route.hash,
12
+ (hash) => {
13
+ // get the sidebar DOM
14
+ const sidebar = document.querySelector('.sidebar')
15
+ if (!sidebar) return
16
+
17
+ // get the active sidebar item DOM, whose href equals to the current route
18
+ const activeSidebarItem = document.querySelector(
19
+ `.sidebar a.sidebar-item[href="${route.path}${hash}"]`
20
+ )
21
+ if (!activeSidebarItem) return
22
+
23
+ // get the top and height of the sidebar
24
+ const sidebarTop = sidebar.getBoundingClientRect().top
25
+ const sidebarHeight = sidebar.getBoundingClientRect().height
26
+
27
+ // get the top and height of the active sidebar item
28
+ const activeSidebarItemTop = activeSidebarItem.getBoundingClientRect().top
29
+ const activeSidebarItemHeight =
30
+ activeSidebarItem.getBoundingClientRect().height
31
+
32
+ if (activeSidebarItemTop < sidebarTop) {
33
+ // scroll to the top edge of sidebar when the active sidebar item overflows the top edge of sidebar
34
+ activeSidebarItem.scrollIntoView(true)
35
+ } else if (
36
+ activeSidebarItemTop + activeSidebarItemHeight >
37
+ sidebarTop + sidebarHeight
38
+ ) {
39
+ // scroll to the bottom edge of sidebar when the active sidebar item overflows the bottom edge of sidebar
40
+ activeSidebarItem.scrollIntoView(false)
41
+ }
42
+ }
43
+ )
44
+ </script>
45
+
46
+ <template>
47
+ <ul v-if="sidebarItems.length" class="sidebar-items">
48
+ <SidebarItem
49
+ v-for="item in sidebarItems"
50
+ :key="item.link || item.text"
51
+ :item="item"
52
+ />
53
+ </ul>
54
+ </template>
@@ -0,0 +1,57 @@
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
+
12
+ <template>
13
+ <button
14
+ class="toggle-dark-button"
15
+ :title="themeLocale.toggleDarkMode"
16
+ @click="toggleDarkMode"
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'
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>