@vuepress/theme-default 2.0.0-rc.34 → 2.0.0-rc.36

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.
@@ -2,6 +2,7 @@
2
2
  import VPPageMeta from '@theme/VPPageMeta.vue'
3
3
  import VPPageNav from '@theme/VPPageNav.vue'
4
4
  import { Content } from 'vuepress/client'
5
+ import { setupHeaders } from '../composables/index.js'
5
6
 
6
7
  defineSlots<{
7
8
  'top'?: (props: Record<never, never>) => any
@@ -9,6 +10,8 @@ defineSlots<{
9
10
  'content-top'?: (props: Record<never, never>) => any
10
11
  'content-bottom'?: (props: Record<never, never>) => any
11
12
  }>()
13
+
14
+ setupHeaders()
12
15
  </script>
13
16
 
14
17
  <template>
@@ -17,7 +17,7 @@ onMounted(() => {
17
17
 
18
18
  // get the active sidebar item DOM, whose href equals to the current route
19
19
  const activeSidebarItem = document.querySelector(
20
- `.vp=sidebar a.vp-sidebar-item[href="${route.path}${hash}"]`,
20
+ `.vp-sidebar a.vp-sidebar-item[href="${route.path}${hash}"]`,
21
21
  )
22
22
  if (!activeSidebarItem) return
23
23
 
@@ -1,8 +1,8 @@
1
1
  import type { ComputedRef } from 'vue';
2
- import type { AutoLinkConfig } from 'vuepress/client';
2
+ import type { AutoLinkOptions } from '../../shared/index.js';
3
3
  interface RelatedLinks {
4
- prevLink: ComputedRef<AutoLinkConfig | null>;
5
- nextLink: ComputedRef<AutoLinkConfig | null>;
4
+ prevLink: ComputedRef<AutoLinkOptions | null>;
5
+ nextLink: ComputedRef<AutoLinkOptions | null>;
6
6
  }
7
7
  export declare const useRelatedLinks: () => RelatedLinks;
8
8
  export {};
@@ -1,42 +1,41 @@
1
1
  import { useSidebarItems } from '@theme/useSidebarItems';
2
+ import { useThemeLocaleData } from '@theme/useThemeData';
2
3
  import { computed } from 'vue';
3
4
  import { resolveRoute, usePageFrontmatter, useRoute } from 'vuepress/client';
4
5
  import { isPlainObject, isString } from 'vuepress/shared';
5
- /**
6
- * Resolve `prev` or `next` config from frontmatter
7
- */
8
- const resolveFromFrontmatterConfig = (conf, current) => {
9
- if (conf === false) {
10
- return null;
6
+ import { getAutoLink } from '../utils/index.js';
7
+ const resolveFromFrontmatterConfig = (config, currentPath) => {
8
+ if (config === false) {
9
+ return false;
11
10
  }
12
- if (isString(conf)) {
13
- const { notFound, meta, path } = resolveRoute(conf, current);
14
- return notFound
15
- ? { text: path, link: path }
16
- : {
17
- text: meta.title || path,
18
- link: path,
19
- };
11
+ if (isString(config)) {
12
+ return getAutoLink(config, currentPath);
20
13
  }
21
- if (isPlainObject(conf)) {
14
+ if (isPlainObject(config)) {
22
15
  return {
23
- ...conf,
24
- link: resolveRoute(conf.link, current).path,
16
+ ...config,
17
+ link: getAutoLink(config.link, currentPath).link,
25
18
  };
26
19
  }
27
- return false;
20
+ return null;
28
21
  };
29
22
  /**
30
23
  * Resolve `prev` or `next` config from sidebar items
31
24
  */
32
25
  const resolveFromSidebarItems = (sidebarItems, currentPath, offset) => {
33
- const index = sidebarItems.findIndex((item) => item.link === currentPath);
34
- if (index !== -1) {
35
- const targetItem = sidebarItems[index + offset];
36
- if (!targetItem?.link) {
26
+ const linkIndex = sidebarItems.findIndex((item) => item.link === currentPath);
27
+ if (linkIndex !== -1) {
28
+ const targetItem = sidebarItems[linkIndex + offset];
29
+ if (!targetItem)
37
30
  return null;
38
- }
39
- return targetItem;
31
+ if (targetItem.link)
32
+ return targetItem;
33
+ if ('prefix' in targetItem && !resolveRoute(targetItem.prefix).notFound)
34
+ return {
35
+ ...targetItem,
36
+ link: targetItem.prefix,
37
+ };
38
+ return null;
40
39
  }
41
40
  for (const item of sidebarItems) {
42
41
  if ('children' in item) {
@@ -46,25 +45,44 @@ const resolveFromSidebarItems = (sidebarItems, currentPath, offset) => {
46
45
  }
47
46
  }
48
47
  }
48
+ const prefixIndex = sidebarItems.findIndex((item) => 'prefix' in item && item.prefix === currentPath);
49
+ if (prefixIndex !== -1) {
50
+ const targetItem = sidebarItems[prefixIndex + offset];
51
+ if (!targetItem)
52
+ return null;
53
+ if (targetItem.link)
54
+ return targetItem;
55
+ if ('prefix' in targetItem && !resolveRoute(targetItem.prefix).notFound)
56
+ return {
57
+ ...targetItem,
58
+ link: targetItem.prefix,
59
+ };
60
+ return null;
61
+ }
49
62
  return null;
50
63
  };
51
64
  export const useRelatedLinks = () => {
52
65
  const frontmatter = usePageFrontmatter();
66
+ const themeLocale = useThemeLocaleData();
53
67
  const sidebarItems = useSidebarItems();
54
68
  const route = useRoute();
55
69
  const prevLink = computed(() => {
56
70
  const prevConfig = resolveFromFrontmatterConfig(frontmatter.value.prev, route.path);
57
- if (prevConfig !== false) {
58
- return prevConfig;
59
- }
60
- return resolveFromSidebarItems(sidebarItems.value, route.path, -1);
71
+ return prevConfig === false
72
+ ? null
73
+ : prevConfig ??
74
+ (themeLocale.value.prev === false
75
+ ? null
76
+ : resolveFromSidebarItems(sidebarItems.value, route.path, -1));
61
77
  });
62
78
  const nextLink = computed(() => {
63
79
  const nextConfig = resolveFromFrontmatterConfig(frontmatter.value.next, route.path);
64
- if (nextConfig !== false) {
65
- return nextConfig;
66
- }
67
- return resolveFromSidebarItems(sidebarItems.value, route.path, 1);
80
+ return nextConfig === false
81
+ ? null
82
+ : nextConfig ??
83
+ (themeLocale.value.next === false
84
+ ? null
85
+ : resolveFromSidebarItems(sidebarItems.value, route.path, 1));
68
86
  });
69
87
  return {
70
88
  prevLink,
@@ -1,7 +1,12 @@
1
- import type { ComputedRef, InjectionKey } from 'vue';
2
- import type { PageData, PageHeader } from 'vuepress/client';
1
+ import type { MenuItem } from '@vuepress/helper/client';
2
+ import type { ComputedRef, InjectionKey, Ref } from 'vue';
3
+ import type { PageData } from 'vuepress/client';
3
4
  import type { SidebarArrayOptions, SidebarObjectOptions, SidebarOptions } from '../../shared/index.js';
4
5
  import type { SidebarHeaderItem, SidebarItem } from '../typings.js';
6
+ export type HeadersRef = Ref<MenuItem[]>;
7
+ export declare const headersRef: HeadersRef;
8
+ export declare const setupHeaders: () => void;
9
+ export declare const useHeaders: () => HeadersRef;
5
10
  export type SidebarItemsRef = ComputedRef<SidebarItem[]>;
6
11
  export declare const sidebarItemsSymbol: InjectionKey<SidebarItemsRef>;
7
12
  /**
@@ -17,21 +22,21 @@ export declare const setupSidebarItems: () => void;
17
22
  *
18
23
  * It should only be resolved and provided once
19
24
  */
20
- export declare const resolveSidebarItems: (sidebarConfig: false | SidebarOptions, sidebarDepth: number, page: PageData, path: string, routeLocale: string) => SidebarItem[];
25
+ export declare const resolveSidebarItems: (sidebarConfig: false | SidebarOptions, page: PageData, path: string, routeLocale: string, headers: MenuItem[]) => SidebarItem[];
21
26
  /**
22
27
  * Util to transform page header to sidebar item
23
28
  */
24
- export declare const resolveSidebarHeaderItem: (sidebarDepth: number, header: PageHeader) => SidebarHeaderItem;
25
- export declare const resolveSidebarHeaderItems: (sidebarDepth: number, headers: PageHeader[]) => SidebarHeaderItem[];
29
+ export declare const resolveSidebarHeaderItem: (header: MenuItem) => SidebarHeaderItem;
30
+ export declare const resolveSidebarHeaderItems: (headers?: MenuItem[]) => SidebarHeaderItem[];
26
31
  /**
27
32
  * Resolve current page and its header to sidebar items if the config is `heading`
28
33
  */
29
- export declare const resolveSidebarHeadingItem: (sidebarDepth: number, page: PageData) => SidebarItem[];
34
+ export declare const resolveSidebarHeadingItem: (page: PageData, headers: MenuItem[]) => SidebarItem[];
30
35
  /**
31
36
  * Resolve sidebar items if the config is an array
32
37
  */
33
- export declare const resolveArraySidebarItems: (sidebarConfig: SidebarArrayOptions, sidebarDepth: number, page: PageData, path: string, prefix?: string) => SidebarItem[];
38
+ export declare const resolveArraySidebarItems: (sidebarConfig: SidebarArrayOptions, headers: MenuItem[], path: string, prefix?: string) => SidebarItem[];
34
39
  /**
35
40
  * Resolve sidebar items if the config is a key -> value (path-prefix -> array) object
36
41
  */
37
- export declare const resolveMultiSidebarItems: (sidebarConfig: SidebarObjectOptions, sidebarDepth: number, page: PageData, path: string) => SidebarItem[];
42
+ export declare const resolveMultiSidebarItems: (sidebarConfig: SidebarObjectOptions, page: PageData, headers: MenuItem[], path: string) => SidebarItem[];
@@ -1,9 +1,37 @@
1
1
  import { useThemeLocaleData } from '@theme/useThemeData';
2
- import { keys, startsWith } from '@vuepress/helper/client';
3
- import { computed, inject, provide } from 'vue';
4
- import { usePageData, usePageFrontmatter, useRoute, useRouteLocale, } from 'vuepress/client';
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
5
  import { isPlainObject, isString } from 'vuepress/shared';
6
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
@@ -24,11 +52,11 @@ export const setupSidebarItems = () => {
24
52
  const page = usePageData();
25
53
  const route = useRoute();
26
54
  const routeLocale = useRouteLocale();
55
+ const headers = useHeaders();
27
56
  const sidebarConfig = computed(() => frontmatter.value.home
28
57
  ? false
29
58
  : frontmatter.value.sidebar ?? themeLocale.value.sidebar ?? 'heading');
30
- const sidebarDepth = computed(() => frontmatter.value.sidebarDepth ?? themeLocale.value.sidebarDepth ?? 2);
31
- const sidebarItems = computed(() => resolveSidebarItems(sidebarConfig.value, sidebarDepth.value, page.value, route.path, routeLocale.value));
59
+ const sidebarItems = computed(() => resolveSidebarItems(sidebarConfig.value, page.value, route.path, routeLocale.value, headers.value));
32
60
  provide(sidebarItemsSymbol, sidebarItems);
33
61
  };
34
62
  /**
@@ -36,46 +64,44 @@ export const setupSidebarItems = () => {
36
64
  *
37
65
  * It should only be resolved and provided once
38
66
  */
39
- export const resolveSidebarItems = (sidebarConfig, sidebarDepth, page, path, routeLocale) => {
67
+ export const resolveSidebarItems = (sidebarConfig, page, path, routeLocale, headers) => {
40
68
  // resolve sidebar items according to the config
41
69
  if (sidebarConfig === false) {
42
70
  return [];
43
71
  }
44
72
  if (sidebarConfig === 'heading') {
45
- return resolveSidebarHeadingItem(sidebarDepth, page);
73
+ return resolveSidebarHeadingItem(page, headers);
46
74
  }
47
75
  if (Array.isArray(sidebarConfig)) {
48
- return resolveArraySidebarItems(sidebarConfig, sidebarDepth, page, path, routeLocale);
76
+ return resolveArraySidebarItems(sidebarConfig, headers, path, routeLocale);
49
77
  }
50
78
  if (isPlainObject(sidebarConfig)) {
51
- return resolveMultiSidebarItems(sidebarConfig, sidebarDepth, page, path);
79
+ return resolveMultiSidebarItems(sidebarConfig, page, headers, path);
52
80
  }
53
81
  return [];
54
82
  };
55
83
  /**
56
84
  * Util to transform page header to sidebar item
57
85
  */
58
- export const resolveSidebarHeaderItem = (sidebarDepth, header) => ({
86
+ export const resolveSidebarHeaderItem = (header) => ({
59
87
  text: header.title,
60
88
  link: header.link,
61
- children: resolveSidebarHeaderItems(sidebarDepth, header.children),
89
+ children: resolveSidebarHeaderItems(header.children),
62
90
  });
63
- export const resolveSidebarHeaderItems = (sidebarDepth, headers) => sidebarDepth > 0
64
- ? headers.map((header) => resolveSidebarHeaderItem(sidebarDepth - 1, header))
65
- : [];
91
+ export const resolveSidebarHeaderItems = (headers) => headers ? headers.map((header) => resolveSidebarHeaderItem(header)) : [];
66
92
  /**
67
93
  * Resolve current page and its header to sidebar items if the config is `heading`
68
94
  */
69
- export const resolveSidebarHeadingItem = (sidebarDepth, page) => [
95
+ export const resolveSidebarHeadingItem = (page, headers) => [
70
96
  {
71
97
  text: page.title,
72
- children: resolveSidebarHeaderItems(sidebarDepth, page.headers),
98
+ children: resolveSidebarHeaderItems(headers),
73
99
  },
74
100
  ];
75
101
  /**
76
102
  * Resolve sidebar items if the config is an array
77
103
  */
78
- export const resolveArraySidebarItems = (sidebarConfig, sidebarDepth, page, path, prefix = '') => {
104
+ export const resolveArraySidebarItems = (sidebarConfig, headers, path, prefix = '') => {
79
105
  const handleChildItem = (item, pathPrefix) => {
80
106
  const childItem = isString(item)
81
107
  ? getAutoLink(resolvePrefix(pathPrefix, item))
@@ -97,10 +123,10 @@ export const resolveArraySidebarItems = (sidebarConfig, sidebarDepth, page, path
97
123
  // use headers of current page as children
98
124
  if (childItem.link === path) {
99
125
  // skip h1 header
100
- const headers = page.headers[0]?.level === 1 ? page.headers[0].children : page.headers;
126
+ const currentHeaders = headers[0]?.level === 1 ? headers[0].children : headers;
101
127
  return {
102
128
  ...childItem,
103
- children: resolveSidebarHeaderItems(sidebarDepth, headers),
129
+ children: resolveSidebarHeaderItems(currentHeaders),
104
130
  };
105
131
  }
106
132
  return childItem;
@@ -110,7 +136,7 @@ export const resolveArraySidebarItems = (sidebarConfig, sidebarDepth, page, path
110
136
  /**
111
137
  * Resolve sidebar items if the config is a key -> value (path-prefix -> array) object
112
138
  */
113
- export const resolveMultiSidebarItems = (sidebarConfig, sidebarDepth, page, path) => {
139
+ export const resolveMultiSidebarItems = (sidebarConfig, page, headers, path) => {
114
140
  const sidebarRoutes = keys(sidebarConfig).sort((x, y) => y.length - x.length);
115
141
  // Find matching config
116
142
  for (const base of sidebarRoutes)
@@ -118,8 +144,8 @@ export const resolveMultiSidebarItems = (sidebarConfig, sidebarDepth, page, path
118
144
  const matched = sidebarConfig[base];
119
145
  return matched
120
146
  ? matched === 'heading'
121
- ? resolveSidebarHeadingItem(sidebarDepth, page)
122
- : resolveArraySidebarItems(matched, sidebarDepth, page, path, base)
147
+ ? resolveSidebarHeadingItem(page, headers)
148
+ : resolveArraySidebarItems(matched, headers, path, base)
123
149
  : [];
124
150
  }
125
151
  console.warn(`${decodeURI(path)} is missing sidebar config.`);
@@ -1,8 +1,10 @@
1
+ import { setupDarkMode } from '@theme/useDarkMode';
2
+ import { useScrollPromise } from '@theme/useScrollPromise';
3
+ import { setupSidebarItems } from '@theme/useSidebarItems';
1
4
  import { hasGlobalComponent } from '@vuepress/helper/client';
2
5
  import { h } from 'vue';
3
6
  import { defineClientConfig } from 'vuepress/client';
4
7
  import { Badge, CodeGroup, CodeGroupItem } from './components/global/index.js';
5
- import { setupDarkMode, setupSidebarItems, useScrollPromise, } from './composables/index.js';
6
8
  import Layout from './layouts/Layout.vue';
7
9
  import NotFound from './layouts/NotFound.vue';
8
10
  import '@vuepress/helper/normalize.css';
@@ -0,0 +1,121 @@
1
+ // ------------ code notation highlighting ------------
2
+ // matches `<span class="line xxxx" ></span>`
3
+
4
+ div[class*='language-'] {
5
+ // highlight lines and notation highlight
6
+ // `!code highlight` and `!code hl` are the same:
7
+ // - `// [\!code highlight]`
8
+ // - `// [\!code hl]`
9
+ // - `// [\!code highlight:3]`
10
+ // - `// [\!code hl:3]`
11
+ // It also has the style of error level,
12
+ // covering the background color with 'warning' and 'error' classes.
13
+ // - `// [\!code warning]`
14
+ // - `// [\!code error]`
15
+ // - `// [\!code warning:3]`
16
+ // - `// [\!code error:3]`
17
+ .line.highlighted {
18
+ display: inline-block;
19
+
20
+ width: 100%;
21
+ margin: 0 -24px;
22
+ padding: 0 24px;
23
+
24
+ background-color: var(--code-highlight-bg-color);
25
+
26
+ transition: background-color 0.5s;
27
+
28
+ &.error {
29
+ background-color: var(--code-highlight-error-bg-color);
30
+ }
31
+
32
+ &.warning {
33
+ background-color: var(--code-highlight-warning-bg-color);
34
+ }
35
+ }
36
+
37
+ // notation diff line
38
+ // - class="diff add": `// [\!code ++]` or `// [\!code ++:3]`
39
+ // - class="diff remove": `// [\!code --]` or `// [\!code --:3]`
40
+ .line.diff {
41
+ display: inline-block;
42
+
43
+ width: 100%;
44
+ margin: 0 -24px;
45
+ padding: 0 24px;
46
+
47
+ transition: background-color 0.5s;
48
+
49
+ &::before {
50
+ position: absolute;
51
+ left: 10px;
52
+ }
53
+
54
+ &.remove {
55
+ background-color: var(--code-line-diff-remove-color);
56
+ opacity: 0.7;
57
+
58
+ &::before {
59
+ content: '-';
60
+ color: var(--code-line-diff-remove-symbol-color);
61
+ }
62
+ }
63
+
64
+ &.add {
65
+ background-color: var(--code-line-diff-add-color);
66
+
67
+ &::before {
68
+ content: '+';
69
+ color: var(--code-line-diff-add-symbol-color);
70
+ }
71
+ }
72
+ }
73
+
74
+ // notation focused lines
75
+ // - `// [\!code focus]`
76
+ // - `// [\!code focus:3]`
77
+ .has-focused-lines .line:not(.has-focus) {
78
+ opacity: 0.7;
79
+ filter: blur(0.095rem);
80
+ transition:
81
+ filter 0.35s,
82
+ opacity 0.35s;
83
+ }
84
+
85
+ &:hover .has-focused-lines .line:not(.has-focus) {
86
+ opacity: 1;
87
+ filter: blur(0);
88
+ }
89
+
90
+ // notation word highlight
91
+ // - `// [\!code word:xxx]`
92
+ // - `// [\!code word:xxx:3]`
93
+ .highlighted-word {
94
+ margin: -1px -2px;
95
+ padding: 1px 2px;
96
+ border: solid 1px var(--code-word-highlight-border);
97
+ border-radius: 4px;
98
+
99
+ background-color: var(--code-word-highlight-bg-color);
100
+ }
101
+
102
+ // whitespace
103
+ .tab,
104
+ .space {
105
+ position: relative;
106
+ }
107
+
108
+ .tab::before,
109
+ .space::before {
110
+ position: absolute;
111
+ opacity: 0.3;
112
+ }
113
+
114
+ .tab::before {
115
+ content: '⇥';
116
+ }
117
+
118
+ .space::before {
119
+ content: '·';
120
+ }
121
+ }
@@ -146,7 +146,7 @@ div[class*='language-'] {
146
146
  right: 1em;
147
147
  z-index: 3;
148
148
 
149
- color: var(--code-ln-color);
149
+ color: var(--code-line-number-color);
150
150
 
151
151
  font-size: 0.75rem;
152
152
  }
@@ -169,7 +169,7 @@ div[class*='language-'] {
169
169
  &.line-numbers-mode {
170
170
  pre {
171
171
  vertical-align: middle;
172
- margin-left: var(--code-ln-wrapper-width);
172
+ margin-left: var(--code-line-number-wrapper-width);
173
173
  }
174
174
 
175
175
  code {
@@ -180,10 +180,10 @@ div[class*='language-'] {
180
180
  position: absolute;
181
181
  top: 0;
182
182
 
183
- width: var(--code-ln-wrapper-width);
183
+ width: var(--code-line-number-wrapper-width);
184
184
  padding-top: 1.3rem;
185
185
 
186
- color: var(--code-ln-color);
186
+ color: var(--code-line-number-color);
187
187
 
188
188
  font-size: 0.875em;
189
189
  line-height: $line-height;
@@ -210,9 +210,9 @@ div[class*='language-'] {
210
210
  top: 0;
211
211
  left: 0;
212
212
 
213
- width: var(--code-ln-wrapper-width);
213
+ width: var(--code-line-number-wrapper-width);
214
214
  height: 100%;
215
- border-right: 1px solid var(--code-hl-bg-color);
215
+ border-right: 1px solid var(--code-highlight-bg-color);
216
216
  border-radius: 6px 0 0 6px;
217
217
  }
218
218
  }
@@ -236,100 +236,6 @@ div[data-highlighter='shiki'] {
236
236
  }
237
237
  }
238
238
 
239
- // ------------ code notation highlighting ------------
240
- // matches `<span class="line xxxx" ></span>`
241
-
242
- div[class*='language-'] {
243
- // highlight lines and notation highlight
244
- //
245
- // `!code highlight` and `!code hl` are the same:
246
- // - `// [\!code highlight]`
247
- // - `// [\!code hl]`
248
- // - `// [\!code highlight:3]`
249
- // - `// [\!code hl:3]`
250
- //
251
- // It also has the style of error level,
252
- // covering the background color with 'warning' and 'error' classes.
253
- // - `// [\!code warning]`
254
- // - `// [\!code error]`
255
- // - `// [\!code warning:3]`
256
- // - `// [\!code error:3]`
257
- .line.highlighted {
258
- display: inline-block;
259
-
260
- width: 100%;
261
- margin: 0 -24px;
262
- padding: 0 24px;
263
-
264
- background-color: var(--code-hl-bg-color);
265
-
266
- transition: background-color 0.5s;
267
-
268
- &.error {
269
- background-color: var(--code-hl-error-bg-color);
270
- }
271
-
272
- &.warning {
273
- background-color: var(--code-hl-warning-bg-color);
274
- }
275
- }
276
-
277
- // notation diff line
278
- //
279
- // - class="diff add": `// [\!code ++]` or `// [\!code ++:3]`
280
- // - class="diff remove": `// [\!code --]` or `// [\!code --:3]`
281
- .line.diff {
282
- display: inline-block;
283
-
284
- width: 100%;
285
- margin: 0 -24px;
286
- padding: 0 24px;
287
-
288
- transition: background-color 0.5s;
289
-
290
- &::before {
291
- position: absolute;
292
- left: 10px;
293
- }
294
-
295
- &.remove {
296
- background-color: var(--code-line-diff-remove-color);
297
- opacity: 0.7;
298
-
299
- &::before {
300
- content: '-';
301
- color: var(--code-line-diff-remove-symbol-color);
302
- }
303
- }
304
-
305
- &.add {
306
- background-color: var(--code-line-diff-add-color);
307
-
308
- &::before {
309
- content: '+';
310
- color: var(--code-line-diff-add-symbol-color);
311
- }
312
- }
313
- }
314
-
315
- // notation focused lines
316
- //
317
- // - `// [\!code focus]`
318
- // - `// [\!code focus:3]`
319
- .has-focused-lines .line:not(.has-focus) {
320
- opacity: 0.7;
321
- filter: blur(0.095rem);
322
- transition:
323
- filter 0.35s,
324
- opacity 0.35s;
325
- }
326
-
327
- &:hover .has-focused-lines .line:not(.has-focus) {
328
- opacity: 1;
329
- filter: blur(0);
330
- }
331
- }
332
-
333
239
  // narrow mobile
334
240
  @media (max-width: $MQMobileNarrow) {
335
241
  .theme-default-content {
@@ -1,4 +1,5 @@
1
1
  @use 'normalize';
2
2
  @use 'code';
3
+ @use 'code-notation';
3
4
  @use 'custom-container';
4
5
  @use 'toc';
@@ -36,15 +36,18 @@ code {
36
36
 
37
37
  kbd {
38
38
  border-color: var(--c-border-dark);
39
+ transition: border-color var(--t-color);
39
40
  }
40
41
 
41
42
  blockquote {
42
43
  border-color: var(--c-border-dark);
43
44
  color: var(--c-text-quote);
45
+ transition: border-color var(--t-color);
44
46
  }
45
47
 
46
48
  hr {
47
49
  border-color: var(--c-border);
50
+ transition: border-color var(--t-color);
48
51
  }
49
52
 
50
53
  table {
@@ -74,15 +74,17 @@
74
74
 
75
75
  // code blocks vars
76
76
  --code-bg-color: #282c34;
77
- --code-hl-bg-color: rgb(0 0 0 / 66%);
78
- --code-hl-error-bg-color: rgb(244 63 94 / 16%);
79
- --code-hl-warning-bg-color: rgb(255 193 7 / 16%);
77
+ --code-highlight-bg-color: rgb(0 0 0 / 66%);
78
+ --code-highlight-error-bg-color: rgb(244 63 94 / 16%);
79
+ --code-highlight-warning-bg-color: rgb(255 193 7 / 16%);
80
80
  --code-line-diff-remove-color: rgb(244 63 94 / 16%);
81
81
  --code-line-diff-remove-symbol-color: #e0575b;
82
82
  --code-line-diff-add-color: rgb(16 185 129 / 16%);
83
83
  --code-line-diff-add-symbol-color: #298459;
84
- --code-ln-color: #9e9e9e;
85
- --code-ln-wrapper-width: 3.5rem;
84
+ --code-word-highlight-bg-color: rgb(0 0 0 / 20%);
85
+ --code-word-highlight-border: #636363;
86
+ --code-line-number-color: #9e9e9e;
87
+ --code-line-number-wrapper-width: 3.5rem;
86
88
 
87
89
  // font vars
88
90
  --font-family: -apple-system, 'BlinkMacSystemFont', 'Segoe UI', roboto, oxygen,
@@ -6,4 +6,4 @@ import type { AutoLinkOptions } from '../../shared';
6
6
  * - Input: '/README.md'
7
7
  * - Output: { text: 'Home', link: '/' }
8
8
  */
9
- export declare const getAutoLink: (config: string) => AutoLinkOptions;
9
+ export declare const getAutoLink: (config: string, currentPath?: string) => AutoLinkOptions;
@@ -6,8 +6,8 @@ import { resolveRoute } from 'vuepress/client';
6
6
  * - Input: '/README.md'
7
7
  * - Output: { text: 'Home', link: '/' }
8
8
  */
9
- export const getAutoLink = (config) => {
10
- const { notFound, meta, path } = resolveRoute(config);
9
+ export const getAutoLink = (config, currentPath) => {
10
+ const { notFound, meta, path } = resolveRoute(config, currentPath);
11
11
  return notFound
12
12
  ? { text: path, link: path }
13
13
  : {
@@ -1,3 +1,4 @@
1
+ import { addViteOptimizeDepsExclude } from '@vuepress/helper';
1
2
  import { activeHeaderLinksPlugin } from '@vuepress/plugin-active-header-links';
2
3
  import { backToTopPlugin } from '@vuepress/plugin-back-to-top';
3
4
  import { copyCodePlugin } from '@vuepress/plugin-copy-code';
@@ -39,6 +40,9 @@ export const defaultTheme = ({ hostname, themePlugins = {}, ...localeOptions } =
39
40
  ])),
40
41
  },
41
42
  clientConfigFile: path.resolve(__dirname, '../client/config.js'),
43
+ extendsBundlerOptions: (bundlerOptions, app) => {
44
+ addViteOptimizeDepsExclude(bundlerOptions, app, '@theme');
45
+ },
42
46
  extendsPage: (page) => {
43
47
  // save relative file path into page data to generate edit link
44
48
  page.data.filePathRelative = page.filePathRelative;
@@ -283,9 +283,9 @@ export interface DefaultThemeLocaleData extends LocaleData {
283
283
  /**
284
284
  * text for prev link
285
285
  */
286
- prev?: string;
286
+ prev?: string | false;
287
287
  /**
288
288
  * text for next link
289
289
  */
290
- next?: string;
290
+ next?: string | false;
291
291
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vuepress/theme-default",
3
- "version": "2.0.0-rc.34",
3
+ "version": "2.0.0-rc.36",
4
4
  "description": "Default theme of VuePress",
5
5
  "keywords": [
6
6
  "vuepress-theme",
@@ -36,29 +36,24 @@
36
36
  "lib",
37
37
  "templates"
38
38
  ],
39
- "scripts": {
40
- "build": "tsc -b tsconfig.build.json",
41
- "clean": "rimraf --glob ./lib ./*.tsbuildinfo",
42
- "copy": "cpx \"src/**/*.{d.ts,vue,scss}\" lib"
43
- },
44
39
  "dependencies": {
45
- "@vuepress/helper": "2.0.0-rc.34",
46
- "@vuepress/plugin-active-header-links": "2.0.0-rc.34",
47
- "@vuepress/plugin-back-to-top": "2.0.0-rc.34",
48
- "@vuepress/plugin-copy-code": "2.0.0-rc.34",
49
- "@vuepress/plugin-git": "2.0.0-rc.34",
50
- "@vuepress/plugin-links-check": "2.0.0-rc.34",
40
+ "@vuepress/helper": "2.0.0-rc.36",
41
+ "@vuepress/plugin-active-header-links": "2.0.0-rc.36",
42
+ "@vuepress/plugin-back-to-top": "2.0.0-rc.36",
43
+ "@vuepress/plugin-copy-code": "2.0.0-rc.36",
44
+ "@vuepress/plugin-git": "2.0.0-rc.36",
45
+ "@vuepress/plugin-links-check": "2.0.0-rc.36",
51
46
  "@vuepress/plugin-markdown-container": "2.0.0-rc.34",
52
- "@vuepress/plugin-medium-zoom": "2.0.0-rc.34",
53
- "@vuepress/plugin-nprogress": "2.0.0-rc.34",
47
+ "@vuepress/plugin-medium-zoom": "2.0.0-rc.36",
48
+ "@vuepress/plugin-nprogress": "2.0.0-rc.36",
54
49
  "@vuepress/plugin-palette": "2.0.0-rc.34",
55
- "@vuepress/plugin-prismjs": "2.0.0-rc.34",
56
- "@vuepress/plugin-seo": "2.0.0-rc.34",
57
- "@vuepress/plugin-sitemap": "2.0.0-rc.34",
58
- "@vuepress/plugin-theme-data": "2.0.0-rc.34",
59
- "@vueuse/core": "^10.10.0",
60
- "sass": "^1.77.4",
61
- "vue": "^3.4.27"
50
+ "@vuepress/plugin-prismjs": "2.0.0-rc.36",
51
+ "@vuepress/plugin-seo": "2.0.0-rc.36",
52
+ "@vuepress/plugin-sitemap": "2.0.0-rc.36",
53
+ "@vuepress/plugin-theme-data": "2.0.0-rc.36",
54
+ "@vueuse/core": "^10.11.0",
55
+ "sass": "^1.77.6",
56
+ "vue": "^3.4.29"
62
57
  },
63
58
  "peerDependencies": {
64
59
  "sass-loader": "^14.0.0",
@@ -72,5 +67,5 @@
72
67
  "publishConfig": {
73
68
  "access": "public"
74
69
  },
75
- "gitHead": "93df303baa6291f52e3523f136073e79d53274ea"
70
+ "gitHead": "7f283f7243f9f9b86a9621f6ebc00d8d335d5f94"
76
71
  }