vitepress 1.5.0 → 1.6.0

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 (37) hide show
  1. package/README.md +1 -0
  2. package/dist/client/app/components/ClientOnly.js +1 -1
  3. package/dist/client/app/components/Content.js +1 -1
  4. package/dist/client/app/composables/preFetch.js +1 -1
  5. package/dist/client/app/router.js +5 -5
  6. package/dist/client/app/ssr.js +1 -1
  7. package/dist/client/app/utils.js +3 -3
  8. package/dist/client/index.d.ts +4 -0
  9. package/dist/client/index.js +2 -2
  10. package/dist/client/shared.js +1 -1
  11. package/dist/client/theme-default/components/VPHero.vue +4 -3
  12. package/dist/client/theme-default/components/VPHome.vue +6 -2
  13. package/dist/client/theme-default/components/VPLocalNavOutlineDropdown.vue +2 -1
  14. package/dist/client/theme-default/components/VPSidebarItem.vue +2 -1
  15. package/dist/client/theme-default/components/VPSkipLink.vue +3 -1
  16. package/dist/client/theme-default/composables/flyout.js +1 -1
  17. package/dist/client/theme-default/composables/nav.js +1 -1
  18. package/dist/client/theme-default/composables/outline.js +2 -4
  19. package/dist/client/theme-default/composables/prev-next.js +2 -2
  20. package/dist/client/theme-default/styles/components/vp-doc.css +4 -2
  21. package/dist/client/theme-default/styles/fonts.css +6 -6
  22. package/dist/client/theme-default/styles/icons.css +3 -0
  23. package/dist/client/theme-default/styles/vars.css +23 -6
  24. package/dist/client/theme-default/support/sidebar.js +1 -1
  25. package/dist/client/theme-default/support/utils.js +2 -2
  26. package/dist/client/theme-default/without-fonts.js +8 -6
  27. package/dist/node/{chunk-DMuPggCS.js → chunk-BZEQqoFe.js} +690 -405
  28. package/dist/node/{chunk-DQlKmeN_.js → chunk-C-d2RJOW.js} +12 -12
  29. package/dist/node/cli.js +16 -12
  30. package/dist/node/index.d.ts +8 -7
  31. package/dist/node/index.js +10 -10
  32. package/dist/node/worker_shikiResolveLang.js +1 -1
  33. package/package.json +42 -46
  34. package/theme.d.ts +2 -0
  35. package/types/default-theme.d.ts +5 -0
  36. package/types/index.d.ts +1 -1
  37. package/lib/vue-demi.mjs +0 -34
package/README.md CHANGED
@@ -2,6 +2,7 @@
2
2
 
3
3
  [![test](https://github.com/vuejs/vitepress/workflows/Test/badge.svg)](https://github.com/vuejs/vitepress/actions)
4
4
  [![npm](https://img.shields.io/npm/v/vitepress)](https://www.npmjs.com/package/vitepress)
5
+ [![nightly releases](https://img.shields.io/badge/nightly-releases-orange)](https://nightly.akryum.dev/vuejs/vitepress)
5
6
  [![chat](https://img.shields.io/badge/chat-discord-blue?logo=discord)](https://chat.vuejs.org)
6
7
 
7
8
  ---
@@ -1,4 +1,4 @@
1
- import { defineComponent, ref, onMounted } from 'vue';
1
+ import { defineComponent, onMounted, ref } from 'vue';
2
2
  export const ClientOnly = defineComponent({
3
3
  setup(_, { slots }) {
4
4
  const show = ref(false);
@@ -1,5 +1,5 @@
1
- import { defineComponent, h, watch } from 'vue';
2
1
  import { useData, useRoute } from 'vitepress';
2
+ import { defineComponent, h, watch } from 'vue';
3
3
  import { contentUpdatedCallbacks } from '../utils';
4
4
  const runCbs = () => contentUpdatedCallbacks.forEach((fn) => fn());
5
5
  export const Content = defineComponent({
@@ -1,7 +1,7 @@
1
1
  // Customized pre-fetch for page chunks based on
2
2
  // https://github.com/GoogleChromeLabs/quicklink
3
- import { useRoute } from '../router';
4
3
  import { onMounted, onUnmounted, watch } from 'vue';
4
+ import { useRoute } from '../router';
5
5
  import { inBrowser, pathToFile } from '../utils';
6
6
  const hasFetched = new Set();
7
7
  const createLink = () => document.createElement('link');
@@ -27,7 +27,7 @@ export function createRouter(loadPageModule, fallbackComponent) {
27
27
  history.pushState({}, '', href);
28
28
  }
29
29
  await loadPage(href);
30
- await router.onAfterRouteChanged?.(href);
30
+ await (router.onAfterRouteChange ?? router.onAfterRouteChanged)?.(href);
31
31
  }
32
32
  let latestPendingPath = null;
33
33
  async function loadPage(href, scrollPosition = 0, isRetry = false) {
@@ -168,11 +168,11 @@ export function createRouter(loadPageModule, fallbackComponent) {
168
168
  }
169
169
  }, { capture: true });
170
170
  window.addEventListener('popstate', async (e) => {
171
- if (e.state === null) {
171
+ if (e.state === null)
172
172
  return;
173
- }
174
- await loadPage(normalizeHref(location.href), (e.state && e.state.scrollPosition) || 0);
175
- router.onAfterRouteChanged?.(location.href);
173
+ const href = normalizeHref(location.href);
174
+ await loadPage(href, (e.state && e.state.scrollPosition) || 0);
175
+ await (router.onAfterRouteChange ?? router.onAfterRouteChanged)?.(href);
176
176
  });
177
177
  window.addEventListener('hashchange', (e) => {
178
178
  e.preventDefault();
@@ -1,6 +1,6 @@
1
1
  // entry for SSR
2
- import { createApp } from './index';
3
2
  import { renderToString } from 'vue/server-renderer';
3
+ import { createApp } from './index';
4
4
  export async function render(path) {
5
5
  const { app, router } = await createApp();
6
6
  await router.go(path);
@@ -1,7 +1,7 @@
1
- import { siteDataRef } from './data';
2
- import { inBrowser, EXTERNAL_URL_RE, sanitizeFileName } from '../shared';
3
1
  import { h, onMounted, onUnmounted, shallowRef } from 'vue';
4
- export { inBrowser, escapeHtml as _escapeHtml } from '../shared';
2
+ import { EXTERNAL_URL_RE, inBrowser, sanitizeFileName } from '../shared';
3
+ import { siteDataRef } from './data';
4
+ export { escapeHtml as _escapeHtml, inBrowser } from '../shared';
5
5
  /**
6
6
  * Join two paths by resolving the slash collision.
7
7
  */
@@ -39,6 +39,10 @@ interface Router {
39
39
  /**
40
40
  * Called after the route changes.
41
41
  */
42
+ onAfterRouteChange?: (to: string) => Awaitable<void>;
43
+ /**
44
+ * @deprecated use `onAfterRouteChange` instead
45
+ */
42
46
  onAfterRouteChanged?: (to: string) => Awaitable<void>;
43
47
  }
44
48
  declare function useRouter(): Router;
@@ -1,9 +1,9 @@
1
1
  // exports in this file are exposed to themes and md files via 'vitepress'
2
2
  // so the user can do `import { useRoute, useData } from 'vitepress'`
3
3
  // composables
4
- export { useData, dataSymbol } from './app/data';
4
+ export { dataSymbol, useData } from './app/data';
5
5
  export { useRoute, useRouter } from './app/router';
6
6
  // utilities
7
- export { inBrowser, onContentUpdated, defineClientComponent, withBase, getScrollOffset, _escapeHtml } from './app/utils';
7
+ export { _escapeHtml, defineClientComponent, getScrollOffset, inBrowser, onContentUpdated, withBase } from './app/utils';
8
8
  // components
9
9
  export { Content } from './app/components/Content';
@@ -31,7 +31,7 @@ export function isActive(currentPath, matchPath, asRegex = false) {
31
31
  }
32
32
  return true;
33
33
  }
34
- function normalize(path) {
34
+ export function normalize(path) {
35
35
  return decodeURI(path)
36
36
  .replace(HASH_OR_QUERY_RE, '')
37
37
  .replace(INDEX_OR_EXT_RE, '$1');
@@ -29,10 +29,10 @@ const heroImageSlotExists = inject('hero-image-slot-exists') as Ref<boolean>
29
29
  <div class="main">
30
30
  <slot name="home-hero-info-before" />
31
31
  <slot name="home-hero-info">
32
- <h1 v-if="name" class="name">
33
- <span v-html="name" class="clip"></span>
32
+ <h1>
33
+ <span v-if="name" v-html="name" class="name clip"></span>
34
+ <span v-if="text" v-html="text" class="text"></span>
34
35
  </h1>
35
- <p v-if="text" v-html="text" class="text"></p>
36
36
  <p v-if="tagline" v-html="tagline" class="tagline"></p>
37
37
  </slot>
38
38
  <slot name="home-hero-info-after" />
@@ -127,6 +127,7 @@ const heroImageSlotExists = inject('hero-image-slot-exists') as Ref<boolean>
127
127
 
128
128
  .name,
129
129
  .text {
130
+ display: inline-block;
130
131
  max-width: 392px;
131
132
  letter-spacing: -0.4px;
132
133
  line-height: 40px;
@@ -4,11 +4,15 @@ import VPHomeFeatures from './VPHomeFeatures.vue'
4
4
  import VPHomeContent from './VPHomeContent.vue'
5
5
  import { useData } from '../composables/data'
6
6
 
7
- const { frontmatter } = useData()
7
+ const { frontmatter, theme } = useData()
8
8
  </script>
9
9
 
10
10
  <template>
11
- <div class="VPHome">
11
+ <div
12
+ class="VPHome"
13
+ :class="{
14
+ 'external-link-icon-enabled': theme.externalLinkIcon
15
+ }">
12
16
  <slot name="home-hero-before" />
13
17
  <VPHomeHero>
14
18
  <template #home-hero-info-before><slot name="home-hero-info-before" /></template>
@@ -125,7 +125,7 @@ function scrollToTop() {
125
125
  vertical-align: middle;
126
126
  margin-left: 2px;
127
127
  font-size: 14px;
128
- transform: rotate(0deg);
128
+ transform: rotate(0)/*rtl:rotate(180deg)*/;
129
129
  transition: transform 0.25s;
130
130
  }
131
131
 
@@ -140,6 +140,7 @@ function scrollToTop() {
140
140
  }
141
141
 
142
142
  .open > .icon {
143
+ /*rtl:ignore*/
143
144
  transform: rotate(90deg);
144
145
  }
145
146
 
@@ -227,12 +227,13 @@ function onCaretClick() {
227
227
 
228
228
  .caret-icon {
229
229
  font-size: 18px;
230
+ /*rtl:ignore*/
230
231
  transform: rotate(90deg);
231
232
  transition: transform 0.25s;
232
233
  }
233
234
 
234
235
  .VPSidebarItem.collapsed .caret-icon {
235
- transform: rotate(0);
236
+ transform: rotate(0)/*rtl:rotate(180deg)*/;
236
237
  }
237
238
 
238
239
  .VPSidebarItem.level-1 .items,
@@ -1,7 +1,9 @@
1
1
  <script lang="ts" setup>
2
2
  import { ref, watch } from 'vue'
3
3
  import { useRoute } from 'vitepress'
4
+ import { useData } from '../composables/data'
4
5
 
6
+ const { theme } = useData()
5
7
  const route = useRoute()
6
8
  const backToTop = ref()
7
9
 
@@ -33,7 +35,7 @@ function focusOnTargetAnchor({ target }: Event) {
33
35
  class="VPSkipLink visually-hidden"
34
36
  @click="focusOnTargetAnchor"
35
37
  >
36
- Skip to content
38
+ {{ theme.skipToContentLabel || 'Skip to content' }}
37
39
  </a>
38
40
  </template>
39
41
 
@@ -1,4 +1,4 @@
1
- import { ref, watch, readonly, onUnmounted } from 'vue';
1
+ import { onUnmounted, readonly, ref, watch } from 'vue';
2
2
  import { inBrowser } from '../../shared';
3
3
  export const focusedElement = ref();
4
4
  let active = false;
@@ -1,5 +1,5 @@
1
- import { ref, watch } from 'vue';
2
1
  import { useRoute } from 'vitepress';
2
+ import { ref, watch } from 'vue';
3
3
  export function useNav() {
4
4
  const isScreenOpen = ref(false);
5
5
  function openScreen() {
@@ -2,6 +2,7 @@ import { getScrollOffset } from 'vitepress';
2
2
  import { onMounted, onUnmounted, onUpdated } from 'vue';
3
3
  import { throttleAndDebounce } from '../support/utils';
4
4
  import { useAside } from './aside';
5
+ const ignoreRE = /\b(?:VPBadge|header-anchor|footnote-ref|ignore-header)\b/;
5
6
  // cached list of anchor elements from resolveHeaders
6
7
  const resolvedHeaders = [];
7
8
  export function resolveTitle(theme) {
@@ -31,11 +32,8 @@ function serializeHeader(h) {
31
32
  let ret = '';
32
33
  for (const node of h.childNodes) {
33
34
  if (node.nodeType === 1) {
34
- if (node.classList.contains('VPBadge') ||
35
- node.classList.contains('header-anchor') ||
36
- node.classList.contains('ignore-header')) {
35
+ if (ignoreRE.test(node.className))
37
36
  continue;
38
- }
39
37
  ret += node.textContent;
40
38
  }
41
39
  else if (node.nodeType === 3) {
@@ -1,7 +1,7 @@
1
1
  import { computed } from 'vue';
2
- import { useData } from './data';
3
2
  import { isActive } from '../../shared';
4
- import { getSidebar, getFlatSideBarLinks } from '../support/sidebar';
3
+ import { getFlatSideBarLinks, getSidebar } from '../support/sidebar';
4
+ import { useData } from './data';
5
5
  export function usePrevNext() {
6
6
  const { page, theme, frontmatter } = useData();
7
7
  return computed(() => {
@@ -493,6 +493,7 @@
493
493
  border: 1px solid var(--vp-code-copy-code-hover-border-color);
494
494
  /*rtl:ignore*/
495
495
  border-right: 0;
496
+ /*rtl:ignore*/
496
497
  border-radius: 4px 0 0 4px;
497
498
  padding: 0 10px;
498
499
  width: fit-content;
@@ -554,7 +555,7 @@
554
555
  * -------------------------------------------------------------------------- */
555
556
 
556
557
  /* prettier-ignore */
557
- :is(.vp-external-link-icon, .vp-doc a[href*='://'], .vp-doc a[target='_blank']):not(.no-icon)::after {
558
+ :is(.vp-external-link-icon, .vp-doc a[href*='://'], .vp-doc a[target='_blank']):not(:is(.no-icon, svg a, :has(img, svg)))::after {
558
559
  display: inline-block;
559
560
  margin-top: -1px;
560
561
  margin-left: 4px;
@@ -566,6 +567,7 @@
566
567
  --icon: url("data:image/svg+xml, %3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' %3E%3Cpath d='M0 0h24v24H0V0z' fill='none' /%3E%3Cpath d='M9 5v2h6.59L4 18.59 5.41 20 17 8.41V15h2V5H9z' /%3E%3C/svg%3E");
567
568
  -webkit-mask-image: var(--icon);
568
569
  mask-image: var(--icon);
570
+ /*rtl:raw:transform: scaleX(-1);*/
569
571
  }
570
572
 
571
573
  .vp-external-link-icon::after {
@@ -573,7 +575,7 @@
573
575
  }
574
576
 
575
577
  /* prettier-ignore */
576
- .external-link-icon-enabled :is(.vp-doc a[href*='://'], .vp-doc a[target='_blank'])::after {
578
+ .external-link-icon-enabled :is(.vp-doc a[href*='://'], .vp-doc a[target='_blank']):not(:is(.no-icon, svg a, :has(img, svg)))::after {
577
579
  content: '';
578
580
  color: currentColor;
579
581
  }
@@ -46,9 +46,9 @@
46
46
  font-weight: 100 900;
47
47
  font-display: swap;
48
48
  src: url('../fonts/inter-roman-vietnamese.woff2') format('woff2');
49
- unicode-range: U+0102-0103, U+0110-0111, U+0128-0129, U+0168-0169, U+01A0-01A1,
50
- U+01AF-01B0, U+0300-0301, U+0303-0304, U+0308-0309, U+0323, U+0329,
51
- U+1EA0-1EF9, U+20AB;
49
+ unicode-range: U+0102-0103, U+0110-0111, U+0128-0129, U+0168-0169,
50
+ U+01A0-01A1, U+01AF-01B0, U+0300-0301, U+0303-0304, U+0308-0309, U+0323,
51
+ U+0329, U+1EA0-1EF9, U+20AB;
52
52
  }
53
53
 
54
54
  @font-face {
@@ -116,9 +116,9 @@
116
116
  font-weight: 100 900;
117
117
  font-display: swap;
118
118
  src: url('../fonts/inter-italic-vietnamese.woff2') format('woff2');
119
- unicode-range: U+0102-0103, U+0110-0111, U+0128-0129, U+0168-0169, U+01A0-01A1,
120
- U+01AF-01B0, U+0300-0301, U+0303-0304, U+0308-0309, U+0323, U+0329,
121
- U+1EA0-1EF9, U+20AB;
119
+ unicode-range: U+0102-0103, U+0110-0111, U+0128-0129, U+0168-0169,
120
+ U+01A0-01A1, U+01AF-01B0, U+0300-0301, U+0303-0304, U+0308-0309, U+0323,
121
+ U+0329, U+1EA0-1EF9, U+20AB;
122
122
  }
123
123
 
124
124
  @font-face {
@@ -39,14 +39,17 @@
39
39
  }
40
40
  .vpi-chevron-down,
41
41
  .vpi-arrow-down {
42
+ /*rtl:ignore*/
42
43
  transform: rotate(90deg);
43
44
  }
44
45
  .vpi-chevron-left,
45
46
  .vpi-arrow-left {
47
+ /*rtl:ignore*/
46
48
  transform: rotate(180deg);
47
49
  }
48
50
  .vpi-chevron-up,
49
51
  .vpi-arrow-up {
52
+ /*rtl:ignore*/
50
53
  transform: rotate(-90deg);
51
54
  }
52
55
  .vpi-square-pen {
@@ -174,15 +174,15 @@
174
174
  * -------------------------------------------------------------------------- */
175
175
 
176
176
  :root {
177
- --vp-c-text-1: rgba(60, 60, 67);
178
- --vp-c-text-2: rgba(60, 60, 67, 0.78);
179
- --vp-c-text-3: rgba(60, 60, 67, 0.56);
177
+ --vp-c-text-1: #3c3c43;
178
+ --vp-c-text-2: #67676c;
179
+ --vp-c-text-3: #929295;
180
180
  }
181
181
 
182
182
  .dark {
183
- --vp-c-text-1: rgba(255, 255, 245, 0.86);
184
- --vp-c-text-2: rgba(235, 235, 245, 0.6);
185
- --vp-c-text-3: rgba(235, 235, 245, 0.38);
183
+ --vp-c-text-1: #dfdfd6;
184
+ --vp-c-text-2: #98989f;
185
+ --vp-c-text-3: #6a6a71;
186
186
  }
187
187
 
188
188
  /**
@@ -366,6 +366,23 @@
366
366
  --vp-code-tab-active-bar-color: var(--vp-c-brand-1);
367
367
  }
368
368
 
369
+ :lang(es),
370
+ :lang(pt) {
371
+ --vp-code-copy-copied-text-content: 'Copiado';
372
+ }
373
+ :lang(fa) {
374
+ --vp-code-copy-copied-text-content: 'کپی شد';
375
+ }
376
+ :lang(ko) {
377
+ --vp-code-copy-copied-text-content: '복사됨';
378
+ }
379
+ :lang(ru) {
380
+ --vp-code-copy-copied-text-content: 'Скопировано';
381
+ }
382
+ :lang(zh) {
383
+ --vp-code-copy-copied-text-content: '已复制';
384
+ }
385
+
369
386
  /**
370
387
  * Component: Button
371
388
  * -------------------------------------------------------------------------- */
@@ -1,5 +1,5 @@
1
- import { ensureStartingSlash } from './utils';
2
1
  import { isActive } from '../../shared';
2
+ import { ensureStartingSlash } from './utils';
3
3
  /**
4
4
  * Get the `Sidebar` from sidebar option. This method will ensure to get correct
5
5
  * sidebar config from `MultiSideBarConfig` with various path combinations such
@@ -1,6 +1,6 @@
1
1
  import { withBase } from 'vitepress';
2
- import { useData } from '../composables/data';
3
2
  import { isExternal, treatAsHtml } from '../../shared';
3
+ import { useData } from '../composables/data';
4
4
  export function throttleAndDebounce(fn, delay) {
5
5
  let timeoutId;
6
6
  let called = false;
@@ -16,7 +16,7 @@ export function throttleAndDebounce(fn, delay) {
16
16
  };
17
17
  }
18
18
  export function ensureStartingSlash(path) {
19
- return /^\//.test(path) ? path : `/${path}`;
19
+ return path.startsWith('/') ? path : `/${path}`;
20
20
  }
21
21
  export function normalizeLink(url) {
22
22
  const { pathname, search, hash, protocol } = new URL(url, 'http://a.com');
@@ -10,23 +10,25 @@ import './styles/components/vp-sponsor.css';
10
10
  import VPBadge from './components/VPBadge.vue';
11
11
  import Layout from './Layout.vue';
12
12
  export { default as VPBadge } from './components/VPBadge.vue';
13
- export { default as VPImage } from './components/VPImage.vue';
14
13
  export { default as VPButton } from './components/VPButton.vue';
14
+ export { default as VPDocAsideSponsors } from './components/VPDocAsideSponsors.vue';
15
+ export { default as VPFeatures } from './components/VPFeatures.vue';
15
16
  export { default as VPHomeContent } from './components/VPHomeContent.vue';
16
- export { default as VPHomeHero } from './components/VPHomeHero.vue';
17
17
  export { default as VPHomeFeatures } from './components/VPHomeFeatures.vue';
18
+ export { default as VPHomeHero } from './components/VPHomeHero.vue';
18
19
  export { default as VPHomeSponsors } from './components/VPHomeSponsors.vue';
20
+ export { default as VPImage } from './components/VPImage.vue';
19
21
  export { default as VPLink } from './components/VPLink.vue';
20
- export { default as VPDocAsideSponsors } from './components/VPDocAsideSponsors.vue';
22
+ export { default as VPNavBarSearch } from './components/VPNavBarSearch.vue';
21
23
  export { default as VPSocialLink } from './components/VPSocialLink.vue';
22
24
  export { default as VPSocialLinks } from './components/VPSocialLinks.vue';
23
25
  export { default as VPSponsors } from './components/VPSponsors.vue';
26
+ export { default as VPTeamMembers } from './components/VPTeamMembers.vue';
24
27
  export { default as VPTeamPage } from './components/VPTeamPage.vue';
25
- export { default as VPTeamPageTitle } from './components/VPTeamPageTitle.vue';
26
28
  export { default as VPTeamPageSection } from './components/VPTeamPageSection.vue';
27
- export { default as VPTeamMembers } from './components/VPTeamMembers.vue';
28
- export { useSidebar } from './composables/sidebar';
29
+ export { default as VPTeamPageTitle } from './components/VPTeamPageTitle.vue';
29
30
  export { useLocalNav } from './composables/local-nav';
31
+ export { useSidebar } from './composables/sidebar';
30
32
  const theme = {
31
33
  Layout,
32
34
  enhanceApp: ({ app }) => {