@vuepress/theme-default 2.0.0-rc.4 → 2.0.0-rc.41

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 (127) hide show
  1. package/lib/client/components/VPDarkIcon.vue +8 -0
  2. package/lib/client/components/{DropdownTransition.vue → VPDropdownTransition.vue} +10 -1
  3. package/lib/client/components/VPEditIcon.vue +12 -0
  4. package/lib/client/components/VPHome.vue +38 -0
  5. package/lib/client/components/VPHomeFeatures.vue +68 -0
  6. package/lib/client/components/{HomeFooter.vue → VPHomeFooter.vue} +16 -2
  7. package/lib/client/components/{HomeHero.vue → VPHomeHero.vue} +108 -7
  8. package/lib/client/components/VPLightIcon.vue +28 -0
  9. package/lib/client/components/VPNavbar.vue +125 -0
  10. package/lib/client/components/{NavbarBrand.vue → VPNavbarBrand.vue} +39 -6
  11. package/lib/client/components/VPNavbarDropdown.vue +320 -0
  12. package/lib/client/components/VPNavbarItems.vue +110 -0
  13. package/lib/client/components/VPPage.vue +69 -0
  14. package/lib/client/components/VPPageMeta.vue +132 -0
  15. package/lib/client/components/VPPageNav.vue +118 -0
  16. package/lib/client/components/VPSidebar.vue +112 -0
  17. package/lib/client/components/VPSidebarItem.vue +167 -0
  18. package/lib/client/components/{SidebarItems.vue → VPSidebarItems.vue} +31 -7
  19. package/lib/client/components/VPToggleColorModeButton.vue +54 -0
  20. package/lib/client/components/VPToggleSidebarButton.vue +92 -0
  21. package/lib/client/components/global/Badge.vue +60 -18
  22. package/lib/client/components/global/CodeGroup.d.ts +1 -0
  23. package/lib/client/components/global/CodeGroup.js +24 -4
  24. package/lib/client/components/global/CodeGroupItem.vue +5 -16
  25. package/lib/client/composables/index.d.ts +8 -0
  26. package/lib/client/composables/index.js +8 -0
  27. package/lib/client/composables/useContributors.d.ts +3 -0
  28. package/lib/client/composables/useContributors.js +14 -0
  29. package/lib/client/composables/useDarkMode.d.ts +0 -1
  30. package/lib/client/composables/useDarkMode.js +14 -13
  31. package/lib/client/composables/useEditLink.d.ts +3 -0
  32. package/lib/client/composables/useEditLink.js +31 -0
  33. package/lib/client/composables/useLastUpdated.d.ts +2 -0
  34. package/lib/client/composables/useLastUpdated.js +17 -0
  35. package/lib/client/composables/useNavbarConfig.d.ts +3 -0
  36. package/lib/client/composables/useNavbarConfig.js +25 -0
  37. package/lib/client/composables/useNavbarRepo.d.ts +6 -0
  38. package/lib/client/composables/useNavbarRepo.js +38 -0
  39. package/lib/client/composables/useNavbarSelectLanguage.d.ts +6 -0
  40. package/lib/client/composables/useNavbarSelectLanguage.js +58 -0
  41. package/lib/client/composables/useNavigate.d.ts +1 -0
  42. package/lib/client/composables/useNavigate.js +22 -0
  43. package/lib/client/composables/useRelatedLinks.d.ts +8 -0
  44. package/lib/client/composables/useRelatedLinks.js +91 -0
  45. package/lib/client/composables/useSidebarItems.d.ts +17 -12
  46. package/lib/client/composables/useSidebarItems.js +87 -52
  47. package/lib/client/composables/useUpdateDeviceStatus.js +5 -4
  48. package/lib/client/config.d.ts +2 -2
  49. package/lib/client/config.js +12 -13
  50. package/lib/client/index.d.ts +2 -1
  51. package/lib/client/index.js +1 -1
  52. package/lib/client/layouts/Layout.vue +121 -20
  53. package/lib/client/layouts/NotFound.vue +18 -4
  54. package/lib/client/shim.d.ts +3 -3
  55. package/lib/client/styles/_mixins.scss +4 -4
  56. package/lib/client/styles/_variables.module.scss +1 -1
  57. package/lib/client/styles/_variables.scss +1 -0
  58. package/lib/client/styles/arrow.scss +18 -24
  59. package/lib/client/styles/code-group.scss +34 -29
  60. package/lib/client/styles/content/code.scss +23 -0
  61. package/lib/client/styles/{custom-container.scss → content/custom-container.scss} +13 -13
  62. package/lib/client/styles/content/index.scss +4 -0
  63. package/lib/client/styles/content/normalize.scss +39 -0
  64. package/lib/client/styles/{toc.scss → content/toc.scss} +1 -1
  65. package/lib/client/styles/external-link-icon.scss +37 -0
  66. package/lib/client/styles/index.scss +3 -13
  67. package/lib/client/styles/layout.scss +3 -199
  68. package/lib/client/styles/normalize.scss +20 -148
  69. package/lib/client/styles/plugins.scss +20 -0
  70. package/lib/client/styles/vars-dark.scss +17 -12
  71. package/lib/client/styles/vars.scss +72 -34
  72. package/lib/client/typings.d.ts +13 -0
  73. package/lib/client/typings.js +1 -0
  74. package/lib/client/utils/getAutoLink.d.ts +9 -0
  75. package/lib/client/utils/getAutoLink.js +17 -0
  76. package/lib/client/utils/index.d.ts +3 -2
  77. package/lib/client/utils/index.js +3 -2
  78. package/lib/client/utils/isActiveSidebarItem.d.ts +3 -3
  79. package/lib/client/utils/isActiveSidebarItem.js +3 -3
  80. package/lib/client/utils/isLinkInternal.d.ts +1 -0
  81. package/lib/client/utils/isLinkInternal.js +2 -0
  82. package/lib/client/utils/resolveEditLink.d.ts +1 -1
  83. package/lib/client/utils/resolvePrefix.d.ts +1 -0
  84. package/lib/client/utils/resolvePrefix.js +4 -0
  85. package/lib/node/defaultTheme.js +83 -24
  86. package/lib/node/index.d.ts +2 -1
  87. package/lib/node/index.js +1 -1
  88. package/lib/node/utils/assignDefaultLocaleOptions.js +1 -1
  89. package/lib/node/utils/resolveContainerPluginOptions.d.ts +3 -3
  90. package/lib/node/utils/resolveContainerPluginOptions.js +2 -2
  91. package/lib/shared/index.d.ts +2 -0
  92. package/lib/shared/index.js +2 -0
  93. package/lib/shared/nav.d.ts +19 -30
  94. package/lib/shared/navbar.d.ts +21 -0
  95. package/lib/shared/navbar.js +1 -0
  96. package/lib/shared/options.d.ts +31 -8
  97. package/lib/shared/page.d.ts +6 -4
  98. package/lib/shared/sidebar.d.ts +26 -0
  99. package/lib/shared/sidebar.js +1 -0
  100. package/package.json +22 -26
  101. package/templates/build.html +19 -10
  102. package/lib/client/components/AutoLink.vue +0 -113
  103. package/lib/client/components/Home.vue +0 -15
  104. package/lib/client/components/HomeContent.vue +0 -5
  105. package/lib/client/components/HomeFeatures.vue +0 -22
  106. package/lib/client/components/Navbar.vue +0 -79
  107. package/lib/client/components/NavbarDropdown.vue +0 -126
  108. package/lib/client/components/NavbarItems.vue +0 -199
  109. package/lib/client/components/Page.vue +0 -31
  110. package/lib/client/components/PageMeta.vue +0 -124
  111. package/lib/client/components/PageNav.vue +0 -122
  112. package/lib/client/components/Sidebar.vue +0 -18
  113. package/lib/client/components/SidebarItem.vue +0 -87
  114. package/lib/client/components/ToggleColorModeButton.vue +0 -57
  115. package/lib/client/components/ToggleSidebarButton.vue +0 -24
  116. package/lib/client/styles/badge.scss +0 -36
  117. package/lib/client/styles/code.scss +0 -263
  118. package/lib/client/styles/home.scss +0 -168
  119. package/lib/client/styles/navbar-dropdown.scss +0 -183
  120. package/lib/client/styles/navbar.scss +0 -197
  121. package/lib/client/styles/page.scss +0 -87
  122. package/lib/client/styles/sidebar.scss +0 -134
  123. package/lib/client/styles/transitions.scss +0 -22
  124. package/lib/client/utils/getNavLink.d.ts +0 -15
  125. package/lib/client/utils/getNavLink.js +0 -18
  126. package/lib/client/utils/getResolveRouteWithRedirect.d.ts +0 -5
  127. package/lib/client/utils/getResolveRouteWithRedirect.js +0 -22
@@ -1,9 +1,37 @@
1
- import { computed, inject, provide } from 'vue';
2
- import { useRoute, useRouter } from 'vue-router';
3
- import { usePageData, usePageFrontmatter } from 'vuepress/client';
4
- import { isPlainObject, isString, resolveLocalePath } from 'vuepress/shared';
5
- import { getNavLink } from '../utils/index.js';
6
- import { useThemeLocaleData } from './useThemeData.js';
1
+ import { useThemeLocaleData } from '@theme/useThemeData';
2
+ import { getHeaders, keys, startsWith } from '@vuepress/helper/client';
3
+ import { computed, inject, onMounted, provide, ref, watch } from 'vue';
4
+ import { usePageData, usePageFrontmatter, useRoute, useRouteLocale, useRouter, } from 'vuepress/client';
5
+ import { isPlainObject, isString } from 'vuepress/shared';
6
+ import { getAutoLink, isLinkInternal, resolvePrefix } from '../utils/index.js';
7
+ export const headersRef = ref([]);
8
+ export const setupHeaders = () => {
9
+ const router = useRouter();
10
+ const themeLocale = useThemeLocaleData();
11
+ const frontmatter = usePageFrontmatter();
12
+ const levels = computed(() => frontmatter.value.sidebarDepth ?? themeLocale.value.sidebarDepth ?? 2);
13
+ router.beforeEach((to, from) => {
14
+ if (to.path !== from.path) {
15
+ headersRef.value = [];
16
+ }
17
+ });
18
+ const updateHeaders = () => {
19
+ if (levels.value <= 0) {
20
+ headersRef.value = [];
21
+ return;
22
+ }
23
+ headersRef.value = getHeaders({
24
+ selector: [...new Array(6)]
25
+ .map((_, i) => `.theme-default-content h${i + 1}`)
26
+ .join(','),
27
+ levels: [2, levels.value + 1],
28
+ ignore: ['.vp-badge'],
29
+ });
30
+ };
31
+ watch(levels, updateHeaders);
32
+ onMounted(updateHeaders);
33
+ };
34
+ export const useHeaders = () => headersRef;
7
35
  export const sidebarItemsSymbol = Symbol('sidebarItems');
8
36
  /**
9
37
  * Inject sidebar items global computed
@@ -23,8 +51,12 @@ export const setupSidebarItems = () => {
23
51
  const frontmatter = usePageFrontmatter();
24
52
  const page = usePageData();
25
53
  const route = useRoute();
26
- const router = useRouter();
27
- const sidebarItems = computed(() => resolveSidebarItems(frontmatter.value, themeLocale.value, page.value, router, route.path));
54
+ const routeLocale = useRouteLocale();
55
+ const headers = useHeaders();
56
+ const sidebarConfig = computed(() => frontmatter.value.home
57
+ ? false
58
+ : (frontmatter.value.sidebar ?? themeLocale.value.sidebar ?? 'heading'));
59
+ const sidebarItems = computed(() => resolveSidebarItems(sidebarConfig.value, page.value, route.path, routeLocale.value, headers.value));
28
60
  provide(sidebarItemsSymbol, sidebarItems);
29
61
  };
30
62
  /**
@@ -32,87 +64,90 @@ export const setupSidebarItems = () => {
32
64
  *
33
65
  * It should only be resolved and provided once
34
66
  */
35
- export const resolveSidebarItems = (frontmatter, themeLocale, page, router, path) => {
36
- // get sidebar config from frontmatter > theme data
37
- const sidebarConfig = frontmatter.sidebar ?? themeLocale.sidebar ?? 'auto';
38
- const sidebarDepth = frontmatter.sidebarDepth ?? themeLocale.sidebarDepth ?? 2;
67
+ export const resolveSidebarItems = (sidebarConfig, page, path, routeLocale, headers) => {
39
68
  // resolve sidebar items according to the config
40
- if (frontmatter.home || sidebarConfig === false) {
69
+ if (sidebarConfig === false) {
41
70
  return [];
42
71
  }
43
- if (sidebarConfig === 'auto') {
44
- return resolveAutoSidebarItems(page, sidebarDepth);
72
+ if (sidebarConfig === 'heading') {
73
+ return resolveSidebarHeadingItem(page, headers);
45
74
  }
46
75
  if (Array.isArray(sidebarConfig)) {
47
- return resolveArraySidebarItems(page, router, path, sidebarConfig, sidebarDepth);
76
+ return resolveArraySidebarItems(sidebarConfig, headers, path, routeLocale);
48
77
  }
49
78
  if (isPlainObject(sidebarConfig)) {
50
- return resolveMultiSidebarItems(page, router, path, sidebarConfig, sidebarDepth);
79
+ return resolveMultiSidebarItems(sidebarConfig, page, headers, path);
51
80
  }
52
81
  return [];
53
82
  };
54
83
  /**
55
84
  * Util to transform page header to sidebar item
56
85
  */
57
- export const headerToSidebarItem = (header, sidebarDepth) => ({
86
+ export const resolveSidebarHeaderItem = (header) => ({
58
87
  text: header.title,
59
88
  link: header.link,
60
- children: headersToSidebarItemChildren(header.children, sidebarDepth),
89
+ children: resolveSidebarHeaderItems(header.children),
61
90
  });
62
- export const headersToSidebarItemChildren = (headers, sidebarDepth) => sidebarDepth > 0
63
- ? headers.map((header) => headerToSidebarItem(header, sidebarDepth - 1))
64
- : [];
91
+ export const resolveSidebarHeaderItems = (headers) => headers ? headers.map((header) => resolveSidebarHeaderItem(header)) : [];
65
92
  /**
66
- * Resolve sidebar items if the config is `auto`
93
+ * Resolve current page and its header to sidebar items if the config is `heading`
67
94
  */
68
- export const resolveAutoSidebarItems = (page, sidebarDepth) => {
69
- return [
70
- {
71
- text: page.title,
72
- children: headersToSidebarItemChildren(page.headers, sidebarDepth),
73
- },
74
- ];
75
- };
95
+ export const resolveSidebarHeadingItem = (page, headers) => [
96
+ {
97
+ text: page.title,
98
+ children: resolveSidebarHeaderItems(headers),
99
+ },
100
+ ];
76
101
  /**
77
102
  * Resolve sidebar items if the config is an array
78
103
  */
79
- export const resolveArraySidebarItems = (page, router, path, sidebarConfig, sidebarDepth) => {
80
- const handleChildItem = (item) => {
81
- let childItem;
82
- if (isString(item)) {
83
- childItem = getNavLink(router, item);
84
- }
85
- else {
86
- childItem = item;
87
- }
88
- if (childItem.children) {
104
+ export const resolveArraySidebarItems = (sidebarConfig, headers, path, prefix = '') => {
105
+ const handleChildItem = (item, pathPrefix) => {
106
+ const childItem = isString(item)
107
+ ? getAutoLink(resolvePrefix(pathPrefix, item))
108
+ : isString(item.link)
109
+ ? {
110
+ ...item,
111
+ link: isLinkInternal(item.link)
112
+ ? getAutoLink(resolvePrefix(pathPrefix, item.link)).link
113
+ : item.link,
114
+ }
115
+ : item;
116
+ if ('children' in childItem) {
89
117
  return {
90
118
  ...childItem,
91
- children: childItem.children.map((item) => handleChildItem(item)),
119
+ children: childItem.children.map((item) => handleChildItem(item, resolvePrefix(pathPrefix, childItem.prefix))),
92
120
  };
93
121
  }
94
122
  // if the sidebar item is current page and children is not set
95
123
  // use headers of current page as children
96
124
  if (childItem.link === path) {
97
125
  // skip h1 header
98
- const headers = page.headers[0]?.level === 1 ? page.headers[0].children : page.headers;
126
+ const currentHeaders = headers[0]?.level === 1 ? headers[0].children : headers;
99
127
  return {
100
128
  ...childItem,
101
- children: headersToSidebarItemChildren(headers, sidebarDepth),
129
+ children: resolveSidebarHeaderItems(currentHeaders),
102
130
  };
103
131
  }
104
132
  return childItem;
105
133
  };
106
- return sidebarConfig.map((item) => handleChildItem(item));
134
+ return sidebarConfig.map((item) => handleChildItem(item, prefix));
107
135
  };
108
136
  /**
109
137
  * Resolve sidebar items if the config is a key -> value (path-prefix -> array) object
110
138
  */
111
- export const resolveMultiSidebarItems = (page, router, path, sidebarConfig, sidebarDepth) => {
112
- const sidebarPath = resolveLocalePath(sidebarConfig, path);
113
- const matchedSidebarConfig = sidebarConfig[sidebarPath] ?? [];
114
- if (matchedSidebarConfig === 'heading') {
115
- return resolveAutoSidebarItems(page, sidebarDepth);
116
- }
117
- return resolveArraySidebarItems(page, router, path, matchedSidebarConfig, sidebarDepth);
139
+ export const resolveMultiSidebarItems = (sidebarConfig, page, headers, path) => {
140
+ const sidebarRoutes = keys(sidebarConfig).sort((x, y) => y.length - x.length);
141
+ // Find matching config
142
+ for (const base of sidebarRoutes)
143
+ if (startsWith(decodeURI(path), base)) {
144
+ const matched = sidebarConfig[base];
145
+ return matched
146
+ ? matched === 'heading'
147
+ ? resolveSidebarHeadingItem(page, headers)
148
+ : resolveArraySidebarItems(matched, headers, path, base)
149
+ : [];
150
+ }
151
+ console.warn(`${decodeURI(path)} is missing sidebar config.`);
152
+ return [];
118
153
  };
@@ -1,11 +1,12 @@
1
+ import { useEventListener } from '@vueuse/core';
1
2
  import { onMounted } from 'vue';
2
- import cssVars from '../styles/_variables.module.scss?module';
3
+ import cssVariables from '../styles/_variables.module.scss';
3
4
  export var DeviceType;
4
5
  (function (DeviceType) {
5
6
  DeviceType["MOBILE"] = "mobile";
6
7
  })(DeviceType || (DeviceType = {}));
7
8
  const DeviceTypeMap = {
8
- [DeviceType.MOBILE]: Number.parseInt(cssVars.mobile?.replace('px', ''), 10),
9
+ [DeviceType.MOBILE]: Number.parseInt(cssVariables.mobile.replace('px', ''), 10),
9
10
  };
10
11
  /**
11
12
  * add listener to detect screen though device type
@@ -17,9 +18,9 @@ export const useUpdateDeviceStatus = (deviceType, callback) => {
17
18
  throw new Error('device width must be a integer');
18
19
  return;
19
20
  }
21
+ useEventListener('orientationchange', () => callback(width), false);
22
+ useEventListener('resize', () => callback(width), false);
20
23
  onMounted(() => {
21
24
  callback(width);
22
- window.addEventListener('resize', () => callback(width), false);
23
- window.addEventListener('orientationchange', () => callback(width), false);
24
25
  });
25
26
  };
@@ -1,4 +1,4 @@
1
- import type { ClientConfig } from 'vuepress/client';
1
+ import '@vuepress/helper/normalize.css';
2
2
  import './styles/index.scss';
3
- declare const _default: ClientConfig;
3
+ declare const _default: import("vuepress/client").ClientConfig;
4
4
  export default _default;
@@ -1,25 +1,24 @@
1
+ import { setupDarkMode } from '@theme/useDarkMode';
2
+ import { useScrollPromise } from '@theme/useScrollPromise';
3
+ import { setupSidebarItems } from '@theme/useSidebarItems';
4
+ import { hasGlobalComponent } from '@vuepress/helper/client';
1
5
  import { h } from 'vue';
2
6
  import { defineClientConfig } from 'vuepress/client';
3
7
  import { Badge, CodeGroup, CodeGroupItem } from './components/global/index.js';
4
- import { setupDarkMode, setupSidebarItems, useScrollPromise, } from './composables/index.js';
5
8
  import Layout from './layouts/Layout.vue';
6
9
  import NotFound from './layouts/NotFound.vue';
10
+ import '@vuepress/helper/normalize.css';
7
11
  import './styles/index.scss';
8
12
  export default defineClientConfig({
9
13
  enhance({ app, router }) {
10
- app.component('Badge', Badge);
11
- app.component('CodeGroup', CodeGroup);
12
- app.component('CodeGroupItem', CodeGroupItem);
13
- // compat with @vuepress/plugin-external-link-icon
14
- app.component('AutoLinkExternalIcon', () => {
15
- const ExternalLinkIcon = app.component('ExternalLinkIcon');
16
- if (ExternalLinkIcon) {
17
- return h(ExternalLinkIcon);
18
- }
19
- return null;
20
- });
14
+ if (!hasGlobalComponent('Badge'))
15
+ app.component('Badge', Badge);
16
+ if (!hasGlobalComponent('CodeGroup'))
17
+ app.component('CodeGroup', CodeGroup);
18
+ if (!hasGlobalComponent('CodeGroupItem'))
19
+ app.component('CodeGroupItem', CodeGroupItem);
21
20
  // compat with @vuepress/plugin-docsearch and @vuepress/plugin-search
22
- app.component('NavbarSearch', () => {
21
+ app.component('VPSearch', () => {
23
22
  const SearchComponent = app.component('Docsearch') || app.component('SearchBox');
24
23
  if (SearchComponent) {
25
24
  return h(SearchComponent);
@@ -1,3 +1,4 @@
1
- export * from '../shared/index.js';
2
1
  export * from './composables/index.js';
2
+ export * from './typings.js';
3
3
  export * from './utils/index.js';
4
+ export type * from '../shared/index.js';
@@ -1,3 +1,3 @@
1
- export * from '../shared/index.js';
2
1
  export * from './composables/index.js';
2
+ export * from './typings.js';
3
3
  export * from './utils/index.js';
@@ -1,17 +1,14 @@
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
+ import { useScrollPromise } from '@theme/useScrollPromise'
3
+ import { useSidebarItems } from '@theme/useSidebarItems'
4
+ import { useThemeLocaleData } from '@theme/useThemeData'
5
+ import VPHome from '@theme/VPHome.vue'
6
+ import VPNavbar from '@theme/VPNavbar.vue'
7
+ import VPPage from '@theme/VPPage.vue'
8
+ import VPSidebar from '@theme/VPSidebar.vue'
6
9
  import { computed, onMounted, onUnmounted, ref } from 'vue'
7
- import { useRouter } from 'vue-router'
8
- import { usePageData, usePageFrontmatter } from 'vuepress/client'
10
+ import { usePageData, usePageFrontmatter, useRouter } from 'vuepress/client'
9
11
  import type { DefaultThemePageFrontmatter } from '../../shared/index.js'
10
- import {
11
- useScrollPromise,
12
- useSidebarItems,
13
- useThemeLocaleData,
14
- } from '../composables/index.js'
15
12
 
16
13
  defineSlots<{
17
14
  'navbar'?: (props: Record<never, never>) => any
@@ -60,12 +57,21 @@ const onTouchEnd = (e): void => {
60
57
  }
61
58
  }
62
59
 
60
+ // external-link-icon
61
+ const enableExternalLinkIcon = computed(
62
+ () =>
63
+ frontmatter.value.externalLinkIcon ??
64
+ themeLocale.value.externalLinkIcon ??
65
+ true,
66
+ )
67
+
63
68
  // classes
64
69
  const containerClass = computed(() => [
65
70
  {
66
71
  'no-navbar': !shouldShowNavbar.value,
67
72
  'no-sidebar': !sidebarItems.value.length,
68
73
  'sidebar-open': isSidebarOpen.value,
74
+ 'external-link-icon': enableExternalLinkIcon.value,
69
75
  },
70
76
  frontmatter.value.pageClass,
71
77
  ])
@@ -90,37 +96,37 @@ const onBeforeLeave = scrollPromise.pending
90
96
 
91
97
  <template>
92
98
  <div
93
- class="theme-container"
99
+ class="vp-theme-container"
94
100
  :class="containerClass"
95
101
  @touchstart="onTouchStart"
96
102
  @touchend="onTouchEnd"
97
103
  >
98
104
  <slot name="navbar">
99
- <Navbar v-if="shouldShowNavbar" @toggle-sidebar="toggleSidebar">
105
+ <VPNavbar v-if="shouldShowNavbar" @toggle-sidebar="toggleSidebar">
100
106
  <template #before>
101
107
  <slot name="navbar-before" />
102
108
  </template>
103
109
  <template #after>
104
110
  <slot name="navbar-after" />
105
111
  </template>
106
- </Navbar>
112
+ </VPNavbar>
107
113
  </slot>
108
114
 
109
- <div class="sidebar-mask" @click="toggleSidebar(false)" />
115
+ <div class="vp-sidebar-mask" @click="toggleSidebar(false)" />
110
116
 
111
117
  <slot name="sidebar">
112
- <Sidebar>
118
+ <VPSidebar>
113
119
  <template #top>
114
120
  <slot name="sidebar-top" />
115
121
  </template>
116
122
  <template #bottom>
117
123
  <slot name="sidebar-bottom" />
118
124
  </template>
119
- </Sidebar>
125
+ </VPSidebar>
120
126
  </slot>
121
127
 
122
128
  <slot name="page">
123
- <Home v-if="frontmatter.home" />
129
+ <VPHome v-if="frontmatter.home" />
124
130
 
125
131
  <Transition
126
132
  v-else
@@ -129,7 +135,7 @@ const onBeforeLeave = scrollPromise.pending
129
135
  @before-enter="onBeforeEnter"
130
136
  @before-leave="onBeforeLeave"
131
137
  >
132
- <Page :key="page.path">
138
+ <VPPage :key="page.path">
133
139
  <template #top>
134
140
  <slot name="page-top" />
135
141
  </template>
@@ -142,8 +148,103 @@ const onBeforeLeave = scrollPromise.pending
142
148
  <template #bottom>
143
149
  <slot name="page-bottom" />
144
150
  </template>
145
- </Page>
151
+ </VPPage>
146
152
  </Transition>
147
153
  </slot>
148
154
  </div>
149
155
  </template>
156
+
157
+ <style lang="scss">
158
+ @import '../styles/variables';
159
+
160
+ .vp-sidebar-mask {
161
+ position: fixed;
162
+ top: 0;
163
+ left: 0;
164
+ z-index: 9;
165
+
166
+ display: none;
167
+
168
+ width: 100vw;
169
+ height: 100vh;
170
+ }
171
+
172
+ .vp-theme-container {
173
+ // navbar is disabled
174
+ &.no-navbar {
175
+ .vp-sidebar {
176
+ top: 0;
177
+
178
+ @media (max-width: $MQMobile) {
179
+ padding-top: 0;
180
+ }
181
+ }
182
+
183
+ .vp-page {
184
+ padding-top: 0;
185
+ }
186
+
187
+ // adjust heading margin and padding;
188
+ .theme-default-content {
189
+ h1,
190
+ h2,
191
+ h3,
192
+ h4,
193
+ h5,
194
+ h6 {
195
+ margin-top: 1.5rem;
196
+ padding-top: 0;
197
+ }
198
+ }
199
+ }
200
+
201
+ &.no-sidebar {
202
+ // hide sidebar
203
+ .vp-sidebar {
204
+ display: none;
205
+
206
+ // show sidebar on mobile because it has navbar links
207
+ @media (max-width: $MQMobile) {
208
+ display: block;
209
+ }
210
+ }
211
+
212
+ .vp-page {
213
+ padding-left: 0;
214
+ }
215
+ }
216
+
217
+ &.sidebar-open {
218
+ @media (max-width: $MQMobile) {
219
+ // show sidebar
220
+ .vp-sidebar {
221
+ transform: translateX(0);
222
+ }
223
+
224
+ // show sidebar mask
225
+ .vp-sidebar-mask {
226
+ display: block;
227
+ }
228
+ }
229
+ }
230
+ }
231
+
232
+ /**
233
+ * fade-slide-y transition
234
+ */
235
+ .fade-slide-y {
236
+ &-enter-active {
237
+ transition: all 0.2s ease;
238
+ }
239
+
240
+ &-leave-active {
241
+ transition: all 0.2s cubic-bezier(1, 0.5, 0.8, 1);
242
+ }
243
+
244
+ &-enter-from,
245
+ &-leave-to {
246
+ opacity: 0;
247
+ transform: translateY(10px);
248
+ }
249
+ }
250
+ </style>
@@ -1,6 +1,6 @@
1
1
  <script setup lang="ts">
2
- import { useRouteLocale } from 'vuepress/client'
3
- import { useThemeLocaleData } from '../composables/index.js'
2
+ import { useThemeLocaleData } from '@theme/useThemeData'
3
+ import { RouteLink, useRouteLocale } from 'vuepress/client'
4
4
 
5
5
  const routeLocale = useRouteLocale()
6
6
  const themeLocale = useThemeLocaleData()
@@ -13,15 +13,29 @@ const homeText = themeLocale.value.backToHome ?? 'Back to home'
13
13
  </script>
14
14
 
15
15
  <template>
16
- <div class="theme-container">
16
+ <div class="vp-theme-container">
17
17
  <main class="page">
18
18
  <div class="theme-default-content">
19
19
  <h1>404</h1>
20
20
 
21
21
  <blockquote>{{ getMsg() }}</blockquote>
22
22
 
23
- <RouterLink :to="homeLink">{{ homeText }}</RouterLink>
23
+ <RouteLink :to="homeLink">{{ homeText }}</RouteLink>
24
24
  </div>
25
25
  </main>
26
26
  </div>
27
27
  </template>
28
+
29
+ <style scoped lang="scss">
30
+ .vp-theme-container {
31
+ max-width: 740px;
32
+ margin: 0 auto;
33
+ padding: 2rem 2.5rem;
34
+ }
35
+
36
+ @media (max-width: 959px) {
37
+ .vp-theme-container {
38
+ padding: 2rem;
39
+ }
40
+ }
41
+ </style>
@@ -4,7 +4,7 @@ declare module '*.vue' {
4
4
  export default comp
5
5
  }
6
6
 
7
- declare module '*.module.scss?module' {
8
- const cssVars: Record<string, string>
9
- export default cssVars
7
+ declare module '*/styles/_variables.module.scss' {
8
+ const cSSVariables: Record<string, string>
9
+ export default cSSVariables
10
10
  }
@@ -1,6 +1,6 @@
1
- @import '_variables';
1
+ @import 'variables';
2
2
 
3
- @mixin content_wrapper {
3
+ @mixin content-wrapper {
4
4
  max-width: var(--content-width);
5
5
  margin: 0 auto;
6
6
  padding: 2rem 2.5rem;
@@ -14,7 +14,7 @@
14
14
  }
15
15
  }
16
16
 
17
- @mixin dropdown_wrapper {
18
- transition: height 0.1s ease-out;
17
+ @mixin dropdown-wrapper {
19
18
  overflow: hidden;
19
+ transition: height 0.1s ease-out;
20
20
  }
@@ -1,4 +1,4 @@
1
- @import '_variables';
1
+ @import 'variables';
2
2
 
3
3
  :export {
4
4
  mobile: $MQMobile;
@@ -1,3 +1,4 @@
1
+ /* stylelint-disable scss/dollar-variable-pattern */
1
2
  @import '@vuepress/plugin-palette/palette';
2
3
 
3
4
  // responsive breakpoints
@@ -1,37 +1,31 @@
1
1
  .arrow {
2
2
  display: inline-block;
3
- width: 0;
4
- height: 0;
5
-
6
- &.up {
7
- border: {
8
- left: 4px solid transparent;
9
- right: 4px solid transparent;
10
- bottom: 6px solid var(--c-bg-arrow);
11
- }
3
+ vertical-align: middle;
4
+
5
+ width: 1em;
6
+ height: 1em;
7
+
8
+ background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath fill='rgba(0,0,0,0.5)' d='M7.41 15.41L12 10.83l4.59 4.58L18 14l-6-6-6 6z'/%3E%3C/svg%3E");
9
+ background-position: center;
10
+ background-repeat: no-repeat;
11
+
12
+ line-height: normal;
13
+
14
+ transition: all 0.3s;
15
+
16
+ html.dark & {
17
+ background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath fill='rgba(255,255,255,0.5)' d='M7.41 15.41L12 10.83l4.59 4.58L18 14l-6-6-6 6z'/%3E%3C/svg%3E");
12
18
  }
13
19
 
14
20
  &.down {
15
- border: {
16
- left: 4px solid transparent;
17
- right: 4px solid transparent;
18
- top: 6px solid var(--c-bg-arrow);
19
- }
21
+ transform: rotate(180deg);
20
22
  }
21
23
 
22
24
  &.right {
23
- border: {
24
- top: 4px solid transparent;
25
- bottom: 4px solid transparent;
26
- left: 6px solid var(--c-bg-arrow);
27
- }
25
+ transform: rotate(90deg);
28
26
  }
29
27
 
30
28
  &.left {
31
- border: {
32
- top: 4px solid transparent;
33
- bottom: 4px solid transparent;
34
- right: 6px solid var(--c-bg-arrow);
35
- }
29
+ transform: rotate(-90deg);
36
30
  }
37
31
  }