From b99d5123c9b2afdc7461089e03476c34d7816faf Mon Sep 17 00:00:00 2001 From: Divyansh Singh <40380293+brc-dd@users.noreply.github.com> Date: Sun, 9 Mar 2025 12:51:36 +0530 Subject: [PATCH 01/28] feat: support using header anchors in markdown file inclusion (#4608) closes #4375 closes #4382 Co-authored-by: btea <2356281422@qq.com> --- .../e2e/markdown-extensions/header-include.md | 27 +++++++++ __tests__/e2e/markdown-extensions/index.md | 6 +- .../markdown-extensions.test.ts | 57 ++++++++++++++++++- docs/en/guide/markdown.md | 47 +++++++++++++++ src/node/markdownToVue.ts | 2 +- src/node/plugins/localSearchPlugin.ts | 2 +- src/node/utils/processIncludes.ts | 52 ++++++++++++++--- 7 files changed, 180 insertions(+), 13 deletions(-) create mode 100644 __tests__/e2e/markdown-extensions/header-include.md diff --git a/__tests__/e2e/markdown-extensions/header-include.md b/__tests__/e2e/markdown-extensions/header-include.md new file mode 100644 index 00000000..70fac23b --- /dev/null +++ b/__tests__/e2e/markdown-extensions/header-include.md @@ -0,0 +1,27 @@ +# header 1 + +header 1 content + +## header 1.1 + +header 1.1 content + +### header 1.1.1 + +header 1.1.1 content + +### header 1.1.2 + +header 1.1.2 content + +## header 1.2 + +header 1.2 content + +### header 1.2.1 + +header 1.2.1 content + +### header 1.2.2 + +header 1.2.2 content diff --git a/__tests__/e2e/markdown-extensions/index.md b/__tests__/e2e/markdown-extensions/index.md index 855803f2..3446b4ef 100644 --- a/__tests__/e2e/markdown-extensions/index.md +++ b/__tests__/e2e/markdown-extensions/index.md @@ -213,6 +213,10 @@ export default config +## Markdown File Inclusion with Header + + + ## Image Lazy Loading -![vitepress logo](/vitepress.png) \ No newline at end of file +![vitepress logo](/vitepress.png) diff --git a/__tests__/e2e/markdown-extensions/markdown-extensions.test.ts b/__tests__/e2e/markdown-extensions/markdown-extensions.test.ts index e49a137f..839f953c 100644 --- a/__tests__/e2e/markdown-extensions/markdown-extensions.test.ts +++ b/__tests__/e2e/markdown-extensions/markdown-extensions.test.ts @@ -64,8 +64,61 @@ describe('Emoji', () => { describe('Table of Contents', () => { test('render toc', async () => { const items = page.locator('#table-of-contents + nav ul li') - const count = await items.count() - expect(count).toBe(44) + expect( + await items.evaluateAll((elements) => + elements.map((el) => el.childNodes[0].textContent) + ) + ).toMatchInlineSnapshot(` + [ + "Links", + "Internal Links", + "External Links", + "GitHub-Style Tables", + "Emoji", + "Table of Contents", + "Custom Containers", + "Default Title", + "Custom Title", + "Line Highlighting in Code Blocks", + "Single Line", + "Multiple single lines, ranges", + "Comment Highlight", + "Line Numbers", + "Import Code Snippets", + "Basic Code Snippet", + "Specify Region", + "With Other Features", + "Code Groups", + "Basic Code Group", + "With Other Features", + "Markdown File Inclusion", + "Region", + "Markdown At File Inclusion", + "Markdown Nested File Inclusion", + "Region", + "After Foo", + "Sub sub", + "Sub sub sub", + "Markdown File Inclusion with Range", + "Region", + "Markdown File Inclusion with Range without Start", + "Region", + "Markdown File Inclusion with Range without End", + "Region", + "Markdown At File Region Snippet", + "Region Snippet", + "Markdown At File Range Region Snippet", + "Range Region Line 2", + "Markdown At File Range Region Snippet without start", + "Range Region Line 1", + "Markdown At File Range Region Snippet without end", + "Range Region Line 3", + "Markdown File Inclusion with Header", + "header 1.1.1", + "header 1.1.2", + "Image Lazy Loading", + ] + `) }) }) diff --git a/docs/en/guide/markdown.md b/docs/en/guide/markdown.md index cf052919..88729f3e 100644 --- a/docs/en/guide/markdown.md +++ b/docs/en/guide/markdown.md @@ -897,6 +897,53 @@ You can also use a [VS Code region](https://code.visualstudio.com/docs/editor/co Note that this does not throw errors if your file is not present. Hence, when using this feature make sure that the contents are being rendered as expected. ::: +Instead of VS Code regions, you can also use header anchors to include a specific section of the file. For example, if you have a header in your markdown file like this: + +```md +## My Base Section + +Some content here. + +### My Sub Section + +Some more content here. + +## Another Section + +Content outside `My Base Section`. +``` + +You can include the `My Base Section` section like this: + +```md +## My Extended Section + +``` + +**Equivalent code** + +```md +## My Extended Section + +Some content here. + +### My Sub Section + +Some more content here. +``` + +Here, `my-base-section` is the generated id of the heading element. In case it's not easily guessable, you can open the part file in your browser and click on the heading anchor (`#` symbol left to the heading when hovered) to see the id in the URL bar. Or use browser dev tools to inspect the element. Alternatively, you can also specify the id to the part file like this: + +```md +## My Base Section {#custom-id} +``` + +and include it like this: + +```md + +``` + ## Math Equations This is currently opt-in. To enable it, you need to install `markdown-it-mathjax3` and set `markdown.math` to `true` in your config file: diff --git a/src/node/markdownToVue.ts b/src/node/markdownToVue.ts index d4576cda..6d2ba98d 100644 --- a/src/node/markdownToVue.ts +++ b/src/node/markdownToVue.ts @@ -142,7 +142,7 @@ export async function createMarkdownToVueRenderFn( // resolve includes let includes: string[] = [] - src = processIncludes(srcDir, src, fileOrig, includes) + src = processIncludes(md, srcDir, src, fileOrig, includes, cleanUrls) const localeIndex = getLocaleForPath(siteConfig?.site, relativePath) diff --git a/src/node/plugins/localSearchPlugin.ts b/src/node/plugins/localSearchPlugin.ts index debc024c..5687ad03 100644 --- a/src/node/plugins/localSearchPlugin.ts +++ b/src/node/plugins/localSearchPlugin.ts @@ -56,7 +56,7 @@ export async function localSearchPlugin( const relativePath = slash(path.relative(srcDir, file)) const env: MarkdownEnv = { path: file, relativePath, cleanUrls } const md_raw = await fs.promises.readFile(file, 'utf-8') - const md_src = processIncludes(srcDir, md_raw, file, []) + const md_src = processIncludes(md, srcDir, md_raw, file, [], cleanUrls) if (options._render) { return await options._render(md_src, env, md) } else { diff --git a/src/node/utils/processIncludes.ts b/src/node/utils/processIncludes.ts index acdccab7..aa98ccbd 100644 --- a/src/node/utils/processIncludes.ts +++ b/src/node/utils/processIncludes.ts @@ -1,18 +1,21 @@ import fs from 'fs-extra' import matter from 'gray-matter' +import type { MarkdownItAsync } from 'markdown-it-async' import path from 'node:path' import c from 'picocolors' import { findRegion } from '../markdown/plugins/snippet' -import { slash } from '../shared' +import { slash, type MarkdownEnv } from '../shared' export function processIncludes( + md: MarkdownItAsync, srcDir: string, src: string, file: string, - includes: string[] + includes: string[], + cleanUrls: boolean ): string { const includesRE = //g - const regionRE = /(#[\w-]+)/ + const regionRE = /(#[^\s\{]+)/ const rangeRE = /\{(\d*),(\d*)\}$/ return src.replace(includesRE, (m: string, m1: string) => { @@ -39,8 +42,34 @@ export function processIncludes( if (region) { const [regionName] = region const lines = content.split(/\r?\n/) - const regionLines = findRegion(lines, regionName.slice(1)) - content = lines.slice(regionLines?.start, regionLines?.end).join('\n') + let { start, end } = findRegion(lines, regionName.slice(1)) ?? {} + + if (start === undefined) { + // region not found, it might be a header + const tokens = md + .parse(content, { + path: includePath, + relativePath: slash(path.relative(srcDir, includePath)), + cleanUrls + } satisfies MarkdownEnv) + .filter((t) => t.type === 'heading_open' && t.map) + const idx = tokens.findIndex( + (t) => t.attrGet('id') === regionName.slice(1) + ) + const token = tokens[idx] + if (token) { + start = token.map![1] + const level = parseInt(token.tag.slice(1)) + for (let i = idx + 1; i < tokens.length; i++) { + if (parseInt(tokens[i].tag.slice(1)) <= level) { + end = tokens[i].map![0] + break + } + } + } + } + + content = lines.slice(start, end).join('\n') } if (range) { @@ -48,8 +77,8 @@ export function processIncludes( const lines = content.split(/\r?\n/) content = lines .slice( - startLine ? parseInt(startLine, 10) - 1 : undefined, - endLine ? parseInt(endLine, 10) : undefined + startLine ? parseInt(startLine) - 1 : undefined, + endLine ? parseInt(endLine) : undefined ) .join('\n') } @@ -60,7 +89,14 @@ export function processIncludes( includes.push(slash(includePath)) // recursively process includes in the content - return processIncludes(srcDir, content, includePath, includes) + return processIncludes( + md, + srcDir, + content, + includePath, + includes, + cleanUrls + ) // } catch (error) { From 5fc2eaa8b6e596db04c8925bfee57ffc684eebf7 Mon Sep 17 00:00:00 2001 From: Divyansh Singh <40380293+brc-dd@users.noreply.github.com> Date: Sun, 9 Mar 2025 12:55:29 +0530 Subject: [PATCH 02/28] release: v2.0.0-alpha.4 --- CHANGELOG.md | 18 ++++++++++++++++++ package.json | 2 +- 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index ec6ee176..387e81e0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,21 @@ +## [2.0.0-alpha.4](https://github.com/vuejs/vitepress/compare/v2.0.0-alpha.3...v2.0.0-alpha.4) (2025-03-09) + +### Bug Fixes + +- **build/regression:** langAlias not working ([06ae2bf](https://github.com/vuejs/vitepress/commit/06ae2bf3a4ee02351530b0bd055e577ca6509d62)), closes [#4581](https://github.com/vuejs/vitepress/issues/4581) +- don't hardcode `tabindex` attr in table renderer ([#4082](https://github.com/vuejs/vitepress/issues/4082)) ([aadc517](https://github.com/vuejs/vitepress/commit/aadc517c69fb239bdda99173bbc123ace567484b)) +- hmr not working for watched files in path loaders ([e271695](https://github.com/vuejs/vitepress/commit/e271695d716247455ca620948f814e6c8ca0e3c4)), closes [#4525](https://github.com/vuejs/vitepress/issues/4525) +- ignore non-text content in permalink generation and fix types of markdown.config ([a8a1800](https://github.com/vuejs/vitepress/commit/a8a1800ae578be88027aa4ec7561ada4d055b888)) +- prevent reload on first server start in fresh installations ([d8a884e](https://github.com/vuejs/vitepress/commit/d8a884ed0f754523765058a70149cdbaf6942341)) +- properly merge classes in custom containers ([#4128](https://github.com/vuejs/vitepress/issues/4128)) ([8aad617](https://github.com/vuejs/vitepress/commit/8aad617446c03d39a65a0b21e9fce43bc484af1e)) +- rebuild dynamic routes cache on server restart ([9f54714](https://github.com/vuejs/vitepress/commit/9f54714e7db69fd4902f1917f927456c71b5a292)), closes [#4525](https://github.com/vuejs/vitepress/issues/4525) + +### Features + +- allow matching region end in snippets without tag ([#4287](https://github.com/vuejs/vitepress/issues/4287)) ([1a2f81d](https://github.com/vuejs/vitepress/commit/1a2f81de4d6549dd1adf86ae131d1a861158bd2d)) +- improve region regexes for snippet plugin ([1a6684c](https://github.com/vuejs/vitepress/commit/1a6684cf1054d326bc1dd6eeb9fb78b150ac2b2a)) +- support using header anchors in markdown file inclusion ([#4608](https://github.com/vuejs/vitepress/issues/4608)) ([b99d512](https://github.com/vuejs/vitepress/commit/b99d5123c9b2afdc7461089e03476c34d7816faf)), closes [#4375](https://github.com/vuejs/vitepress/issues/4375) [#4382](https://github.com/vuejs/vitepress/issues/4382) + ## [2.0.0-alpha.3](https://github.com/vuejs/vitepress/compare/v2.0.0-alpha.2...v2.0.0-alpha.3) (2025-02-24) ### Bug Fixes diff --git a/package.json b/package.json index 5e110096..f44e3c28 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "vitepress", - "version": "2.0.0-alpha.3", + "version": "2.0.0-alpha.4", "description": "Vite & Vue powered static site generator", "keywords": [ "vite", From e06b83ec0949a0fad712f4059819e737058ca0e7 Mon Sep 17 00:00:00 2001 From: Bugo Date: Sun, 9 Mar 2025 13:30:17 +0500 Subject: [PATCH 03/28] docs(ru): update translations (#4610) --------- Co-authored-by: Divyansh Singh <40380293+brc-dd@users.noreply.github.com> --- docs/ru/guide/i18n.md | 2 +- docs/ru/guide/markdown.md | 51 +++++++++++++++++++++++++++++++++++++-- 2 files changed, 50 insertions(+), 3 deletions(-) diff --git a/docs/ru/guide/i18n.md b/docs/ru/guide/i18n.md index d698f030..b982eece 100644 --- a/docs/ru/guide/i18n.md +++ b/docs/ru/guide/i18n.md @@ -27,7 +27,7 @@ export default defineConfig({ ru: { label: 'Русский', lang: 'ru', // необязательный, будет добавлен как атрибут `lang` в тег `html` - link: '/ru/guide' // по умолчанию /ru/ -- отображается в меню переводов на панели навигации, может быть внешним + link: '/ru/guide' // по умолчанию /ru/ -- ссылка в меню переводов на панели навигации, может быть внешней // другие свойства, специфичные для локали... } diff --git a/docs/ru/guide/markdown.md b/docs/ru/guide/markdown.md index 192bd2f8..b67e1355 100644 --- a/docs/ru/guide/markdown.md +++ b/docs/ru/guide/markdown.md @@ -844,7 +844,7 @@ export default config Может быть создана с помощью `.foorc.json`. ``` -**Эквивалентный код** +**Соответствующий код** ```md # Документация @@ -883,7 +883,7 @@ export default config ``` -**Эквивалентный код** +**Соответствующий код** ```md # Документация @@ -899,6 +899,53 @@ export default config Обратите внимание, что это не приводит к ошибкам, если ваш файл отсутствует. Поэтому при использовании этой функции убедитесь, что содержимое отображается так, как ожидается. ::: +Вместо регионов VS Code вы также можете использовать якоря заголовков, чтобы включить определённый раздел файла. Например, если у вас есть заголовок в вашем markdown-файле, например: + +```md +## Мой основной раздел + +Какой-то контент здесь. + +### Мой подраздел + +Ещё немного контента здесь. + +## Другой раздел + +Контент вне `Моего основного раздела`. +``` + +Вы можете включить раздел `Мой основной раздел` следующим образом: + +```md +## Мой дополнительный раздел + +``` + +**Соответствующий код** + +```md +## Мой дополнительный раздел + +Какой-то контент здесь. + +### Мой подраздел + +Ещё немного контента здесь. +``` + +Здесь `мои-основнои-раздел` — это сгенерированный идентификатор элемента заголовка. Если его нелегко угадать, вы можете открыть файл в браузере и нажать на якорь заголовка (символ `#` слева от заголовка при наведении), чтобы увидеть идентификатор в адресной строке. Или используйте инструменты разработчика браузера для проверки элемента. Кроме того, вы также можете указать идентификатор для файла части следующим образом: + +```md +## Мой основной раздел {#custom-id} +``` + +и включить его следующим образом: + +```md + +``` + ## Математические уравнения {#math-equations} В настоящее время эта фича предоставляется по желанию. Чтобы включить её, вам нужно установить `markdown-it-mathjax3` и установить значение `true` для опции `markdown.math` в вашем файле конфигурации: From e25d0805505db2f1116e99d38a488d5cb39ed426 Mon Sep 17 00:00:00 2001 From: Divyansh Singh <40380293+brc-dd@users.noreply.github.com> Date: Tue, 18 Mar 2025 09:31:13 +0530 Subject: [PATCH 04/28] fix: normalize url fragments in internal links to correctly resolve to anchors (#4628) closes #4605 - Normalizations aren't applied to raw html inside markdown or vue code. - It is assumed `slugify(slugify(something)) === slugify(something)` --- src/node/markdown/markdown.ts | 8 ++++++-- src/node/markdown/plugins/link.ts | 22 +++++++++++++++------- 2 files changed, 21 insertions(+), 9 deletions(-) diff --git a/src/node/markdown/markdown.ts b/src/node/markdown/markdown.ts index fd6bf492..bb56e0cf 100644 --- a/src/node/markdown/markdown.ts +++ b/src/node/markdown/markdown.ts @@ -13,7 +13,7 @@ import { import { sfcPlugin, type SfcPluginOptions } from '@mdit-vue/plugin-sfc' import { titlePlugin } from '@mdit-vue/plugin-title' import { tocPlugin, type TocPluginOptions } from '@mdit-vue/plugin-toc' -import { slugify } from '@mdit-vue/shared' +import { slugify as defaultSlugify } from '@mdit-vue/shared' import type { LanguageInput, ShikiTransformer, @@ -232,6 +232,8 @@ export async function createMarkdownRenderer( await options.preConfig(md) } + const slugify = options.anchor?.slugify ?? defaultSlugify + // custom plugins md.use(componentPlugin, { ...options.component }) .use(highlightLinePlugin) @@ -242,7 +244,8 @@ export async function createMarkdownRenderer( .use( linkPlugin, { target: '_blank', rel: 'noreferrer', ...options.externalLinks }, - base + base, + slugify ) .use(lineNumberPlugin, options.lineNumbers) @@ -317,6 +320,7 @@ export async function createMarkdownRenderer( } as SfcPluginOptions) .use(titlePlugin) .use(tocPlugin, { + slugify, ...options.toc } as TocPluginOptions) diff --git a/src/node/markdown/plugins/link.ts b/src/node/markdown/plugins/link.ts index 3e48843c..2fe2e1ac 100644 --- a/src/node/markdown/plugins/link.ts +++ b/src/node/markdown/plugins/link.ts @@ -16,7 +16,8 @@ const indexRE = /(^|.*\/)index.md(#?.*)$/i export const linkPlugin = ( md: MarkdownItAsync, externalAttrs: Record, - base: string + base: string, + slugify: (str: string) => string ) => { md.renderer.rules.link_open = ( tokens, @@ -27,9 +28,12 @@ export const linkPlugin = ( ) => { const token = tokens[idx] const hrefIndex = token.attrIndex('href') - const targetIndex = token.attrIndex('target') - const downloadIndex = token.attrIndex('download') - if (hrefIndex >= 0 && targetIndex < 0 && downloadIndex < 0) { + if ( + hrefIndex >= 0 && + token.attrIndex('target') < 0 && + token.attrIndex('download') < 0 && + token.attrGet('class') !== 'header-anchor' // header anchors are already normalized + ) { const hrefAttr = token.attrs![hrefIndex] const url = hrefAttr[1] if (isExternal(url)) { @@ -54,7 +58,7 @@ export const linkPlugin = ( ) { normalizeHref(hrefAttr, env) } else if (url.startsWith('#')) { - hrefAttr[1] = decodeURI(hrefAttr[1]) + hrefAttr[1] = decodeURI(normalizeHash(hrefAttr[1])) } // append base to internal (non-relative) urls @@ -72,7 +76,7 @@ export const linkPlugin = ( const indexMatch = url.match(indexRE) if (indexMatch) { const [, path, hash] = indexMatch - url = path + hash + url = path + normalizeHash(hash) } else { let cleanUrl = url.replace(/[?#].*$/, '') // transform foo.md -> foo[.html] @@ -88,7 +92,7 @@ export const linkPlugin = ( cleanUrl += '.html' } const parsed = new URL(url, 'http://a.com') - url = cleanUrl + parsed.search + parsed.hash + url = cleanUrl + parsed.search + normalizeHash(parsed.hash) } // ensure leading . for relative paths @@ -103,6 +107,10 @@ export const linkPlugin = ( hrefAttr[1] = decodeURI(url) } + function normalizeHash(str: string) { + return str ? encodeURI('#' + slugify(decodeURI(str).slice(1))) : '' + } + function pushLink(link: string, env: MarkdownEnv) { const links = env.links || (env.links = []) links.push(link) From a97ae461d4bba64af00444f0cacc62f053cfd97c Mon Sep 17 00:00:00 2001 From: Okinea Dev Date: Wed, 19 Mar 2025 02:31:03 +0100 Subject: [PATCH 05/28] chore: use SVG logo on main website page (#4623) --------- Co-authored-by: Kia King Ishii Co-authored-by: Divyansh Singh <40380293+brc-dd@users.noreply.github.com> --- art/vitepress-logo.svg | 2 +- docs/.vitepress/theme/styles.css | 5 +++++ docs/en/index.md | 2 +- docs/es/index.md | 2 +- docs/fa/index.md | 2 +- docs/ko/index.md | 2 +- docs/pt/index.md | 2 +- docs/public/vitepress-logo-large.svg | 1 + docs/public/vitepress-logo-mini.svg | 22 +--------------------- docs/ru/index.md | 2 +- 10 files changed, 14 insertions(+), 28 deletions(-) create mode 120000 docs/public/vitepress-logo-large.svg mode change 100644 => 120000 docs/public/vitepress-logo-mini.svg diff --git a/art/vitepress-logo.svg b/art/vitepress-logo.svg index 1052015b..0805ed51 100644 --- a/art/vitepress-logo.svg +++ b/art/vitepress-logo.svg @@ -1,4 +1,4 @@ - + diff --git a/docs/.vitepress/theme/styles.css b/docs/.vitepress/theme/styles.css index 1f397744..ce1c75d2 100644 --- a/docs/.vitepress/theme/styles.css +++ b/docs/.vitepress/theme/styles.css @@ -33,6 +33,11 @@ } } +.VPHero .VPImage { + filter: drop-shadow(-2px 4px 6px rgba(0, 0, 0, 0.2)); + padding: 18px; +} + /* used in reference/default-theme-search */ img[src='/search.png'] { width: 100%; diff --git a/docs/en/index.md b/docs/en/index.md index d65ee07b..c91ce953 100644 --- a/docs/en/index.md +++ b/docs/en/index.md @@ -19,7 +19,7 @@ hero: text: GitHub link: https://github.com/vuejs/vitepress image: - src: /vitepress-logo-large.webp + src: /vitepress-logo-large.svg alt: VitePress features: diff --git a/docs/es/index.md b/docs/es/index.md index 6ced6057..04a4c68f 100644 --- a/docs/es/index.md +++ b/docs/es/index.md @@ -19,7 +19,7 @@ hero: text: GitHub link: https://github.com/vuejs/vitepress image: - src: /vitepress-logo-large.webp + src: /vitepress-logo-large.svg alt: VitePress features: diff --git a/docs/fa/index.md b/docs/fa/index.md index 1637397f..cd6552ba 100644 --- a/docs/fa/index.md +++ b/docs/fa/index.md @@ -19,7 +19,7 @@ hero: text: گیت‌هاب link: https://github.com/vuejs/vitepress image: - src: /vitepress-logo-large.webp + src: /vitepress-logo-large.svg alt: ویت‌پرس features: diff --git a/docs/ko/index.md b/docs/ko/index.md index 6a16ff49..3ddaa07d 100644 --- a/docs/ko/index.md +++ b/docs/ko/index.md @@ -19,7 +19,7 @@ hero: text: GitHub link: https://github.com/vuejs/vitepress image: - src: /vitepress-logo-large.webp + src: /vitepress-logo-large.svg alt: VitePress features: diff --git a/docs/pt/index.md b/docs/pt/index.md index fccf03a0..71fff26b 100644 --- a/docs/pt/index.md +++ b/docs/pt/index.md @@ -19,7 +19,7 @@ hero: text: GitHub link: https://github.com/vuejs/vitepress image: - src: /vitepress-logo-large.webp + src: /vitepress-logo-large.svg alt: VitePress features: diff --git a/docs/public/vitepress-logo-large.svg b/docs/public/vitepress-logo-large.svg new file mode 120000 index 00000000..59e331aa --- /dev/null +++ b/docs/public/vitepress-logo-large.svg @@ -0,0 +1 @@ +../../art/vitepress-logo.svg \ No newline at end of file diff --git a/docs/public/vitepress-logo-mini.svg b/docs/public/vitepress-logo-mini.svg deleted file mode 100644 index 47756f7a..00000000 --- a/docs/public/vitepress-logo-mini.svg +++ /dev/null @@ -1,21 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - diff --git a/docs/public/vitepress-logo-mini.svg b/docs/public/vitepress-logo-mini.svg new file mode 120000 index 00000000..f7c9b3af --- /dev/null +++ b/docs/public/vitepress-logo-mini.svg @@ -0,0 +1 @@ +../../art/vitepress-logo-mini.svg \ No newline at end of file diff --git a/docs/ru/index.md b/docs/ru/index.md index 6d5f0de3..77f2072a 100644 --- a/docs/ru/index.md +++ b/docs/ru/index.md @@ -19,7 +19,7 @@ hero: text: GitHub link: https://github.com/vuejs/vitepress image: - src: /vitepress-logo-large.webp + src: /vitepress-logo-large.svg alt: VitePress features: From d07298120b31bd9ddd251d95ce8c2d2c2f919734 Mon Sep 17 00:00:00 2001 From: btea <2356281422@qq.com> Date: Wed, 19 Mar 2025 21:58:45 +0800 Subject: [PATCH 06/28] docs: markdown file inclusion example config line-numbers (#4633) --- docs/en/guide/markdown.md | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/docs/en/guide/markdown.md b/docs/en/guide/markdown.md index 88729f3e..bbd2b2a3 100644 --- a/docs/en/guide/markdown.md +++ b/docs/en/guide/markdown.md @@ -824,7 +824,7 @@ It also supports selecting a line range: **Input** -```md +```md:line-numbers # Docs ## Basics @@ -834,7 +834,7 @@ It also supports selecting a line range: **Part file** (`parts/basics.md`) -```md +```md:line-numbers Some getting started stuff. ### Configuration @@ -844,7 +844,7 @@ Can be created using `.foorc.json`. **Equivalent code** -```md +```md:line-numbers # Docs ## Basics @@ -860,7 +860,7 @@ You can also use a [VS Code region](https://code.visualstudio.com/docs/editor/co **Input** -```md +```md:line-numbers # Docs ## Basics @@ -871,7 +871,7 @@ You can also use a [VS Code region](https://code.visualstudio.com/docs/editor/co **Part file** (`parts/basics.md`) -```md +```md:line-numbers ## Usage Line 1 @@ -883,7 +883,7 @@ You can also use a [VS Code region](https://code.visualstudio.com/docs/editor/co **Equivalent code** -```md +```md:line-numbers # Docs ## Basics From 9d0145d32dd72bfcc6964afb7c5016668fb57a40 Mon Sep 17 00:00:00 2001 From: GabrielxD Date: Thu, 20 Mar 2025 21:52:00 +0800 Subject: [PATCH 07/28] chore(docs): use SVG logo on zh index page (#4638) --- docs/zh/index.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/zh/index.md b/docs/zh/index.md index 81f71c16..e07f9136 100644 --- a/docs/zh/index.md +++ b/docs/zh/index.md @@ -19,7 +19,7 @@ hero: text: GitHub link: https://github.com/vuejs/vitepress image: - src: /vitepress-logo-large.webp + src: /vitepress-logo-large.svg alt: VitePress features: From 7d9448192079e59493aa5c1e86cdf6d6deae8e36 Mon Sep 17 00:00:00 2001 From: GabrielxD Date: Fri, 21 Mar 2025 15:42:57 +0800 Subject: [PATCH 08/28] fix(theme-default): ensure proper sizing of SVG hero images (#4639) Co-authored-by: Divyansh Singh <40380293+brc-dd@users.noreply.github.com> --- src/client/theme-default/components/VPHero.vue | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/client/theme-default/components/VPHero.vue b/src/client/theme-default/components/VPHero.vue index b3d527d7..c60a9b46 100644 --- a/src/client/theme-default/components/VPHero.vue +++ b/src/client/theme-default/components/VPHero.vue @@ -322,6 +322,9 @@ const heroImageSlotExists = inject('hero-image-slot-exists') as Ref left: 50%; max-width: 192px; max-height: 192px; + width: 100%; + height: 100%; + object-fit: contain; /*rtl:ignore*/ transform: translate(-50%, -50%); } From 63079bff03b15861d174199f7361a2aff84380e0 Mon Sep 17 00:00:00 2001 From: Shigma Date: Mon, 24 Mar 2025 11:29:14 +0800 Subject: [PATCH 09/28] feat: add `custom-block-title-default` class when default title is used for containers (#4643) --- src/node/markdown/plugins/containers.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/node/markdown/plugins/containers.ts b/src/node/markdown/plugins/containers.ts index 073fb38d..a00b9a85 100644 --- a/src/node/markdown/plugins/containers.ts +++ b/src/node/markdown/plugins/containers.ts @@ -69,9 +69,11 @@ function createContainer( const title = md.renderInline(info || defaultTitle, { references: env.references }) + const titleClass = + 'custom-block-title' + (info ? '' : ' custom-block-title-default') if (klass === 'details') return `
${title}\n` - return `

${title}

\n` + return `

${title}

\n` } else return klass === 'details' ? `\n` : `
\n` } } From ae0d52d9990b48b0bd8a6e2cd6c97182a11c5a8a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=BF=A0=20/=20green?= Date: Tue, 25 Mar 2025 16:41:12 +0900 Subject: [PATCH 10/28] refactor: avoid assigning to bundle object (#4647) --- src/node/plugin.ts | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/src/node/plugin.ts b/src/node/plugin.ts index 219c18b6..748c4da4 100644 --- a/src/node/plugin.ts +++ b/src/node/plugin.ts @@ -366,15 +366,12 @@ export async function createVitePressPlugin( pageToHashMap![chunk.name.toLowerCase()] = hash // inject another chunk with the content stripped - bundle[name + '-lean'] = { - ...chunk, + this.emitFile({ + type: 'asset', + name: name + '-lean', fileName: chunk.fileName.replace(/\.js$/, '.lean.js'), - preliminaryFileName: chunk.preliminaryFileName.replace( - /\.js$/, - '.lean.js' - ), - code: chunk.code.replace(staticStripRE, `""`) - } + source: chunk.code.replace(staticStripRE, `""`) + }) // remove static markers from original code chunk.code = chunk.code.replace(staticRestoreRE, '') From 531a7a19d2fd94522a1dfeb5e996897f3122d0ca Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 25 Mar 2025 20:19:22 +0530 Subject: [PATCH 11/28] chore(deps): bump vite from 6.2.1 to 6.2.3 (#4648) Bumps [vite](https://github.com/vitejs/vite/tree/HEAD/packages/vite) from 6.2.1 to 6.2.3. - [Release notes](https://github.com/vitejs/vite/releases) - [Changelog](https://github.com/vitejs/vite/blob/v6.2.3/packages/vite/CHANGELOG.md) - [Commits](https://github.com/vitejs/vite/commits/v6.2.3/packages/vite) --- updated-dependencies: - dependency-name: vite dependency-type: direct:production ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- pnpm-lock.yaml | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 76b395f3..5e0c5d93 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -39,7 +39,7 @@ importers: version: 3.1.0 '@vitejs/plugin-vue': specifier: ^5.2.1 - version: 5.2.1(vite@6.2.1(@types/node@22.13.9)(jiti@1.21.7)(yaml@2.7.0))(vue@3.5.13(typescript@5.8.2)) + version: 5.2.1(vite@6.2.3(@types/node@22.13.9)(jiti@1.21.7)(yaml@2.7.0))(vue@3.5.13(typescript@5.8.2)) '@vue/devtools-api': specifier: ^7.7.2 version: 7.7.2 @@ -66,7 +66,7 @@ importers: version: 3.1.0 vite: specifier: ^6.2.1 - version: 6.2.1(@types/node@22.13.9)(jiti@1.21.7)(yaml@2.7.0) + version: 6.2.3(@types/node@22.13.9)(jiti@1.21.7)(yaml@2.7.0) vue: specifier: ^3.5.13 version: 3.5.13(typescript@5.8.2) @@ -2093,8 +2093,8 @@ packages: muggle-string@0.4.1: resolution: {integrity: sha512-VNTrAak/KhO2i8dqqnqnAHOa3cYBwXEZe9h+D5h/1ZqFSTEFHdM65lR7RoIqq3tBBYavsOXV84NoHXZ0AkPyqQ==} - nanoid@3.3.9: - resolution: {integrity: sha512-SppoicMGpZvbF1l3z4x7No3OlIjP7QJvC9XR7AhZr1kL133KHnKPztkKDc+Ir4aJ/1VhTySrtKhrsycmrMQfvg==} + nanoid@3.3.11: + resolution: {integrity: sha512-N8SpfPUnUp1bK+PMYW8qSWdl9U+wwNWI4QKxOYDy9JAro3WMX7p2OeVRF9v+347pnakNevPmiHhNmZ2HbFA76w==} engines: {node: ^10 || ^12 || ^13.7 || ^14 || >=15.0.1} hasBin: true @@ -2713,8 +2713,8 @@ packages: engines: {node: ^18.0.0 || ^20.0.0 || >=22.0.0} hasBin: true - vite@6.2.1: - resolution: {integrity: sha512-n2GnqDb6XPhlt9B8olZPrgMD/es/Nd1RdChF6CBD/fHW6pUyUTt2sQW2fPRX5GiD9XEa6+8A6A4f2vT6pSsE7Q==} + vite@6.2.3: + resolution: {integrity: sha512-IzwM54g4y9JA/xAeBPNaDXiBF8Jsgl3VBQ2YQ/wOY6fyW3xMdSoltIV3Bo59DErdqdE6RxUfv8W69DvUorE4Eg==} engines: {node: ^18.0.0 || ^20.0.0 || >=22.0.0} hasBin: true peerDependencies: @@ -3505,9 +3505,9 @@ snapshots: '@ungap/structured-clone@1.3.0': {} - '@vitejs/plugin-vue@5.2.1(vite@6.2.1(@types/node@22.13.9)(jiti@1.21.7)(yaml@2.7.0))(vue@3.5.13(typescript@5.8.2))': + '@vitejs/plugin-vue@5.2.1(vite@6.2.3(@types/node@22.13.9)(jiti@1.21.7)(yaml@2.7.0))(vue@3.5.13(typescript@5.8.2))': dependencies: - vite: 6.2.1(@types/node@22.13.9)(jiti@1.21.7)(yaml@2.7.0) + vite: 6.2.3(@types/node@22.13.9)(jiti@1.21.7)(yaml@2.7.0) vue: 3.5.13(typescript@5.8.2) '@vitest/expect@3.0.8': @@ -3517,13 +3517,13 @@ snapshots: chai: 5.2.0 tinyrainbow: 2.0.0 - '@vitest/mocker@3.0.8(vite@6.2.1(@types/node@22.13.9)(jiti@1.21.7)(yaml@2.7.0))': + '@vitest/mocker@3.0.8(vite@6.2.3(@types/node@22.13.9)(jiti@1.21.7)(yaml@2.7.0))': dependencies: '@vitest/spy': 3.0.8 estree-walker: 3.0.3 magic-string: 0.30.17 optionalDependencies: - vite: 6.2.1(@types/node@22.13.9)(jiti@1.21.7)(yaml@2.7.0) + vite: 6.2.3(@types/node@22.13.9)(jiti@1.21.7)(yaml@2.7.0) '@vitest/pretty-format@3.0.8': dependencies: @@ -4654,7 +4654,7 @@ snapshots: muggle-string@0.4.1: {} - nanoid@3.3.9: {} + nanoid@3.3.11: {} nanoid@5.1.3: {} @@ -4815,7 +4815,7 @@ snapshots: postcss@8.5.3: dependencies: - nanoid: 3.3.9 + nanoid: 3.3.11 picocolors: 1.1.1 source-map-js: 1.2.1 @@ -5261,7 +5261,7 @@ snapshots: debug: 4.4.0 es-module-lexer: 1.6.0 pathe: 2.0.3 - vite: 6.2.1(@types/node@22.13.9)(jiti@1.21.7)(yaml@2.7.0) + vite: 6.2.3(@types/node@22.13.9)(jiti@1.21.7)(yaml@2.7.0) transitivePeerDependencies: - '@types/node' - jiti @@ -5276,7 +5276,7 @@ snapshots: - tsx - yaml - vite@6.2.1(@types/node@22.13.9)(jiti@1.21.7)(yaml@2.7.0): + vite@6.2.3(@types/node@22.13.9)(jiti@1.21.7)(yaml@2.7.0): dependencies: esbuild: 0.25.0 postcss: 8.5.3 @@ -5298,7 +5298,7 @@ snapshots: vitest@3.0.8(@types/debug@4.1.12)(@types/node@22.13.9)(jiti@1.21.7)(yaml@2.7.0): dependencies: '@vitest/expect': 3.0.8 - '@vitest/mocker': 3.0.8(vite@6.2.1(@types/node@22.13.9)(jiti@1.21.7)(yaml@2.7.0)) + '@vitest/mocker': 3.0.8(vite@6.2.3(@types/node@22.13.9)(jiti@1.21.7)(yaml@2.7.0)) '@vitest/pretty-format': 3.0.8 '@vitest/runner': 3.0.8 '@vitest/snapshot': 3.0.8 @@ -5314,7 +5314,7 @@ snapshots: tinyexec: 0.3.2 tinypool: 1.0.2 tinyrainbow: 2.0.0 - vite: 6.2.1(@types/node@22.13.9)(jiti@1.21.7)(yaml@2.7.0) + vite: 6.2.3(@types/node@22.13.9)(jiti@1.21.7)(yaml@2.7.0) vite-node: 3.0.8(@types/node@22.13.9)(jiti@1.21.7)(yaml@2.7.0) why-is-node-running: 2.3.0 optionalDependencies: From db58af5c66e563e7663084057a9853d8f2da984c Mon Sep 17 00:00:00 2001 From: Divyansh Singh <40380293+brc-dd@users.noreply.github.com> Date: Thu, 27 Mar 2025 14:28:27 +0530 Subject: [PATCH 12/28] fix!: don't remove shiki styles from `pre` and remove unnecessary transformers (#4652) BREAKING CHANGE: `vp-adaptive-theme` class is no longer added to code blocks when there is single theme. Theme authors supporting single code theme can use `.shiki:not(.shiki-themes)` as selector. Alternatively, it might be better to use the bg/fg variables set on the `.shiki` block to keep things generic. BREAKING CHANGE: `vp-code` class is no longer added to code blocks. Use `.shiki` or `pre.shiki` or `[class*='language-'] pre` instead. People not customizing their themes are not affected. But if you see weird stuff, you know what to change. --- .../styles/components/vp-code.css | 4 +- src/node/markdown/markdown.ts | 5 +-- src/node/markdown/plugins/containers.ts | 43 +++++-------------- src/node/markdown/plugins/highlight.ts | 14 +----- src/node/markdown/plugins/preWrapper.ts | 7 +-- 5 files changed, 16 insertions(+), 57 deletions(-) diff --git a/src/client/theme-default/styles/components/vp-code.css b/src/client/theme-default/styles/components/vp-code.css index 1ff9429b..5c42b9ca 100644 --- a/src/client/theme-default/styles/components/vp-code.css +++ b/src/client/theme-default/styles/components/vp-code.css @@ -1,7 +1,7 @@ -.dark .vp-code span { +.dark .shiki span { color: var(--shiki-dark, inherit); } -html:not(.dark) .vp-code span { +html:not(.dark) .shiki span { color: var(--shiki-light, inherit); } diff --git a/src/node/markdown/markdown.ts b/src/node/markdown/markdown.ts index bb56e0cf..7b006620 100644 --- a/src/node/markdown/markdown.ts +++ b/src/node/markdown/markdown.ts @@ -215,7 +215,6 @@ export async function createMarkdownRenderer( const theme = options.theme ?? { light: 'github-light', dark: 'github-dark' } const codeCopyButtonTitle = options.codeCopyButtonTitle || 'Copy Code' - const hasSingleTheme = typeof theme === 'string' || 'name' in theme let [highlight, dispose] = options.highlight ? [options.highlight, () => {}] @@ -237,9 +236,9 @@ export async function createMarkdownRenderer( // custom plugins md.use(componentPlugin, { ...options.component }) .use(highlightLinePlugin) - .use(preWrapperPlugin, { codeCopyButtonTitle, hasSingleTheme }) + .use(preWrapperPlugin, { codeCopyButtonTitle }) .use(snippetPlugin, srcDir) - .use(containerPlugin, { hasSingleTheme }, options.container) + .use(containerPlugin, options.container) .use(imagePlugin, options.image) .use( linkPlugin, diff --git a/src/node/markdown/plugins/containers.ts b/src/node/markdown/plugins/containers.ts index a00b9a85..39efce17 100644 --- a/src/node/markdown/plugins/containers.ts +++ b/src/node/markdown/plugins/containers.ts @@ -3,40 +3,17 @@ import container from 'markdown-it-container' import type { RenderRule } from 'markdown-it/lib/renderer.mjs' import type Token from 'markdown-it/lib/token.mjs' import type { MarkdownEnv } from '../../shared' -import { - extractTitle, - getAdaptiveThemeMarker, - type Options -} from './preWrapper' +import { extractTitle } from './preWrapper' export const containerPlugin = ( md: MarkdownItAsync, - options: Options, - containerOptions?: ContainerOptions + options?: ContainerOptions ) => { - md.use(...createContainer('tip', containerOptions?.tipLabel || 'TIP', md)) - .use(...createContainer('info', containerOptions?.infoLabel || 'INFO', md)) - .use( - ...createContainer( - 'warning', - containerOptions?.warningLabel || 'WARNING', - md - ) - ) - .use( - ...createContainer( - 'danger', - containerOptions?.dangerLabel || 'DANGER', - md - ) - ) - .use( - ...createContainer( - 'details', - containerOptions?.detailsLabel || 'Details', - md - ) - ) + md.use(...createContainer('tip', options?.tipLabel || 'TIP', md)) + .use(...createContainer('info', options?.infoLabel || 'INFO', md)) + .use(...createContainer('warning', options?.warningLabel || 'WARNING', md)) + .use(...createContainer('danger', options?.dangerLabel || 'DANGER', md)) + .use(...createContainer('details', options?.detailsLabel || 'Details', md)) // explicitly escape Vue syntax .use(container, 'v-pre', { render: (tokens: Token[], idx: number) => @@ -46,7 +23,7 @@ export const containerPlugin = ( render: (tokens: Token[], idx: number) => tokens[idx].nesting === 1 ? `
\n` : `
\n` }) - .use(...createCodeGroup(options, md)) + .use(...createCodeGroup(md)) } type ContainerArgs = [typeof container, string, { render: RenderRule }] @@ -80,7 +57,7 @@ function createContainer( ] } -function createCodeGroup(options: Options, md: MarkdownItAsync): ContainerArgs { +function createCodeGroup(md: MarkdownItAsync): ContainerArgs { return [ container, 'code-group', @@ -118,7 +95,7 @@ function createCodeGroup(options: Options, md: MarkdownItAsync): ContainerArgs { } } - return `
${tabs}
\n` + return `
${tabs}
\n` } return `
\n` } diff --git a/src/node/markdown/plugins/highlight.ts b/src/node/markdown/plugins/highlight.ts index 52e5e84e..eef32b58 100644 --- a/src/node/markdown/plugins/highlight.ts +++ b/src/node/markdown/plugins/highlight.ts @@ -80,19 +80,7 @@ export async function highlight( classActivePre: 'has-focused-lines' }), transformerNotationHighlight(), - transformerNotationErrorLevel(), - { - name: 'vitepress:add-class', - pre(node) { - this.addClassToHast(node, 'vp-code') - } - }, - { - name: 'vitepress:clean-up', - pre(node) { - delete node.properties.style - } - } + transformerNotationErrorLevel() ] const vueRE = /-vue(?=:|$)/ diff --git a/src/node/markdown/plugins/preWrapper.ts b/src/node/markdown/plugins/preWrapper.ts index bd6b96ba..e7d553b3 100644 --- a/src/node/markdown/plugins/preWrapper.ts +++ b/src/node/markdown/plugins/preWrapper.ts @@ -2,7 +2,6 @@ import type { MarkdownItAsync } from 'markdown-it-async' export interface Options { codeCopyButtonTitle: string - hasSingleTheme: boolean } export function preWrapperPlugin(md: MarkdownItAsync, options: Options) { @@ -20,7 +19,7 @@ export function preWrapperPlugin(md: MarkdownItAsync, options: Options) { const lang = extractLang(token.info) return ( - `
` + + `
` + `` + `${lang}` + fence(...args) + @@ -29,10 +28,6 @@ export function preWrapperPlugin(md: MarkdownItAsync, options: Options) { } } -export function getAdaptiveThemeMarker(options: Options) { - return options.hasSingleTheme ? '' : ' vp-adaptive-theme' -} - export function extractTitle(info: string, html = false) { if (html) { return ( From 0267dcafa20beea24ef359d24bb1fa99e1ffda49 Mon Sep 17 00:00:00 2001 From: Yuxuan Zhang Date: Sat, 29 Mar 2025 23:07:36 -0400 Subject: [PATCH 13/28] feat(theme): make "Take me home" button's link customizable (#4658) --- src/client/theme-default/NotFound.vue | 2 +- types/default-theme.d.ts | 7 +++++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/src/client/theme-default/NotFound.vue b/src/client/theme-default/NotFound.vue index b9665142..f65d3a6d 100644 --- a/src/client/theme-default/NotFound.vue +++ b/src/client/theme-default/NotFound.vue @@ -22,7 +22,7 @@ const { currentLang } = useLangs()
{{ theme.notFound?.linkText ?? 'Take me home' }} diff --git a/types/default-theme.d.ts b/types/default-theme.d.ts index 5a669c49..2e17ce9d 100644 --- a/types/default-theme.d.ts +++ b/types/default-theme.d.ts @@ -480,6 +480,13 @@ export namespace DefaultTheme { */ quote?: string + /** + * Target of the home link. + * + * @default '/' + */ + link?: string + /** * Set aria label for home link. * From 35f36a96bb1cb34f7b2e1f1f3b26d26a9038ef8a Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 1 Apr 2025 00:29:39 +0530 Subject: [PATCH 14/28] chore(deps): bump vite from 6.2.3 to 6.2.4 (#4664) Bumps [vite](https://github.com/vitejs/vite/tree/HEAD/packages/vite) from 6.2.3 to 6.2.4. - [Release notes](https://github.com/vitejs/vite/releases) - [Changelog](https://github.com/vitejs/vite/blob/v6.2.4/packages/vite/CHANGELOG.md) - [Commits](https://github.com/vitejs/vite/commits/v6.2.4/packages/vite) --- updated-dependencies: - dependency-name: vite dependency-type: direct:production ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- pnpm-lock.yaml | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 5e0c5d93..17032eee 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -39,7 +39,7 @@ importers: version: 3.1.0 '@vitejs/plugin-vue': specifier: ^5.2.1 - version: 5.2.1(vite@6.2.3(@types/node@22.13.9)(jiti@1.21.7)(yaml@2.7.0))(vue@3.5.13(typescript@5.8.2)) + version: 5.2.1(vite@6.2.4(@types/node@22.13.9)(jiti@1.21.7)(yaml@2.7.0))(vue@3.5.13(typescript@5.8.2)) '@vue/devtools-api': specifier: ^7.7.2 version: 7.7.2 @@ -66,7 +66,7 @@ importers: version: 3.1.0 vite: specifier: ^6.2.1 - version: 6.2.3(@types/node@22.13.9)(jiti@1.21.7)(yaml@2.7.0) + version: 6.2.4(@types/node@22.13.9)(jiti@1.21.7)(yaml@2.7.0) vue: specifier: ^3.5.13 version: 3.5.13(typescript@5.8.2) @@ -2713,8 +2713,8 @@ packages: engines: {node: ^18.0.0 || ^20.0.0 || >=22.0.0} hasBin: true - vite@6.2.3: - resolution: {integrity: sha512-IzwM54g4y9JA/xAeBPNaDXiBF8Jsgl3VBQ2YQ/wOY6fyW3xMdSoltIV3Bo59DErdqdE6RxUfv8W69DvUorE4Eg==} + vite@6.2.4: + resolution: {integrity: sha512-veHMSew8CcRzhL5o8ONjy8gkfmFJAd5Ac16oxBUjlwgX3Gq2Wqr+qNC3TjPIpy7TPV/KporLga5GT9HqdrCizw==} engines: {node: ^18.0.0 || ^20.0.0 || >=22.0.0} hasBin: true peerDependencies: @@ -3505,9 +3505,9 @@ snapshots: '@ungap/structured-clone@1.3.0': {} - '@vitejs/plugin-vue@5.2.1(vite@6.2.3(@types/node@22.13.9)(jiti@1.21.7)(yaml@2.7.0))(vue@3.5.13(typescript@5.8.2))': + '@vitejs/plugin-vue@5.2.1(vite@6.2.4(@types/node@22.13.9)(jiti@1.21.7)(yaml@2.7.0))(vue@3.5.13(typescript@5.8.2))': dependencies: - vite: 6.2.3(@types/node@22.13.9)(jiti@1.21.7)(yaml@2.7.0) + vite: 6.2.4(@types/node@22.13.9)(jiti@1.21.7)(yaml@2.7.0) vue: 3.5.13(typescript@5.8.2) '@vitest/expect@3.0.8': @@ -3517,13 +3517,13 @@ snapshots: chai: 5.2.0 tinyrainbow: 2.0.0 - '@vitest/mocker@3.0.8(vite@6.2.3(@types/node@22.13.9)(jiti@1.21.7)(yaml@2.7.0))': + '@vitest/mocker@3.0.8(vite@6.2.4(@types/node@22.13.9)(jiti@1.21.7)(yaml@2.7.0))': dependencies: '@vitest/spy': 3.0.8 estree-walker: 3.0.3 magic-string: 0.30.17 optionalDependencies: - vite: 6.2.3(@types/node@22.13.9)(jiti@1.21.7)(yaml@2.7.0) + vite: 6.2.4(@types/node@22.13.9)(jiti@1.21.7)(yaml@2.7.0) '@vitest/pretty-format@3.0.8': dependencies: @@ -5261,7 +5261,7 @@ snapshots: debug: 4.4.0 es-module-lexer: 1.6.0 pathe: 2.0.3 - vite: 6.2.3(@types/node@22.13.9)(jiti@1.21.7)(yaml@2.7.0) + vite: 6.2.4(@types/node@22.13.9)(jiti@1.21.7)(yaml@2.7.0) transitivePeerDependencies: - '@types/node' - jiti @@ -5276,7 +5276,7 @@ snapshots: - tsx - yaml - vite@6.2.3(@types/node@22.13.9)(jiti@1.21.7)(yaml@2.7.0): + vite@6.2.4(@types/node@22.13.9)(jiti@1.21.7)(yaml@2.7.0): dependencies: esbuild: 0.25.0 postcss: 8.5.3 @@ -5298,7 +5298,7 @@ snapshots: vitest@3.0.8(@types/debug@4.1.12)(@types/node@22.13.9)(jiti@1.21.7)(yaml@2.7.0): dependencies: '@vitest/expect': 3.0.8 - '@vitest/mocker': 3.0.8(vite@6.2.3(@types/node@22.13.9)(jiti@1.21.7)(yaml@2.7.0)) + '@vitest/mocker': 3.0.8(vite@6.2.4(@types/node@22.13.9)(jiti@1.21.7)(yaml@2.7.0)) '@vitest/pretty-format': 3.0.8 '@vitest/runner': 3.0.8 '@vitest/snapshot': 3.0.8 @@ -5314,7 +5314,7 @@ snapshots: tinyexec: 0.3.2 tinypool: 1.0.2 tinyrainbow: 2.0.0 - vite: 6.2.3(@types/node@22.13.9)(jiti@1.21.7)(yaml@2.7.0) + vite: 6.2.4(@types/node@22.13.9)(jiti@1.21.7)(yaml@2.7.0) vite-node: 3.0.8(@types/node@22.13.9)(jiti@1.21.7)(yaml@2.7.0) why-is-node-running: 2.3.0 optionalDependencies: From ea5cbfca395c06fe3d624056eeebf5654e454192 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 4 Apr 2025 21:40:19 +0530 Subject: [PATCH 15/28] chore(deps): bump vite from 6.2.4 to 6.2.5 (#4676) Bumps [vite](https://github.com/vitejs/vite/tree/HEAD/packages/vite) from 6.2.4 to 6.2.5. - [Release notes](https://github.com/vitejs/vite/releases) - [Changelog](https://github.com/vitejs/vite/blob/v6.2.5/packages/vite/CHANGELOG.md) - [Commits](https://github.com/vitejs/vite/commits/v6.2.5/packages/vite) --- updated-dependencies: - dependency-name: vite dependency-version: 6.2.5 dependency-type: direct:production ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- pnpm-lock.yaml | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 17032eee..e61590e7 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -39,7 +39,7 @@ importers: version: 3.1.0 '@vitejs/plugin-vue': specifier: ^5.2.1 - version: 5.2.1(vite@6.2.4(@types/node@22.13.9)(jiti@1.21.7)(yaml@2.7.0))(vue@3.5.13(typescript@5.8.2)) + version: 5.2.1(vite@6.2.5(@types/node@22.13.9)(jiti@1.21.7)(yaml@2.7.0))(vue@3.5.13(typescript@5.8.2)) '@vue/devtools-api': specifier: ^7.7.2 version: 7.7.2 @@ -66,7 +66,7 @@ importers: version: 3.1.0 vite: specifier: ^6.2.1 - version: 6.2.4(@types/node@22.13.9)(jiti@1.21.7)(yaml@2.7.0) + version: 6.2.5(@types/node@22.13.9)(jiti@1.21.7)(yaml@2.7.0) vue: specifier: ^3.5.13 version: 3.5.13(typescript@5.8.2) @@ -2713,8 +2713,8 @@ packages: engines: {node: ^18.0.0 || ^20.0.0 || >=22.0.0} hasBin: true - vite@6.2.4: - resolution: {integrity: sha512-veHMSew8CcRzhL5o8ONjy8gkfmFJAd5Ac16oxBUjlwgX3Gq2Wqr+qNC3TjPIpy7TPV/KporLga5GT9HqdrCizw==} + vite@6.2.5: + resolution: {integrity: sha512-j023J/hCAa4pRIUH6J9HemwYfjB5llR2Ps0CWeikOtdR8+pAURAk0DoJC5/mm9kd+UgdnIy7d6HE4EAvlYhPhA==} engines: {node: ^18.0.0 || ^20.0.0 || >=22.0.0} hasBin: true peerDependencies: @@ -3505,9 +3505,9 @@ snapshots: '@ungap/structured-clone@1.3.0': {} - '@vitejs/plugin-vue@5.2.1(vite@6.2.4(@types/node@22.13.9)(jiti@1.21.7)(yaml@2.7.0))(vue@3.5.13(typescript@5.8.2))': + '@vitejs/plugin-vue@5.2.1(vite@6.2.5(@types/node@22.13.9)(jiti@1.21.7)(yaml@2.7.0))(vue@3.5.13(typescript@5.8.2))': dependencies: - vite: 6.2.4(@types/node@22.13.9)(jiti@1.21.7)(yaml@2.7.0) + vite: 6.2.5(@types/node@22.13.9)(jiti@1.21.7)(yaml@2.7.0) vue: 3.5.13(typescript@5.8.2) '@vitest/expect@3.0.8': @@ -3517,13 +3517,13 @@ snapshots: chai: 5.2.0 tinyrainbow: 2.0.0 - '@vitest/mocker@3.0.8(vite@6.2.4(@types/node@22.13.9)(jiti@1.21.7)(yaml@2.7.0))': + '@vitest/mocker@3.0.8(vite@6.2.5(@types/node@22.13.9)(jiti@1.21.7)(yaml@2.7.0))': dependencies: '@vitest/spy': 3.0.8 estree-walker: 3.0.3 magic-string: 0.30.17 optionalDependencies: - vite: 6.2.4(@types/node@22.13.9)(jiti@1.21.7)(yaml@2.7.0) + vite: 6.2.5(@types/node@22.13.9)(jiti@1.21.7)(yaml@2.7.0) '@vitest/pretty-format@3.0.8': dependencies: @@ -5261,7 +5261,7 @@ snapshots: debug: 4.4.0 es-module-lexer: 1.6.0 pathe: 2.0.3 - vite: 6.2.4(@types/node@22.13.9)(jiti@1.21.7)(yaml@2.7.0) + vite: 6.2.5(@types/node@22.13.9)(jiti@1.21.7)(yaml@2.7.0) transitivePeerDependencies: - '@types/node' - jiti @@ -5276,7 +5276,7 @@ snapshots: - tsx - yaml - vite@6.2.4(@types/node@22.13.9)(jiti@1.21.7)(yaml@2.7.0): + vite@6.2.5(@types/node@22.13.9)(jiti@1.21.7)(yaml@2.7.0): dependencies: esbuild: 0.25.0 postcss: 8.5.3 @@ -5298,7 +5298,7 @@ snapshots: vitest@3.0.8(@types/debug@4.1.12)(@types/node@22.13.9)(jiti@1.21.7)(yaml@2.7.0): dependencies: '@vitest/expect': 3.0.8 - '@vitest/mocker': 3.0.8(vite@6.2.4(@types/node@22.13.9)(jiti@1.21.7)(yaml@2.7.0)) + '@vitest/mocker': 3.0.8(vite@6.2.5(@types/node@22.13.9)(jiti@1.21.7)(yaml@2.7.0)) '@vitest/pretty-format': 3.0.8 '@vitest/runner': 3.0.8 '@vitest/snapshot': 3.0.8 @@ -5314,7 +5314,7 @@ snapshots: tinyexec: 0.3.2 tinypool: 1.0.2 tinyrainbow: 2.0.0 - vite: 6.2.4(@types/node@22.13.9)(jiti@1.21.7)(yaml@2.7.0) + vite: 6.2.5(@types/node@22.13.9)(jiti@1.21.7)(yaml@2.7.0) vite-node: 3.0.8(@types/node@22.13.9)(jiti@1.21.7)(yaml@2.7.0) why-is-node-running: 2.3.0 optionalDependencies: From 544cd8125985b9e3af7fee68ea9592d159799e01 Mon Sep 17 00:00:00 2001 From: Yuxuan Zhang Date: Sat, 5 Apr 2025 09:59:32 -0400 Subject: [PATCH 16/28] feat(theme)!: add `isHome` frontmatter option (#4673) BREAKING CHANGE: `useLocalNav` and `useSidebar` are removed in favor of `useLayout`. To migrate, just do find and replace. Sidebar controls are no longer exported, but I didn't find any usage on GitHub. If there is demand, we can export respective composables later. `DefaultTheme.DocSidebar` and `DefaultTheme.DocLocalNav` types are also removed. --------- Co-authored-by: Divyansh Singh <40380293+brc-dd@users.noreply.github.com> Co-authored-by: userquin --- .../theme/components/ApiPreference.vue | 2 +- docs/en/reference/default-theme-config.md | 35 +++++ docs/en/reference/default-theme-sidebar.md | 33 ----- docs/en/reference/default-theme-team-page.md | 8 +- docs/en/reference/frontmatter-config.md | 13 ++ docs/es/reference/default-theme-sidebar.md | 33 ----- docs/es/reference/default-theme-team-page.md | 8 +- docs/fa/reference/default-theme-sidebar.md | 35 ----- docs/fa/reference/default-theme-team-page.md | 8 +- docs/ko/reference/default-theme-sidebar.md | 33 ----- docs/ko/reference/default-theme-team-page.md | 8 +- docs/pt/reference/default-theme-sidebar.md | 33 ----- docs/pt/reference/default-theme-team-page.md | 8 +- docs/ru/reference/default-theme-sidebar.md | 33 ----- docs/ru/reference/default-theme-team-page.md | 6 +- docs/zh/reference/default-theme-sidebar.md | 33 ----- docs/zh/reference/default-theme-team-page.md | 8 +- src/client/app/utils.ts | 11 +- src/client/theme-default/Layout.vue | 19 +-- .../theme-default/components/VPContent.vue | 9 +- src/client/theme-default/components/VPDoc.vue | 4 +- .../components/VPDocAsideOutline.vue | 25 ++-- .../components/VPDocAsideSponsors.vue | 2 +- .../components/VPDocOutlineItem.vue | 8 +- .../theme-default/components/VPFeature.vue | 4 +- .../theme-default/components/VPFlyout.vue | 2 +- .../theme-default/components/VPFooter.vue | 4 +- .../theme-default/components/VPHero.vue | 2 +- .../components/VPHomeSponsors.vue | 2 +- .../theme-default/components/VPLocalNav.vue | 30 +---- .../components/VPLocalNavOutlineDropdown.vue | 9 +- .../theme-default/components/VPMenu.vue | 2 +- .../theme-default/components/VPMenuGroup.vue | 2 +- .../theme-default/components/VPNavBar.vue | 8 +- .../theme-default/components/VPNavBarMenu.vue | 4 +- .../components/VPNavBarSearch.vue | 2 +- .../components/VPNavBarTitle.vue | 8 +- .../components/VPNavScreenMenu.vue | 2 +- .../components/VPNavScreenMenuGroup.vue | 2 +- .../VPNavScreenMenuGroupSection.vue | 6 +- .../theme-default/components/VPSidebar.vue | 6 +- .../components/VPSidebarGroup.vue | 2 +- .../components/VPSidebarItem.vue | 4 +- .../components/VPSocialLinks.vue | 6 +- .../components/VPTeamMembers.vue | 2 +- src/client/theme-default/composables/aside.ts | 4 +- .../theme-default/composables/layout.ts | 85 ++++++++++++ .../theme-default/composables/local-nav.ts | 24 ---- .../theme-default/composables/outline.ts | 27 ++-- .../theme-default/composables/sidebar.ts | 123 ++++-------------- src/client/theme-default/without-fonts.ts | 3 +- theme.d.ts | 27 +++- types/default-theme.d.ts | 43 +----- 53 files changed, 306 insertions(+), 554 deletions(-) create mode 100644 src/client/theme-default/composables/layout.ts delete mode 100644 src/client/theme-default/composables/local-nav.ts diff --git a/__tests__/e2e/.vitepress/theme/components/ApiPreference.vue b/__tests__/e2e/.vitepress/theme/components/ApiPreference.vue index 12207764..c286640b 100644 --- a/__tests__/e2e/.vitepress/theme/components/ApiPreference.vue +++ b/__tests__/e2e/.vitepress/theme/components/ApiPreference.vue @@ -30,7 +30,7 @@ function removeSpaces(str: string) { diff --git a/docs/en/reference/default-theme-config.md b/docs/en/reference/default-theme-config.md index c8afc554..8f71d4af 100644 --- a/docs/en/reference/default-theme-config.md +++ b/docs/en/reference/default-theme-config.md @@ -457,3 +457,38 @@ Can be used to customize the label of the skip to content link. This link is sho - Default: `false` Whether to show an external link icon next to external links in markdown. + +## `useLayout` + +Returns layout-related data. The returned object has the following type: + +```ts +interface { + isHome: ComputedRef + + sidebar: ComputedRef + sidebarGroups: ComputedRef + hasSidebar: ComputedRef + isSidebarEnabled: ComputedRef + + hasAside: ComputedRef + leftAside: ComputedRef + + headers: ShallowRef + hasLocalNav: ComputedRef +} +``` + +**Example:** + +```vue + + + +``` diff --git a/docs/en/reference/default-theme-sidebar.md b/docs/en/reference/default-theme-sidebar.md index 9a64a074..67893cf6 100644 --- a/docs/en/reference/default-theme-sidebar.md +++ b/docs/en/reference/default-theme-sidebar.md @@ -180,36 +180,3 @@ export default { } } ``` - -## `useSidebar` - -Returns sidebar-related data. The returned object has the following type: - -```ts -export interface DocSidebar { - isOpen: Ref - sidebar: ComputedRef - sidebarGroups: ComputedRef - hasSidebar: ComputedRef - hasAside: ComputedRef - leftAside: ComputedRef - isSidebarEnabled: ComputedRef - open: () => void - close: () => void - toggle: () => void -} -``` - -**Example:** - -```vue - - - -``` diff --git a/docs/en/reference/default-theme-team-page.md b/docs/en/reference/default-theme-team-page.md index 29b071ff..6c37c6a7 100644 --- a/docs/en/reference/default-theme-team-page.md +++ b/docs/en/reference/default-theme-team-page.md @@ -53,12 +53,12 @@ const members = [ Say hello to our awesome team. - + ``` The above will display a team member in card looking element. It should display something similar to below. - + `` component comes in 2 different sizes, `small` and `medium`. While it boils down to your preference, usually `small` size should fit better when used in doc page. Also, you may add more properties to each member such as adding "description" or "sponsor" button. Learn more about it in [``](#vpteammembers). @@ -107,9 +107,7 @@ const members = [ team, some of whom have chosen to be featured below. - + ``` diff --git a/docs/en/reference/frontmatter-config.md b/docs/en/reference/frontmatter-config.md index 955d4ad7..4d6f86c0 100644 --- a/docs/en/reference/frontmatter-config.md +++ b/docs/en/reference/frontmatter-config.md @@ -225,3 +225,16 @@ Then you can customize styles of this specific page in `.vitepress/theme/custom. /* page-specific styles */ } ``` + +### isHome + +- Type: `boolean` + +The default theme relies on checks like `frontmatter.layout === 'home'` to determine if the current page is the home page.\ +This is useful when you want to force show the home page elements in a custom layout. + +```yaml +--- +isHome: true +--- +``` diff --git a/docs/es/reference/default-theme-sidebar.md b/docs/es/reference/default-theme-sidebar.md index cf2af04b..41cd5cac 100644 --- a/docs/es/reference/default-theme-sidebar.md +++ b/docs/es/reference/default-theme-sidebar.md @@ -181,36 +181,3 @@ export default { } } ``` - -## `useSidebar` - -Devuelve datos relacionados con la barra lateral. El objeto devuelto tiene el siguiente tipo: - -```ts -export interface DocSidebar { - isOpen: Ref - sidebar: ComputedRef - sidebarGroups: ComputedRef - hasSidebar: ComputedRef - hasAside: ComputedRef - leftAside: ComputedRef - isSidebarEnabled: ComputedRef - open: () => void - close: () => void - toggle: () => void -} -``` - -**Exemplo:** - -```vue - - - -``` diff --git a/docs/es/reference/default-theme-team-page.md b/docs/es/reference/default-theme-team-page.md index 1f6492a8..996e8f18 100644 --- a/docs/es/reference/default-theme-team-page.md +++ b/docs/es/reference/default-theme-team-page.md @@ -53,12 +53,12 @@ const members = [ Saluda a nuestro increible equipo. - + ``` El código anterior mostrará a un miembro del equipo en un elemento similar a una tarjeta. Debería mostrar algo similar a lo siguiente. - + El componente `` viene en dos tamaños diferentes, pequeño `small` y médio `medium`. Si bien es una cuestión de preferencia, generalmente el tamaño `small` debería encajar mejor cuando se use en la página del documento. Además, puede agregar más propiedades a cada miembro, como agregar el botón "descripción" o "patrocinador". Obtenga más información sobre en [``](#vpteammembers). @@ -107,9 +107,7 @@ const members = [ Algunos de los miembros han elegido aparecer a continuación. - + ``` diff --git a/docs/fa/reference/default-theme-sidebar.md b/docs/fa/reference/default-theme-sidebar.md index cba65dff..96433c2d 100644 --- a/docs/fa/reference/default-theme-sidebar.md +++ b/docs/fa/reference/default-theme-sidebar.md @@ -178,38 +178,3 @@ export default { } } ``` - -## `useSidebar` {#usesidebar} - -داده‌های مربوط به نوار کناری را برمی‌گرداند. شیء برگردانده شده دارای نوع‌های زیر است: - -```ts -export interface DocSidebar { - isOpen: Ref - sidebar: ComputedRef - sidebarGroups: ComputedRef - hasSidebar: ComputedRef - hasAside: ComputedRef - leftAside: ComputedRef - isSidebarEnabled: ComputedRef - open: () => void - close: () => void - toggle: () => void -} -``` - -**مثال:** - -```vue - - - -``` diff --git a/docs/fa/reference/default-theme-team-page.md b/docs/fa/reference/default-theme-team-page.md index ccd9738d..57fc2814 100644 --- a/docs/fa/reference/default-theme-team-page.md +++ b/docs/fa/reference/default-theme-team-page.md @@ -53,12 +53,12 @@ const members = [ با سلام به تیم فوق‌العاده‌ی ما خوش آمدید. - + ``` بالا به صورت عنصری با شکل کارتی اعضای تیم را نمایش می‌دهد. باید به شکل زیر نمایش داده شود. - + کامپوننت `` دارای دو اندازه مختلف، `small` و `medium` است. معمولاً اندازه `small` برای استفاده در صفحات مستندات مناسب‌تر است. همچنین می‌توانید ویژگی‌های بیشتری برای هر عضو اضافه کنید مانند "توضیحات" یا "دکمه حامی". جهت کسب اطلاعات بیشتر به [``](#vpteammembers) مراجعه کنید. @@ -106,9 +106,7 @@ const members = [ توسعه ویت‌پرس توسط تیمی بین‌المللی راهنمایی می‌شود، برخی از اعضا که انتخاب کرده‌اند تا در زیر نمایش داده شوند. - + ``` diff --git a/docs/ko/reference/default-theme-sidebar.md b/docs/ko/reference/default-theme-sidebar.md index 21e19ccc..8e4709cd 100644 --- a/docs/ko/reference/default-theme-sidebar.md +++ b/docs/ko/reference/default-theme-sidebar.md @@ -180,36 +180,3 @@ export default { } } ``` - -## `useSidebar` - -사이드바 관련 데이터를 반환합니다. 반환된 객체는 다음과 같은 타입을 가집니다: - -```ts -export interface DocSidebar { - isOpen: Ref - sidebar: ComputedRef - sidebarGroups: ComputedRef - hasSidebar: ComputedRef - hasAside: ComputedRef - leftAside: ComputedRef - isSidebarEnabled: ComputedRef - open: () => void - close: () => void - toggle: () => void -} -``` - -**예제:** - -```vue - - - -``` diff --git a/docs/ko/reference/default-theme-team-page.md b/docs/ko/reference/default-theme-team-page.md index 2123f349..b4fddb0f 100644 --- a/docs/ko/reference/default-theme-team-page.md +++ b/docs/ko/reference/default-theme-team-page.md @@ -53,12 +53,12 @@ const members = [ Say hello to our awesome team. - + ``` 위 코드는 카드 형태의 엘리먼트로 팀 구성원을 표시합니다. 아래와 비슷한 형태로 표시됩니다. - + `` 컴포넌트는 `small`과 `medium` 두 가지 크기로 제공됩니다. 개인의 선호도에 따라 선택할 수 있지만, 일반적으로 `small` 사이즈가 문서 페이지에 더 적합합니다. 또한, 각 구성원에 "설명"이나 "후원" 버튼과 같은 프로퍼티를 추가할 수도 있습니다. 자세한 내용은 [``](#vpteammembers)에서 확인할 수 있습니다. @@ -107,9 +107,7 @@ const members = [ team, some of whom have chosen to be featured below. - + ``` diff --git a/docs/pt/reference/default-theme-sidebar.md b/docs/pt/reference/default-theme-sidebar.md index 62c3b3b1..0d8baf8d 100644 --- a/docs/pt/reference/default-theme-sidebar.md +++ b/docs/pt/reference/default-theme-sidebar.md @@ -180,36 +180,3 @@ export default { } } ``` - -## `useSidebar` - -Retorna dados relacionados à barra lateral. O objeto retornado tem o seguinte tipo: - -```ts -export interface DocSidebar { - isOpen: Ref - sidebar: ComputedRef - sidebarGroups: ComputedRef - hasSidebar: ComputedRef - hasAside: ComputedRef - leftAside: ComputedRef - isSidebarEnabled: ComputedRef - open: () => void - close: () => void - toggle: () => void -} -``` - -**Exemplo:** - -```vue - - - -``` diff --git a/docs/pt/reference/default-theme-team-page.md b/docs/pt/reference/default-theme-team-page.md index 1daa47a5..32a9db0d 100644 --- a/docs/pt/reference/default-theme-team-page.md +++ b/docs/pt/reference/default-theme-team-page.md @@ -53,12 +53,12 @@ const members = [ Diga olá à nossa equipe incrível. - + ``` O código acima exibirá um membro da equipe em um elemento tipo cartão. Ele deve exibir algo semelhante ao abaixo. - + O componente `` vem em 2 tamanhos diferentes, pequeno `small` e médio `medium`. Enquanto é uma questão de preferência, geralmente o tamanho `small` deve encaixar melhor quando usado na página de documento. Além disso, você pode adicionar mais propriedades a cada membro, como adicionar o botão "descrição" ou "patrocinador". Saiba mais sobre em [``](#vpteammembers). @@ -107,9 +107,7 @@ const members = [ alguns dos membros escolheram ser apresentados abaixo. - + ``` diff --git a/docs/ru/reference/default-theme-sidebar.md b/docs/ru/reference/default-theme-sidebar.md index 92fd89c1..bdc6e338 100644 --- a/docs/ru/reference/default-theme-sidebar.md +++ b/docs/ru/reference/default-theme-sidebar.md @@ -178,36 +178,3 @@ export default { } } ``` - -## `useSidebar` {#usesidebar} - -Возвращает данные, связанные с сайдбаром. Возвращаемый объект имеет следующий тип: - -```ts -export interface DocSidebar { - isOpen: Ref - sidebar: ComputedRef - sidebarGroups: ComputedRef - hasSidebar: ComputedRef - hasAside: ComputedRef - leftAside: ComputedRef - isSidebarEnabled: ComputedRef - open: () => void - close: () => void - toggle: () => void -} -``` - -**Пример:** - -```vue - - - -``` diff --git a/docs/ru/reference/default-theme-team-page.md b/docs/ru/reference/default-theme-team-page.md index 0eebaa24..615692bb 100644 --- a/docs/ru/reference/default-theme-team-page.md +++ b/docs/ru/reference/default-theme-team-page.md @@ -51,12 +51,12 @@ const members = [ # Поприветствуйте нашу замечательную команду - + ``` Вышеуказанное отобразит члена команды в виде карточки. Должно отобразиться что-то похожее на то, что показано ниже. - + Компонент `` поставляется в двух различных размерах, `small` и `medium`. Хотя это зависит от ваших предпочтений, обычно размер `small` лучше подходит для использования на странице с макетом `doc`. Кроме того, вы можете добавить дополнительные свойства для карточки члена команды, например, добавить «описание» или кнопку «спонсировать». Подробнее об этом в секции [``](#vpteammembers). @@ -104,7 +104,7 @@ layout: page которой представлены ниже. - + ``` diff --git a/docs/zh/reference/default-theme-sidebar.md b/docs/zh/reference/default-theme-sidebar.md index ba9a9adc..e353ef78 100644 --- a/docs/zh/reference/default-theme-sidebar.md +++ b/docs/zh/reference/default-theme-sidebar.md @@ -178,36 +178,3 @@ export default { } } ``` - -## `useSidebar` - -返回侧边栏相关数据。返回的对象具有以下类型: - -```ts -export interface DocSidebar { - isOpen: Ref - sidebar: ComputedRef - sidebarGroups: ComputedRef - hasSidebar: ComputedRef - hasAside: ComputedRef - leftAside: ComputedRef - isSidebarEnabled: ComputedRef - open: () => void - close: () => void - toggle: () => void -} -``` - -**示例:** - -```vue - - - -``` diff --git a/docs/zh/reference/default-theme-team-page.md b/docs/zh/reference/default-theme-team-page.md index 0341f0f2..9f155cf2 100644 --- a/docs/zh/reference/default-theme-team-page.md +++ b/docs/zh/reference/default-theme-team-page.md @@ -53,12 +53,12 @@ const members = [ Say hello to our awesome team. - + ``` 以上将在卡片外观元素中显示团队成员。它应该显示类似于下面的内容。 - + `` 组件有 2 种不同的尺寸,`small` 和 `medium`。虽然它取决于你的偏好,但通常尺寸在文档页面中使用时 `small` 应该更适合。此外,你可以为每个成员添加更多属性,例如添加“描述”或“赞助”按钮。在 [``](#vpteammembers) 中了解更多信息。 @@ -107,9 +107,7 @@ const members = [ team, some of whom have chosen to be featured below. - + ``` diff --git a/src/client/app/utils.ts b/src/client/app/utils.ts index 53ef6e51..b734179c 100644 --- a/src/client/app/utils.ts +++ b/src/client/app/utils.ts @@ -1,10 +1,5 @@ -import { - h, - onMounted, - onUnmounted, - shallowRef, - type AsyncComponentLoader -} from 'vue' +import { tryOnUnmounted } from '@vueuse/core' +import { h, onMounted, shallowRef, type AsyncComponentLoader } from 'vue' import { EXTERNAL_URL_RE, inBrowser, @@ -81,7 +76,7 @@ export let contentUpdatedCallbacks: (() => any)[] = [] */ export function onContentUpdated(fn: () => any) { contentUpdatedCallbacks.push(fn) - onUnmounted(() => { + tryOnUnmounted(() => { contentUpdatedCallbacks = contentUpdatedCallbacks.filter((f) => f !== fn) }) } diff --git a/src/client/theme-default/Layout.vue b/src/client/theme-default/Layout.vue index 69284148..30ebe491 100644 --- a/src/client/theme-default/Layout.vue +++ b/src/client/theme-default/Layout.vue @@ -1,6 +1,5 @@