@vuepress/theme-default 2.0.0-rc.8 → 2.0.0-rc.80

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 (149) hide show
  1. package/lib/client/components/VPAutoLink.vue +32 -0
  2. package/lib/client/components/VPDarkIcon.vue +8 -0
  3. package/lib/client/components/VPDropdownTransition.vue +43 -0
  4. package/lib/client/components/VPEditIcon.vue +12 -0
  5. package/lib/client/components/VPFadeSlideYTransition.vue +43 -0
  6. package/lib/client/components/VPHome.vue +38 -0
  7. package/lib/client/components/VPHomeFeatures.vue +65 -0
  8. package/lib/client/components/{HomeFooter.vue → VPHomeFooter.vue} +16 -3
  9. package/lib/client/components/VPHomeHero.vue +185 -0
  10. package/lib/client/components/VPLightIcon.vue +28 -0
  11. package/lib/client/components/VPNavbar.vue +134 -0
  12. package/lib/client/components/{NavbarBrand.vue → VPNavbarBrand.vue} +41 -16
  13. package/lib/client/components/VPNavbarDropdown.vue +331 -0
  14. package/lib/client/components/VPNavbarItems.vue +111 -0
  15. package/lib/client/components/VPPage.vue +69 -0
  16. package/lib/client/components/VPPageMeta.vue +134 -0
  17. package/lib/client/components/VPPageNav.vue +125 -0
  18. package/lib/client/components/VPSidebar.vue +113 -0
  19. package/lib/client/components/VPSidebarItem.vue +186 -0
  20. package/lib/client/components/{SidebarItems.vue → VPSidebarItems.vue} +27 -7
  21. package/lib/client/components/VPToggleColorModeButton.vue +55 -0
  22. package/lib/client/components/VPToggleSidebarButton.vue +92 -0
  23. package/lib/client/components/global/Badge.vue +84 -18
  24. package/lib/client/components/global/index.d.ts +1 -3
  25. package/lib/client/components/global/index.js +1 -3
  26. package/lib/client/composables/index.d.ts +9 -1
  27. package/lib/client/composables/index.js +9 -1
  28. package/lib/client/composables/useContributors.d.ts +3 -0
  29. package/lib/client/composables/useContributors.js +11 -0
  30. package/lib/client/composables/useDarkMode.d.ts +0 -1
  31. package/lib/client/composables/useDarkMode.js +19 -16
  32. package/lib/client/composables/useData.d.ts +13 -0
  33. package/lib/client/composables/useData.js +15 -0
  34. package/lib/client/composables/useEditLink.d.ts +3 -0
  35. package/lib/client/composables/useEditLink.js +28 -0
  36. package/lib/client/composables/useHeaders.d.ts +9 -0
  37. package/lib/client/composables/useHeaders.js +38 -0
  38. package/lib/client/composables/useLastUpdated.d.ts +2 -0
  39. package/lib/client/composables/useLastUpdated.js +14 -0
  40. package/lib/client/composables/useNavbarConfig.d.ts +3 -0
  41. package/lib/client/composables/useNavbarConfig.js +29 -0
  42. package/lib/client/composables/useNavbarRepo.d.ts +6 -0
  43. package/lib/client/composables/useNavbarRepo.js +38 -0
  44. package/lib/client/composables/useNavbarSelectLanguage.d.ts +6 -0
  45. package/lib/client/composables/useNavbarSelectLanguage.js +55 -0
  46. package/lib/client/composables/useNavigate.d.ts +1 -0
  47. package/lib/client/composables/useNavigate.js +22 -0
  48. package/lib/client/composables/useRelatedLinks.d.ts +8 -0
  49. package/lib/client/composables/useRelatedLinks.js +90 -0
  50. package/lib/client/composables/useScrollPromise.js +3 -1
  51. package/lib/client/composables/useSidebarItems.d.ts +21 -21
  52. package/lib/client/composables/useSidebarItems.js +96 -86
  53. package/lib/client/composables/useUpdateDeviceStatus.d.ts +1 -1
  54. package/lib/client/composables/useUpdateDeviceStatus.js +10 -5
  55. package/lib/client/config.d.ts +3 -2
  56. package/lib/client/config.js +8 -23
  57. package/lib/client/index.d.ts +2 -1
  58. package/lib/client/index.js +0 -1
  59. package/lib/client/layouts/Layout.vue +127 -54
  60. package/lib/client/layouts/NotFound.vue +25 -11
  61. package/lib/client/shim.d.ts +6 -5
  62. package/lib/client/styles/_mixins.scss +4 -4
  63. package/lib/client/styles/_variables.module.scss +1 -1
  64. package/lib/client/styles/_variables.scss +2 -1
  65. package/lib/client/styles/arrow.scss +18 -24
  66. package/lib/client/styles/code-group.scss +35 -30
  67. package/lib/client/styles/content/code.scss +23 -0
  68. package/lib/client/styles/content/index.scss +3 -0
  69. package/lib/client/styles/content/normalize.scss +39 -0
  70. package/lib/client/styles/{toc.scss → content/toc.scss} +1 -1
  71. package/lib/client/styles/external-link-icon.scss +36 -0
  72. package/lib/client/styles/index.scss +3 -13
  73. package/lib/client/styles/layout.scss +5 -197
  74. package/lib/client/styles/normalize.scss +1 -194
  75. package/lib/client/styles/plugins.scss +28 -0
  76. package/lib/client/styles/vars-dark.scss +20 -58
  77. package/lib/client/styles/vars.scss +54 -129
  78. package/lib/client/typings.d.ts +13 -0
  79. package/lib/client/typings.js +1 -0
  80. package/lib/client/utils/index.d.ts +2 -2
  81. package/lib/client/utils/index.js +2 -2
  82. package/lib/client/utils/isActiveSidebarItem.d.ts +3 -3
  83. package/lib/client/utils/isActiveSidebarItem.js +1 -1
  84. package/lib/client/utils/resolveAutoLink.d.ts +9 -0
  85. package/lib/client/utils/resolveAutoLink.js +17 -0
  86. package/lib/client/utils/resolveEditLink.d.ts +3 -3
  87. package/lib/client/utils/resolveEditLink.js +3 -3
  88. package/lib/client/utils/resolvePrefix.d.ts +1 -0
  89. package/lib/client/utils/resolvePrefix.js +4 -0
  90. package/lib/client/utils/resolveRepoType.d.ts +1 -1
  91. package/lib/client/utils/resolveRepoType.js +4 -4
  92. package/lib/node/defaultTheme.d.ts +2 -1
  93. package/lib/node/defaultTheme.js +50 -56
  94. package/lib/node/index.d.ts +2 -3
  95. package/lib/node/index.js +0 -3
  96. package/lib/node/typings.d.ts +58 -0
  97. package/lib/node/typings.js +1 -0
  98. package/lib/node/utils/assignDefaultLocaleOptions.js +3 -7
  99. package/lib/node/utils/index.d.ts +1 -1
  100. package/lib/node/utils/index.js +1 -1
  101. package/lib/node/utils/resolveMarkdownHintLocales.d.ts +9 -0
  102. package/lib/node/utils/resolveMarkdownHintLocales.js +19 -0
  103. package/lib/shared/index.d.ts +5 -3
  104. package/lib/shared/index.js +1 -3
  105. package/lib/shared/nav.d.ts +19 -30
  106. package/lib/shared/navbar.d.ts +21 -0
  107. package/lib/shared/navbar.js +1 -0
  108. package/lib/shared/options.d.ts +36 -65
  109. package/lib/shared/page.d.ts +9 -6
  110. package/lib/shared/sidebar.d.ts +26 -0
  111. package/lib/shared/sidebar.js +1 -0
  112. package/package.json +29 -27
  113. package/templates/build.html +16 -10
  114. package/lib/client/components/AutoLink.vue +0 -113
  115. package/lib/client/components/DropdownTransition.vue +0 -25
  116. package/lib/client/components/Home.vue +0 -15
  117. package/lib/client/components/HomeContent.vue +0 -5
  118. package/lib/client/components/HomeFeatures.vue +0 -22
  119. package/lib/client/components/HomeHero.vue +0 -97
  120. package/lib/client/components/Navbar.vue +0 -79
  121. package/lib/client/components/NavbarDropdown.vue +0 -126
  122. package/lib/client/components/NavbarItems.vue +0 -199
  123. package/lib/client/components/Page.vue +0 -31
  124. package/lib/client/components/PageMeta.vue +0 -124
  125. package/lib/client/components/PageNav.vue +0 -122
  126. package/lib/client/components/Sidebar.vue +0 -18
  127. package/lib/client/components/SidebarItem.vue +0 -87
  128. package/lib/client/components/ToggleColorModeButton.vue +0 -57
  129. package/lib/client/components/ToggleSidebarButton.vue +0 -24
  130. package/lib/client/components/global/CodeGroup.d.ts +0 -6
  131. package/lib/client/components/global/CodeGroup.js +0 -120
  132. package/lib/client/components/global/CodeGroupItem.vue +0 -27
  133. package/lib/client/composables/useThemeData.d.ts +0 -4
  134. package/lib/client/composables/useThemeData.js +0 -3
  135. package/lib/client/styles/badge.scss +0 -36
  136. package/lib/client/styles/code.scss +0 -263
  137. package/lib/client/styles/custom-container.scss +0 -142
  138. package/lib/client/styles/home.scss +0 -168
  139. package/lib/client/styles/navbar-dropdown.scss +0 -183
  140. package/lib/client/styles/navbar.scss +0 -197
  141. package/lib/client/styles/page.scss +0 -87
  142. package/lib/client/styles/sidebar.scss +0 -134
  143. package/lib/client/styles/transitions.scss +0 -22
  144. package/lib/client/utils/getNavLink.d.ts +0 -15
  145. package/lib/client/utils/getNavLink.js +0 -18
  146. package/lib/client/utils/getResolveRouteWithRedirect.d.ts +0 -5
  147. package/lib/client/utils/getResolveRouteWithRedirect.js +0 -22
  148. package/lib/node/utils/resolveContainerPluginOptions.d.ts +0 -8
  149. package/lib/node/utils/resolveContainerPluginOptions.js +0 -17
@@ -0,0 +1,134 @@
1
+ <script setup lang="ts">
2
+ import VPAutoLink from '@theme/VPAutoLink.vue'
3
+ import VPEditIcon from '@theme/VPEditIcon.vue'
4
+ import { useContributors } from '@theme/useContributors'
5
+ import { useData } from '@theme/useData'
6
+ import { useEditLink } from '@theme/useEditLink'
7
+ import { useLastUpdated } from '@theme/useLastUpdated'
8
+
9
+ const { themeLocale } = useData()
10
+ const editLink = useEditLink()
11
+ const lastUpdated = useLastUpdated()
12
+ const contributors = useContributors()
13
+ </script>
14
+
15
+ <template>
16
+ <footer class="vp-page-meta">
17
+ <div v-if="editLink" class="vp-meta-item edit-link">
18
+ <VPAutoLink class="label" :config="editLink">
19
+ <template #before>
20
+ <VPEditIcon />
21
+ </template>
22
+ </VPAutoLink>
23
+ </div>
24
+
25
+ <div class="vp-meta-item git-info">
26
+ <div v-if="lastUpdated" class="vp-meta-item last-updated">
27
+ <span class="meta-item-label">{{ themeLocale.lastUpdatedText }}: </span>
28
+ <ClientOnly>
29
+ <span class="meta-item-info">{{ lastUpdated }}</span>
30
+ </ClientOnly>
31
+ </div>
32
+
33
+ <div
34
+ v-if="contributors && contributors.length"
35
+ class="vp-meta-item contributors"
36
+ >
37
+ <span class="meta-item-label"
38
+ >{{ themeLocale.contributorsText }}:
39
+ </span>
40
+ <span class="meta-item-info">
41
+ <template v-for="(contributor, index) in contributors" :key="index">
42
+ <span class="contributor" :title="`email: ${contributor.email}`">
43
+ {{ contributor.name }}
44
+ </span>
45
+ <template v-if="index !== contributors.length - 1">, </template>
46
+ </template>
47
+ </span>
48
+ </div>
49
+ </div>
50
+ </footer>
51
+ </template>
52
+
53
+ <style lang="scss">
54
+ @use '../styles/mixins';
55
+ @use '../styles/variables' as *;
56
+
57
+ .vp-page-meta {
58
+ @include mixins.content-wrapper;
59
+
60
+ & {
61
+ display: flex;
62
+ flex-wrap: wrap;
63
+ justify-content: space-between;
64
+
65
+ overflow: auto;
66
+
67
+ padding-top: 0.75rem;
68
+ padding-bottom: 0.75rem;
69
+ }
70
+
71
+ @media print {
72
+ margin: 0 !important;
73
+ padding-right: 0 !important;
74
+ padding-left: 0 !important;
75
+ }
76
+
77
+ @media (max-width: $MQMobile) {
78
+ display: block;
79
+ }
80
+
81
+ .vp-meta-item {
82
+ flex-grow: 1;
83
+
84
+ .vp-meta-label {
85
+ font-weight: 500;
86
+
87
+ &:not(a) {
88
+ color: var(--vp-c-text-mute);
89
+ }
90
+ }
91
+
92
+ .vp-meta-info {
93
+ color: var(--vp-c-text-mute);
94
+ font-weight: 400;
95
+ }
96
+ }
97
+
98
+ .git-info {
99
+ text-align: end;
100
+ }
101
+
102
+ .edit-link {
103
+ margin-top: 0.25rem;
104
+ margin-right: 0.5rem;
105
+ margin-bottom: 0.25rem;
106
+ font-size: 14px;
107
+
108
+ @media print {
109
+ display: none;
110
+ }
111
+
112
+ .edit-icon {
113
+ position: relative;
114
+ bottom: -0.125em;
115
+
116
+ width: 1em;
117
+ height: 1em;
118
+ margin-right: 0.25em;
119
+ }
120
+ }
121
+
122
+ .last-updated,
123
+ .contributors {
124
+ margin-top: 0.25rem;
125
+ margin-bottom: 0.25rem;
126
+ font-size: 14px;
127
+
128
+ @media (max-width: $MQMobile) {
129
+ font-size: 13px;
130
+ text-align: start;
131
+ }
132
+ }
133
+ }
134
+ </style>
@@ -0,0 +1,125 @@
1
+ <script setup lang="ts">
2
+ import VPAutoLink from '@theme/VPAutoLink.vue'
3
+ import { useData } from '@theme/useData'
4
+ import { useNavigate } from '@theme/useNavigate'
5
+ import { useRelatedLinks } from '@theme/useRelatedLinks'
6
+ import { useEventListener } from '@vueuse/core'
7
+ import { computed } from 'vue'
8
+
9
+ const { themeLocale } = useData()
10
+ const navigate = useNavigate()
11
+
12
+ const { prevLink, nextLink } = useRelatedLinks()
13
+
14
+ const navbarLabel = computed(
15
+ () => themeLocale.value.pageNavbarLabel ?? 'page navigation',
16
+ )
17
+
18
+ useEventListener('keydown', (event): void => {
19
+ if (event.altKey) {
20
+ if (event.key === 'ArrowRight') {
21
+ if (nextLink.value) {
22
+ navigate(nextLink.value.link)
23
+ event.preventDefault()
24
+ }
25
+ } else if (event.key === 'ArrowLeft') {
26
+ if (prevLink.value) {
27
+ navigate(prevLink.value.link)
28
+ event.preventDefault()
29
+ }
30
+ }
31
+ }
32
+ })
33
+ </script>
34
+
35
+ <template>
36
+ <nav
37
+ v-if="prevLink || nextLink"
38
+ class="vp-page-nav"
39
+ :aria-label="navbarLabel"
40
+ >
41
+ <VPAutoLink v-if="prevLink" class="prev" :config="prevLink">
42
+ <div class="hint">
43
+ <span class="arrow left" />
44
+ {{ themeLocale.prev ?? 'Prev' }}
45
+ </div>
46
+ <div class="link">
47
+ <span class="external-link">{{ prevLink.text }}</span>
48
+ </div>
49
+ </VPAutoLink>
50
+
51
+ <VPAutoLink v-if="nextLink" class="next" :config="nextLink">
52
+ <div class="hint">
53
+ {{ themeLocale.next ?? 'Next' }}
54
+ <span class="arrow right" />
55
+ </div>
56
+ <div class="link">
57
+ <span class="external-link">{{ nextLink.text }}</span>
58
+ </div>
59
+ </VPAutoLink>
60
+ </nav>
61
+ </template>
62
+
63
+ <style lang="scss">
64
+ @use '../styles/variables' as *;
65
+
66
+ .vp-page-nav {
67
+ display: flex;
68
+ flex-wrap: wrap;
69
+
70
+ max-width: var(--content-width, 740px);
71
+ min-height: 2rem;
72
+ margin-top: 0;
73
+ margin-right: auto;
74
+ margin-left: auto;
75
+ padding: 1rem 2rem 0;
76
+ border-top: 1px solid var(--vp-c-gutter);
77
+
78
+ transition: border-top var(--vp-t-color);
79
+
80
+ @media (max-width: $MQNarrow) {
81
+ padding-right: 1rem;
82
+ padding-left: 1rem;
83
+ }
84
+
85
+ @media print {
86
+ display: none;
87
+ }
88
+
89
+ .auto-link {
90
+ display: inline-block;
91
+ flex-grow: 1;
92
+
93
+ margin: 0.25rem;
94
+ padding: 0.25rem 0.5rem;
95
+ border: 1px solid var(--vp-c-gutter);
96
+ border-radius: 0.25rem;
97
+
98
+ &:hover {
99
+ background: var(--vp-c-control);
100
+ }
101
+
102
+ &.external-link::after {
103
+ display: none;
104
+ }
105
+
106
+ &:not(.external-link) .external-link::after {
107
+ display: none;
108
+ }
109
+
110
+ .hint {
111
+ color: var(--vp-c-text-mute);
112
+ font-size: 0.875rem;
113
+ line-height: 2;
114
+ }
115
+ }
116
+
117
+ .prev {
118
+ text-align: start;
119
+ }
120
+
121
+ .next {
122
+ text-align: end;
123
+ }
124
+ }
125
+ </style>
@@ -0,0 +1,113 @@
1
+ <script setup lang="ts">
2
+ import VPNavbarItems from '@theme/VPNavbarItems.vue'
3
+ import VPSidebarItems from '@theme/VPSidebarItems.vue'
4
+ import type { VNode } from 'vue'
5
+
6
+ defineSlots<{
7
+ top?: (props: Record<never, never>) => VNode | VNode[] | null
8
+ bottom?: (props: Record<never, never>) => VNode | VNode[] | null
9
+ }>()
10
+ </script>
11
+
12
+ <template>
13
+ <aside class="vp-sidebar" vp-sidebar>
14
+ <VPNavbarItems />
15
+ <slot name="top" />
16
+ <VPSidebarItems />
17
+ <slot name="bottom" />
18
+ </aside>
19
+ </template>
20
+
21
+ <style lang="scss">
22
+ @use '../styles/variables' as *;
23
+
24
+ .vp-sidebar {
25
+ position: fixed;
26
+
27
+ // leave space for navbar
28
+ top: var(--navbar-height);
29
+ bottom: 0;
30
+ left: 0;
31
+ z-index: 10;
32
+
33
+ overflow-y: auto;
34
+
35
+ box-sizing: border-box;
36
+ width: var(--sidebar-width);
37
+ margin: 0;
38
+ border-right: 1px solid var(--vp-c-border);
39
+
40
+ background-color: var(--vp-sidebar-c-bg);
41
+
42
+ font-size: 16px;
43
+
44
+ transition:
45
+ transform var(--vp-t-transform),
46
+ background-color var(--vp-t-color),
47
+ border-color var(--vp-t-color);
48
+
49
+ scrollbar-color: var(--vp-c-accent-bg) var(--vp-c-gutter);
50
+ scrollbar-width: thin;
51
+
52
+ // narrow desktop / iPad
53
+ @media (max-width: $MQNarrow) {
54
+ width: var(--sidebar-width-mobile);
55
+ font-size: 15px;
56
+ }
57
+
58
+ // wide mobile
59
+ @media (max-width: $MQMobile) {
60
+ top: 0;
61
+
62
+ // leave space for navbar
63
+ padding-top: var(--navbar-height);
64
+ transform: translateX(-100%);
65
+ }
66
+
67
+ &::-webkit-scrollbar {
68
+ width: 7px;
69
+ }
70
+
71
+ &::-webkit-scrollbar-track {
72
+ background-color: var(--vp-c-gutter);
73
+ }
74
+
75
+ &::-webkit-scrollbar-thumb {
76
+ background-color: var(--vp-c-accent-bg);
77
+ }
78
+
79
+ // override styles
80
+ .vp-navbar-items {
81
+ display: none;
82
+ padding: 0.5rem 0 0.75rem;
83
+ border-bottom: 1px solid var(--vp-c-gutter);
84
+ transition: border-color var(--vp-t-color);
85
+
86
+ @media (max-width: $MQMobile) {
87
+ display: block;
88
+
89
+ .vp-navbar-dropdown-item .route-link-active::after {
90
+ top: calc(1rem - 2px);
91
+ }
92
+ }
93
+
94
+ ul {
95
+ margin: 0;
96
+ padding: 0;
97
+ list-style-type: none;
98
+ }
99
+
100
+ .auto-link {
101
+ font-weight: 600;
102
+ }
103
+ }
104
+
105
+ // override styles
106
+ .vp-navbar-item {
107
+ display: block;
108
+ padding: 0.5rem 0 0.5rem 1.5rem;
109
+ font-size: 1.1em;
110
+ line-height: 1.25rem;
111
+ }
112
+ }
113
+ </style>
@@ -0,0 +1,186 @@
1
+ <script setup lang="ts">
2
+ import VPAutoLink from '@theme/VPAutoLink.vue'
3
+ import VPDropdownTransition from '@theme/VPDropdownTransition.vue'
4
+ import { isActiveSidebarItem } from '@theme/isActiveSidebarItem'
5
+ import { useToggle } from '@vueuse/core'
6
+ import { computed, nextTick, onBeforeUnmount, toRefs } from 'vue'
7
+ import { useRoute, useRouter } from 'vuepress/client'
8
+ import type { SidebarGroupItem, SidebarItem } from '../typings.js'
9
+
10
+ const props = withDefaults(
11
+ defineProps<{
12
+ /**
13
+ * The sidebar item to be rendered
14
+ */
15
+ item: SidebarItem
16
+ /**
17
+ * The depth of the current sidebar item
18
+ */
19
+ depth?: number
20
+ }>(),
21
+ { depth: 0 },
22
+ )
23
+
24
+ const { item, depth } = toRefs(props)
25
+ const route = useRoute()
26
+ const router = useRouter()
27
+
28
+ const collapsible = computed(() => (item.value as SidebarGroupItem).collapsible)
29
+ const isActive = computed(() => isActiveSidebarItem(item.value, route))
30
+ const itemClass = computed(() => ({
31
+ 'vp-sidebar-item': true,
32
+ 'vp-sidebar-heading': depth.value === 0,
33
+ 'active': isActive.value,
34
+ 'collapsible': collapsible.value,
35
+ }))
36
+
37
+ const isOpenDefault = computed(() =>
38
+ collapsible.value ? isActive.value : true,
39
+ )
40
+ // eslint-disable-next-line vue/no-ref-object-reactivity-loss
41
+ const [isOpen, toggleIsOpen] = useToggle(isOpenDefault.value)
42
+ const onClick = (e: Event): void => {
43
+ if (collapsible.value) {
44
+ e.preventDefault()
45
+ // toggle open status on click
46
+ toggleIsOpen()
47
+ }
48
+ }
49
+
50
+ // reset open status after navigation
51
+ const unregisterRouterHook = router.afterEach(() => {
52
+ void nextTick(() => {
53
+ isOpen.value = isOpenDefault.value
54
+ })
55
+ })
56
+ onBeforeUnmount(() => {
57
+ unregisterRouterHook()
58
+ })
59
+ </script>
60
+
61
+ <template>
62
+ <li>
63
+ <VPAutoLink v-if="item.link" :class="itemClass" :config="item">
64
+ <template #after>
65
+ <span
66
+ v-if="collapsible"
67
+ class="arrow"
68
+ :class="isOpen ? 'down' : 'right'"
69
+ />
70
+ </template>
71
+ </VPAutoLink>
72
+ <p
73
+ v-else
74
+ tabindex="0"
75
+ :class="itemClass"
76
+ @click="onClick"
77
+ @keydown.enter="onClick"
78
+ >
79
+ {{ item.text }}
80
+ <span
81
+ v-if="collapsible"
82
+ class="arrow"
83
+ :class="isOpen ? 'down' : 'right'"
84
+ />
85
+ </p>
86
+
87
+ <VPDropdownTransition v-if="'children' in item && item.children.length">
88
+ <ul v-show="isOpen" class="vp-sidebar-children">
89
+ <VPSidebarItem
90
+ v-for="child in item.children"
91
+ :key="`${depth}${child.text}${child.link}`"
92
+ :item="child"
93
+ :depth="depth + 1"
94
+ />
95
+ </ul>
96
+ </VPDropdownTransition>
97
+ </li>
98
+ </template>
99
+
100
+ <style lang="scss">
101
+ @use '../styles/mixins';
102
+ @use '../styles/variables' as *;
103
+
104
+ .vp-sidebar-item {
105
+ border-left: 0.25rem solid transparent;
106
+ color: var(--vp-c-text);
107
+ cursor: default;
108
+
109
+ &:focus-visible {
110
+ outline-width: 1px;
111
+ outline-offset: -1px;
112
+ }
113
+
114
+ &.vp-sidebar-heading {
115
+ box-sizing: border-box;
116
+ width: 100%;
117
+ margin: 0;
118
+ padding: 0.35rem 1.5rem 0.35rem 1.25rem;
119
+
120
+ font-weight: bold;
121
+ font-size: 1.1em;
122
+
123
+ transition: color 0.15s ease;
124
+
125
+ + .vp-sidebar-children {
126
+ @include mixins.dropdown-wrapper;
127
+
128
+ margin-bottom: 0.75rem;
129
+ }
130
+ }
131
+
132
+ &.collapsible {
133
+ cursor: pointer;
134
+ }
135
+
136
+ &:not(.vp-sidebar-heading) {
137
+ display: inline-block;
138
+
139
+ box-sizing: border-box;
140
+ width: 100%;
141
+ margin: 0;
142
+ padding: 0.35rem 1rem 0.35rem 2rem;
143
+
144
+ font-weight: 400;
145
+ font-size: 1em;
146
+ line-height: 1.4;
147
+
148
+ + .vp-sidebar-children {
149
+ padding-left: 1rem;
150
+ font-size: 0.95em;
151
+ }
152
+
153
+ .vp-sidebar-children .vp-sidebar-children & {
154
+ padding: 0.25rem 1rem 0.25rem 1.75rem;
155
+
156
+ &.active {
157
+ border-left-color: transparent;
158
+ font-weight: 500;
159
+ }
160
+ }
161
+
162
+ a.vp-sidebar-heading + .vp-sidebar-children &.active {
163
+ border-left-color: transparent;
164
+ }
165
+ }
166
+
167
+ &.active:not(p.vp-sidebar-heading) {
168
+ border-left-color: var(--vp-c-accent);
169
+ color: var(--vp-c-accent);
170
+ font-weight: 600;
171
+ }
172
+
173
+ .auto-link {
174
+ display: block;
175
+ }
176
+
177
+ &.auto-link {
178
+ display: block;
179
+ cursor: pointer;
180
+
181
+ &:hover {
182
+ color: var(--vp-c-accent);
183
+ }
184
+ }
185
+ }
186
+ </style>
@@ -1,8 +1,8 @@
1
1
  <script setup lang="ts">
2
- import SidebarItem from '@theme/SidebarItem.vue'
2
+ import VPSidebarItem from '@theme/VPSidebarItem.vue'
3
+ import { useSidebarItems } from '@theme/useSidebarItems'
3
4
  import { onMounted, watch } from 'vue'
4
- import { useRoute } from 'vue-router'
5
- import { useSidebarItems } from '../composables/index.js'
5
+ import { useRoute } from 'vuepress/client'
6
6
 
7
7
  const route = useRoute()
8
8
  const sidebarItems = useSidebarItems()
@@ -12,12 +12,12 @@ onMounted(() => {
12
12
  () => route.hash,
13
13
  (hash) => {
14
14
  // get the sidebar DOM
15
- const sidebar = document.querySelector('.sidebar')
15
+ const sidebar = document.querySelector('.vp-sidebar')
16
16
  if (!sidebar) return
17
17
 
18
18
  // get the active sidebar item DOM, whose href equals to the current route
19
19
  const activeSidebarItem = document.querySelector(
20
- `.sidebar a.sidebar-item[href="${route.path}${hash}"]`,
20
+ `.vp-sidebar .vp-sidebar-item.auto-link[href="${route.path}${hash}"]`,
21
21
  )
22
22
  if (!activeSidebarItem) return
23
23
 
@@ -47,11 +47,31 @@ onMounted(() => {
47
47
  </script>
48
48
 
49
49
  <template>
50
- <ul v-if="sidebarItems.length" class="sidebar-items">
51
- <SidebarItem
50
+ <ul v-if="sidebarItems.length" class="vp-sidebar-items">
51
+ <VPSidebarItem
52
52
  v-for="item in sidebarItems"
53
53
  :key="`${item.text}${item.link}`"
54
54
  :item="item"
55
55
  />
56
56
  </ul>
57
57
  </template>
58
+
59
+ <style lang="scss">
60
+ @use '../styles/variables' as *;
61
+
62
+ .vp-sidebar-items {
63
+ margin: 0;
64
+ padding: 1.5rem 0;
65
+ list-style-type: none;
66
+
67
+ @media (max-width: $MQMobile) {
68
+ padding: 1rem 0;
69
+ }
70
+
71
+ ul {
72
+ margin: 0;
73
+ padding: 0;
74
+ list-style-type: none;
75
+ }
76
+ }
77
+ </style>
@@ -0,0 +1,55 @@
1
+ <script setup lang="ts">
2
+ import VPDarkIcon from '@theme/VPDarkIcon.vue'
3
+ import VPLightIcon from '@theme/VPLightIcon.vue'
4
+ import { useDarkMode } from '@theme/useDarkMode'
5
+ import { useData } from '@theme/useData'
6
+
7
+ const { themeLocale } = useData()
8
+ const isDarkMode = useDarkMode()
9
+
10
+ const toggleColorMode = (): void => {
11
+ isDarkMode.value = !isDarkMode.value
12
+ }
13
+ </script>
14
+
15
+ <template>
16
+ <button
17
+ type="button"
18
+ class="vp-toggle-color-mode-button"
19
+ :title="themeLocale.toggleColorMode"
20
+ @click="toggleColorMode"
21
+ >
22
+ <VPLightIcon v-show="!isDarkMode" />
23
+ <VPDarkIcon v-show="isDarkMode" />
24
+ </button>
25
+ </template>
26
+
27
+ <style lang="scss">
28
+ .vp-toggle-color-mode-button {
29
+ display: flex;
30
+
31
+ margin: auto;
32
+ margin-left: 1rem;
33
+ border: 0;
34
+
35
+ background: none;
36
+ color: var(--vp-c-text);
37
+
38
+ opacity: 0.8;
39
+ cursor: pointer;
40
+
41
+ @media print {
42
+ display: none;
43
+ }
44
+
45
+ &:hover {
46
+ opacity: 1;
47
+ }
48
+
49
+ .light-icon,
50
+ .dark-icon {
51
+ width: 1.25rem;
52
+ height: 1.25rem;
53
+ }
54
+ }
55
+ </style>