@vuepress/theme-default 2.0.0-beta.43 → 2.0.0-beta.46

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.
@@ -8,7 +8,11 @@ import PageNav from '@theme/PageNav.vue'
8
8
  <slot name="top" />
9
9
 
10
10
  <div class="theme-default-content">
11
+ <slot name="content-top" />
12
+
11
13
  <Content />
14
+
15
+ <slot name="content-bottom" />
12
16
  </div>
13
17
 
14
18
  <PageMeta />
@@ -1,46 +1,49 @@
1
1
  <script setup lang="ts">
2
2
  import SidebarItem from '@theme/SidebarItem.vue'
3
- import { watch } from 'vue'
3
+ import { onMounted, watch } from 'vue'
4
4
  import { useRoute } from 'vue-router'
5
5
  import { useSidebarItems } from '../composables'
6
6
 
7
7
  const route = useRoute()
8
8
  const sidebarItems = useSidebarItems()
9
9
 
10
- watch(
11
- () => route.hash,
12
- (hash) => {
13
- // get the sidebar DOM
14
- const sidebar = document.querySelector('.sidebar')
15
- if (!sidebar) return
10
+ onMounted(() => {
11
+ watch(
12
+ () => route.hash,
13
+ (hash) => {
14
+ // get the sidebar DOM
15
+ const sidebar = document.querySelector('.sidebar')
16
+ if (!sidebar) return
16
17
 
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
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
22
23
 
23
- // get the top and height of the sidebar
24
- const sidebarTop = sidebar.getBoundingClientRect().top
25
- const sidebarHeight = sidebar.getBoundingClientRect().height
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()
26
30
 
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)
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
+ }
41
44
  }
42
- }
43
- )
45
+ )
46
+ })
44
47
  </script>
45
48
 
46
49
  <template>
@@ -1,5 +1,4 @@
1
1
  import type { VNode } from 'vue';
2
- declare const _default: import("vue").DefineComponent<{}, () => VNode<import("vue").RendererNode, import("vue").RendererElement, {
2
+ export declare const CodeGroup: import("vue").DefineComponent<{}, () => VNode<import("vue").RendererNode, import("vue").RendererElement, {
3
3
  [key: string]: any;
4
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<{}>>, {}>;
5
- export default _default;
@@ -1,5 +1,5 @@
1
1
  import { defineComponent, h, onBeforeUpdate, ref } from 'vue';
2
- export default defineComponent({
2
+ export const CodeGroup = defineComponent({
3
3
  name: 'CodeGroup',
4
4
  setup(_, { slots }) {
5
5
  // index of current active item
@@ -0,0 +1,4 @@
1
+ import Badge from './Badge.vue';
2
+ import { CodeGroup } from './CodeGroup';
3
+ import CodeGroupItem from './CodeGroupItem.vue';
4
+ export { Badge, CodeGroup, CodeGroupItem };
@@ -0,0 +1,4 @@
1
+ import Badge from './Badge.vue';
2
+ import { CodeGroup } from './CodeGroup';
3
+ import CodeGroupItem from './CodeGroupItem.vue';
4
+ export { Badge, CodeGroup, CodeGroupItem };
@@ -7,7 +7,10 @@ import { useResolveRouteWithRedirect } from './useResolveRouteWithRedirect';
7
7
  * - Output: { text: 'Home', link: '/' }
8
8
  */
9
9
  export const useNavLink = (item) => {
10
- const resolved = useResolveRouteWithRedirect(item);
10
+ // the route path of vue-router is url-encoded, and we expect users are using
11
+ // non-url-encoded string in theme config, so we need to url-encode it first to
12
+ // resolve the route correctly
13
+ const resolved = useResolveRouteWithRedirect(encodeURI(item));
11
14
  return {
12
15
  text: resolved.meta.title || item,
13
16
  link: resolved.name === '404' ? item : resolved.fullPath,
@@ -0,0 +1,3 @@
1
+ import './styles/index.scss';
2
+ declare const _default: import("@vuepress/client").ClientConfig;
3
+ export default _default;
@@ -0,0 +1,38 @@
1
+ import { defineClientConfig } from '@vuepress/client';
2
+ import { h } from 'vue';
3
+ import { Badge, CodeGroup, CodeGroupItem } from './components/global';
4
+ import { setupDarkMode, setupSidebarItems, useScrollPromise, } from './composables';
5
+ import './styles/index.scss';
6
+ export default defineClientConfig({
7
+ enhance({ app, router }) {
8
+ app.component('Badge', Badge);
9
+ app.component('CodeGroup', CodeGroup);
10
+ app.component('CodeGroupItem', CodeGroupItem);
11
+ // compat with @vuepress/plugin-external-link-icon
12
+ app.component('AutoLinkExternalIcon', () => {
13
+ const ExternalLinkIcon = app.component('ExternalLinkIcon');
14
+ if (ExternalLinkIcon) {
15
+ return h(ExternalLinkIcon);
16
+ }
17
+ return null;
18
+ });
19
+ // compat with @vuepress/plugin-docsearch and @vuepress/plugin-search
20
+ app.component('NavbarSearch', () => {
21
+ const SearchComponent = app.component('Docsearch') || app.component('SearchBox');
22
+ if (SearchComponent) {
23
+ return h(SearchComponent);
24
+ }
25
+ return null;
26
+ });
27
+ // handle scrollBehavior with transition
28
+ const scrollBehavior = router.options.scrollBehavior;
29
+ router.options.scrollBehavior = async (...args) => {
30
+ await useScrollPromise().wait();
31
+ return scrollBehavior(...args);
32
+ };
33
+ },
34
+ setup() {
35
+ setupDarkMode();
36
+ setupSidebarItems();
37
+ },
38
+ });
@@ -118,6 +118,12 @@ const onBeforeLeave = scrollPromise.pending
118
118
  <template #top>
119
119
  <slot name="page-top" />
120
120
  </template>
121
+ <template #content-top>
122
+ <slot name="page-content-top" />
123
+ </template>
124
+ <template #content-bottom>
125
+ <slot name="page-content-bottom" />
126
+ </template>
121
127
  <template #bottom>
122
128
  <slot name="page-bottom" />
123
129
  </template>
@@ -218,17 +218,19 @@ div[class*='language-'] {
218
218
  color: var(--code-ln-color);
219
219
  padding-top: 1.25rem;
220
220
  line-height: 1.4;
221
-
222
- br {
223
- user-select: none;
224
- }
221
+ counter-reset: line-number;
225
222
 
226
223
  .line-number {
227
224
  position: relative;
228
225
  z-index: 3;
229
226
  user-select: none;
230
- font-size: 0.85em;
231
- line-height: 0;
227
+ height: 1.4em;
228
+
229
+ &::before {
230
+ counter-increment: line-number;
231
+ content: counter(line-number);
232
+ font-size: 0.85em;
233
+ }
232
234
  }
233
235
  }
234
236
 
@@ -10,11 +10,15 @@ html.dark {
10
10
  color-scheme: dark;
11
11
  }
12
12
 
13
+ html {
14
+ font-size: 16px;
15
+ }
16
+
13
17
  body {
14
18
  font-family: var(--font-family);
15
19
  -webkit-font-smoothing: antialiased;
16
20
  -moz-osx-font-smoothing: grayscale;
17
- font-size: 16px;
21
+ font-size: 1rem;
18
22
  color: var(--c-text);
19
23
  }
20
24
 
@@ -46,7 +50,7 @@ code {
46
50
  padding: 0.25rem 0.5rem;
47
51
  margin: 0;
48
52
  font-size: 0.85em;
49
- background-color: var(--c-bg-light);
53
+ background-color: var(--c-bg-lighter);
50
54
  border-radius: 3px;
51
55
  overflow-wrap: break-word;
52
56
  transition: background-color var(--t-color);
@@ -27,8 +27,7 @@ const defaultTheme = ({ themePlugins = {}, ...localeOptions } = {}) => {
27
27
  `@theme/${file}`,
28
28
  utils_1.path.resolve(__dirname, '../client/components', file),
29
29
  ])),
30
- clientAppEnhanceFiles: utils_1.path.resolve(__dirname, '../client/clientAppEnhance.js'),
31
- clientAppSetupFiles: utils_1.path.resolve(__dirname, '../client/clientAppSetup.js'),
30
+ clientConfigFile: utils_1.path.resolve(__dirname, '../client/config.js'),
32
31
  extendsPage: (page) => {
33
32
  // save relative file path into page data to generate edit link
34
33
  page.data.filePathRelative = page.filePathRelative;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vuepress/theme-default",
3
- "version": "2.0.0-beta.43",
3
+ "version": "2.0.0-beta.46",
4
4
  "description": "Default theme of VuePress",
5
5
  "keywords": [
6
6
  "vuepress-theme",
@@ -25,27 +25,27 @@
25
25
  "templates"
26
26
  ],
27
27
  "dependencies": {
28
- "@vuepress/client": "2.0.0-beta.43",
29
- "@vuepress/core": "2.0.0-beta.43",
30
- "@vuepress/plugin-active-header-links": "2.0.0-beta.43",
31
- "@vuepress/plugin-back-to-top": "2.0.0-beta.43",
32
- "@vuepress/plugin-container": "2.0.0-beta.43",
33
- "@vuepress/plugin-external-link-icon": "2.0.0-beta.43",
34
- "@vuepress/plugin-git": "2.0.0-beta.43",
35
- "@vuepress/plugin-medium-zoom": "2.0.0-beta.43",
36
- "@vuepress/plugin-nprogress": "2.0.0-beta.43",
37
- "@vuepress/plugin-palette": "2.0.0-beta.43",
38
- "@vuepress/plugin-prismjs": "2.0.0-beta.43",
39
- "@vuepress/plugin-theme-data": "2.0.0-beta.43",
40
- "@vuepress/shared": "2.0.0-beta.43",
41
- "@vuepress/utils": "2.0.0-beta.43",
42
- "@vueuse/core": "^8.2.1",
28
+ "@vuepress/client": "2.0.0-beta.46",
29
+ "@vuepress/core": "2.0.0-beta.46",
30
+ "@vuepress/plugin-active-header-links": "2.0.0-beta.46",
31
+ "@vuepress/plugin-back-to-top": "2.0.0-beta.46",
32
+ "@vuepress/plugin-container": "2.0.0-beta.46",
33
+ "@vuepress/plugin-external-link-icon": "2.0.0-beta.46",
34
+ "@vuepress/plugin-git": "2.0.0-beta.46",
35
+ "@vuepress/plugin-medium-zoom": "2.0.0-beta.46",
36
+ "@vuepress/plugin-nprogress": "2.0.0-beta.46",
37
+ "@vuepress/plugin-palette": "2.0.0-beta.46",
38
+ "@vuepress/plugin-prismjs": "2.0.0-beta.46",
39
+ "@vuepress/plugin-theme-data": "2.0.0-beta.46",
40
+ "@vuepress/shared": "2.0.0-beta.46",
41
+ "@vuepress/utils": "2.0.0-beta.46",
42
+ "@vueuse/core": "^8.4.2",
43
43
  "sass": "^1.51.0",
44
- "vue": "^3.2.33",
45
- "vue-router": "^4.0.14"
44
+ "vue": "^3.2.35",
45
+ "vue-router": "^4.0.15"
46
46
  },
47
47
  "peerDependencies": {
48
- "sass-loader": "^12.6.0"
48
+ "sass-loader": "^13.0.0"
49
49
  },
50
50
  "peerDependenciesMeta": {
51
51
  "sass-loader": {
@@ -1,3 +0,0 @@
1
- import './styles/index.scss';
2
- declare const _default: import("@vuepress/client").ClientAppEnhance;
3
- export default _default;
@@ -1,34 +0,0 @@
1
- import { defineClientAppEnhance } from '@vuepress/client';
2
- import { h } from 'vue';
3
- import Badge from './components/global/Badge.vue';
4
- import CodeGroup from './components/global/CodeGroup';
5
- import CodeGroupItem from './components/global/CodeGroupItem.vue';
6
- import { useScrollPromise } from './composables';
7
- import './styles/index.scss';
8
- export default defineClientAppEnhance(({ app, router }) => {
9
- app.component('Badge', Badge);
10
- app.component('CodeGroup', CodeGroup);
11
- app.component('CodeGroupItem', CodeGroupItem);
12
- // compat with @vuepress/plugin-external-link-icon
13
- app.component('AutoLinkExternalIcon', () => {
14
- const ExternalLinkIcon = app.component('ExternalLinkIcon');
15
- if (ExternalLinkIcon) {
16
- return h(ExternalLinkIcon);
17
- }
18
- return null;
19
- });
20
- // compat with @vuepress/plugin-docsearch and @vuepress/plugin-search
21
- app.component('NavbarSearch', () => {
22
- const SearchComponent = app.component('Docsearch') || app.component('SearchBox');
23
- if (SearchComponent) {
24
- return h(SearchComponent);
25
- }
26
- return null;
27
- });
28
- // handle scrollBehavior with transition
29
- const scrollBehavior = router.options.scrollBehavior;
30
- router.options.scrollBehavior = async (...args) => {
31
- await useScrollPromise().wait();
32
- return scrollBehavior(...args);
33
- };
34
- });
@@ -1,2 +0,0 @@
1
- declare const _default: import("@vuepress/client").ClientAppSetup;
2
- export default _default;
@@ -1,6 +0,0 @@
1
- import { defineClientAppSetup } from '@vuepress/client';
2
- import { setupDarkMode, setupSidebarItems } from './composables';
3
- export default defineClientAppSetup(() => {
4
- setupDarkMode();
5
- setupSidebarItems();
6
- });