Merge branch 'main' into custom-nav-components

pull/4630/head
Lukas Leisten 6 months ago committed by GitHub
commit 2ddd194f11
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -39,7 +39,7 @@ importers:
version: 3.1.0 version: 3.1.0
'@vitejs/plugin-vue': '@vitejs/plugin-vue':
specifier: ^5.2.1 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.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': '@vue/devtools-api':
specifier: ^7.7.2 specifier: ^7.7.2
version: 7.7.2 version: 7.7.2
@ -66,7 +66,7 @@ importers:
version: 3.1.0 version: 3.1.0
vite: vite:
specifier: ^6.2.1 specifier: ^6.2.1
version: 6.2.1(@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: vue:
specifier: ^3.5.13 specifier: ^3.5.13
version: 3.5.13(typescript@5.8.2) version: 3.5.13(typescript@5.8.2)
@ -2093,8 +2093,8 @@ packages:
muggle-string@0.4.1: muggle-string@0.4.1:
resolution: {integrity: sha512-VNTrAak/KhO2i8dqqnqnAHOa3cYBwXEZe9h+D5h/1ZqFSTEFHdM65lR7RoIqq3tBBYavsOXV84NoHXZ0AkPyqQ==} resolution: {integrity: sha512-VNTrAak/KhO2i8dqqnqnAHOa3cYBwXEZe9h+D5h/1ZqFSTEFHdM65lR7RoIqq3tBBYavsOXV84NoHXZ0AkPyqQ==}
nanoid@3.3.9: nanoid@3.3.11:
resolution: {integrity: sha512-SppoicMGpZvbF1l3z4x7No3OlIjP7QJvC9XR7AhZr1kL133KHnKPztkKDc+Ir4aJ/1VhTySrtKhrsycmrMQfvg==} resolution: {integrity: sha512-N8SpfPUnUp1bK+PMYW8qSWdl9U+wwNWI4QKxOYDy9JAro3WMX7p2OeVRF9v+347pnakNevPmiHhNmZ2HbFA76w==}
engines: {node: ^10 || ^12 || ^13.7 || ^14 || >=15.0.1} engines: {node: ^10 || ^12 || ^13.7 || ^14 || >=15.0.1}
hasBin: true hasBin: true
@ -2713,8 +2713,8 @@ packages:
engines: {node: ^18.0.0 || ^20.0.0 || >=22.0.0} engines: {node: ^18.0.0 || ^20.0.0 || >=22.0.0}
hasBin: true hasBin: true
vite@6.2.1: vite@6.2.4:
resolution: {integrity: sha512-n2GnqDb6XPhlt9B8olZPrgMD/es/Nd1RdChF6CBD/fHW6pUyUTt2sQW2fPRX5GiD9XEa6+8A6A4f2vT6pSsE7Q==} resolution: {integrity: sha512-veHMSew8CcRzhL5o8ONjy8gkfmFJAd5Ac16oxBUjlwgX3Gq2Wqr+qNC3TjPIpy7TPV/KporLga5GT9HqdrCizw==}
engines: {node: ^18.0.0 || ^20.0.0 || >=22.0.0} engines: {node: ^18.0.0 || ^20.0.0 || >=22.0.0}
hasBin: true hasBin: true
peerDependencies: peerDependencies:
@ -3505,9 +3505,9 @@ snapshots:
'@ungap/structured-clone@1.3.0': {} '@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.4(@types/node@22.13.9)(jiti@1.21.7)(yaml@2.7.0))(vue@3.5.13(typescript@5.8.2))':
dependencies: dependencies:
vite: 6.2.1(@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) vue: 3.5.13(typescript@5.8.2)
'@vitest/expect@3.0.8': '@vitest/expect@3.0.8':
@ -3517,13 +3517,13 @@ snapshots:
chai: 5.2.0 chai: 5.2.0
tinyrainbow: 2.0.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.4(@types/node@22.13.9)(jiti@1.21.7)(yaml@2.7.0))':
dependencies: dependencies:
'@vitest/spy': 3.0.8 '@vitest/spy': 3.0.8
estree-walker: 3.0.3 estree-walker: 3.0.3
magic-string: 0.30.17 magic-string: 0.30.17
optionalDependencies: optionalDependencies:
vite: 6.2.1(@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': '@vitest/pretty-format@3.0.8':
dependencies: dependencies:
@ -4654,7 +4654,7 @@ snapshots:
muggle-string@0.4.1: {} muggle-string@0.4.1: {}
nanoid@3.3.9: {} nanoid@3.3.11: {}
nanoid@5.1.3: {} nanoid@5.1.3: {}
@ -4815,7 +4815,7 @@ snapshots:
postcss@8.5.3: postcss@8.5.3:
dependencies: dependencies:
nanoid: 3.3.9 nanoid: 3.3.11
picocolors: 1.1.1 picocolors: 1.1.1
source-map-js: 1.2.1 source-map-js: 1.2.1
@ -5261,7 +5261,7 @@ snapshots:
debug: 4.4.0 debug: 4.4.0
es-module-lexer: 1.6.0 es-module-lexer: 1.6.0
pathe: 2.0.3 pathe: 2.0.3
vite: 6.2.1(@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: transitivePeerDependencies:
- '@types/node' - '@types/node'
- jiti - jiti
@ -5276,7 +5276,7 @@ snapshots:
- tsx - tsx
- yaml - yaml
vite@6.2.1(@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: dependencies:
esbuild: 0.25.0 esbuild: 0.25.0
postcss: 8.5.3 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): vitest@3.0.8(@types/debug@4.1.12)(@types/node@22.13.9)(jiti@1.21.7)(yaml@2.7.0):
dependencies: dependencies:
'@vitest/expect': 3.0.8 '@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.4(@types/node@22.13.9)(jiti@1.21.7)(yaml@2.7.0))
'@vitest/pretty-format': 3.0.8 '@vitest/pretty-format': 3.0.8
'@vitest/runner': 3.0.8 '@vitest/runner': 3.0.8
'@vitest/snapshot': 3.0.8 '@vitest/snapshot': 3.0.8
@ -5314,7 +5314,7 @@ snapshots:
tinyexec: 0.3.2 tinyexec: 0.3.2
tinypool: 1.0.2 tinypool: 1.0.2
tinyrainbow: 2.0.0 tinyrainbow: 2.0.0
vite: 6.2.1(@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) 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 why-is-node-running: 2.3.0
optionalDependencies: optionalDependencies:

@ -22,7 +22,7 @@ const { currentLang } = useLangs()
<div class="action"> <div class="action">
<a <a
class="link" class="link"
:href="withBase(currentLang.link)" :href="withBase(theme.notFound?.link ?? currentLang.link)"
:aria-label="theme.notFound?.linkLabel ?? 'go to home'" :aria-label="theme.notFound?.linkLabel ?? 'go to home'"
> >
{{ theme.notFound?.linkText ?? 'Take me home' }} {{ theme.notFound?.linkText ?? 'Take me home' }}

@ -322,6 +322,9 @@ const heroImageSlotExists = inject('hero-image-slot-exists') as Ref<boolean>
left: 50%; left: 50%;
max-width: 192px; max-width: 192px;
max-height: 192px; max-height: 192px;
width: 100%;
height: 100%;
object-fit: contain;
/*rtl:ignore*/ /*rtl:ignore*/
transform: translate(-50%, -50%); transform: translate(-50%, -50%);
} }

@ -1,7 +1,7 @@
.dark .vp-code span { .dark .shiki span {
color: var(--shiki-dark, inherit); color: var(--shiki-dark, inherit);
} }
html:not(.dark) .vp-code span { html:not(.dark) .shiki span {
color: var(--shiki-light, inherit); color: var(--shiki-light, inherit);
} }

@ -215,7 +215,6 @@ export async function createMarkdownRenderer(
const theme = options.theme ?? { light: 'github-light', dark: 'github-dark' } const theme = options.theme ?? { light: 'github-light', dark: 'github-dark' }
const codeCopyButtonTitle = options.codeCopyButtonTitle || 'Copy Code' const codeCopyButtonTitle = options.codeCopyButtonTitle || 'Copy Code'
const hasSingleTheme = typeof theme === 'string' || 'name' in theme
let [highlight, dispose] = options.highlight let [highlight, dispose] = options.highlight
? [options.highlight, () => {}] ? [options.highlight, () => {}]
@ -237,9 +236,9 @@ export async function createMarkdownRenderer(
// custom plugins // custom plugins
md.use(componentPlugin, { ...options.component }) md.use(componentPlugin, { ...options.component })
.use(highlightLinePlugin) .use(highlightLinePlugin)
.use(preWrapperPlugin, { codeCopyButtonTitle, hasSingleTheme }) .use(preWrapperPlugin, { codeCopyButtonTitle })
.use(snippetPlugin, srcDir) .use(snippetPlugin, srcDir)
.use(containerPlugin, { hasSingleTheme }, options.container) .use(containerPlugin, options.container)
.use(imagePlugin, options.image) .use(imagePlugin, options.image)
.use( .use(
linkPlugin, linkPlugin,

@ -3,40 +3,17 @@ import container from 'markdown-it-container'
import type { RenderRule } from 'markdown-it/lib/renderer.mjs' import type { RenderRule } from 'markdown-it/lib/renderer.mjs'
import type Token from 'markdown-it/lib/token.mjs' import type Token from 'markdown-it/lib/token.mjs'
import type { MarkdownEnv } from '../../shared' import type { MarkdownEnv } from '../../shared'
import { import { extractTitle } from './preWrapper'
extractTitle,
getAdaptiveThemeMarker,
type Options
} from './preWrapper'
export const containerPlugin = ( export const containerPlugin = (
md: MarkdownItAsync, md: MarkdownItAsync,
options: Options, options?: ContainerOptions
containerOptions?: ContainerOptions
) => { ) => {
md.use(...createContainer('tip', containerOptions?.tipLabel || 'TIP', md)) md.use(...createContainer('tip', options?.tipLabel || 'TIP', md))
.use(...createContainer('info', containerOptions?.infoLabel || 'INFO', md)) .use(...createContainer('info', options?.infoLabel || 'INFO', md))
.use( .use(...createContainer('warning', options?.warningLabel || 'WARNING', md))
...createContainer( .use(...createContainer('danger', options?.dangerLabel || 'DANGER', md))
'warning', .use(...createContainer('details', options?.detailsLabel || 'Details', md))
containerOptions?.warningLabel || 'WARNING',
md
)
)
.use(
...createContainer(
'danger',
containerOptions?.dangerLabel || 'DANGER',
md
)
)
.use(
...createContainer(
'details',
containerOptions?.detailsLabel || 'Details',
md
)
)
// explicitly escape Vue syntax // explicitly escape Vue syntax
.use(container, 'v-pre', { .use(container, 'v-pre', {
render: (tokens: Token[], idx: number) => render: (tokens: Token[], idx: number) =>
@ -46,7 +23,7 @@ export const containerPlugin = (
render: (tokens: Token[], idx: number) => render: (tokens: Token[], idx: number) =>
tokens[idx].nesting === 1 ? `<div class="vp-raw">\n` : `</div>\n` tokens[idx].nesting === 1 ? `<div class="vp-raw">\n` : `</div>\n`
}) })
.use(...createCodeGroup(options, md)) .use(...createCodeGroup(md))
} }
type ContainerArgs = [typeof container, string, { render: RenderRule }] type ContainerArgs = [typeof container, string, { render: RenderRule }]
@ -69,16 +46,18 @@ function createContainer(
const title = md.renderInline(info || defaultTitle, { const title = md.renderInline(info || defaultTitle, {
references: env.references references: env.references
}) })
const titleClass =
'custom-block-title' + (info ? '' : ' custom-block-title-default')
if (klass === 'details') if (klass === 'details')
return `<details ${attrs}><summary>${title}</summary>\n` return `<details ${attrs}><summary>${title}</summary>\n`
return `<div ${attrs}><p class="custom-block-title">${title}</p>\n` return `<div ${attrs}><p class="${titleClass}">${title}</p>\n`
} else return klass === 'details' ? `</details>\n` : `</div>\n` } else return klass === 'details' ? `</details>\n` : `</div>\n`
} }
} }
] ]
} }
function createCodeGroup(options: Options, md: MarkdownItAsync): ContainerArgs { function createCodeGroup(md: MarkdownItAsync): ContainerArgs {
return [ return [
container, container,
'code-group', 'code-group',
@ -116,7 +95,7 @@ function createCodeGroup(options: Options, md: MarkdownItAsync): ContainerArgs {
} }
} }
return `<div class="vp-code-group${getAdaptiveThemeMarker(options)}"><div class="tabs">${tabs}</div><div class="blocks">\n` return `<div class="vp-code-group"><div class="tabs">${tabs}</div><div class="blocks">\n`
} }
return `</div></div>\n` return `</div></div>\n`
} }

@ -80,19 +80,7 @@ export async function highlight(
classActivePre: 'has-focused-lines' classActivePre: 'has-focused-lines'
}), }),
transformerNotationHighlight(), transformerNotationHighlight(),
transformerNotationErrorLevel(), transformerNotationErrorLevel()
{
name: 'vitepress:add-class',
pre(node) {
this.addClassToHast(node, 'vp-code')
}
},
{
name: 'vitepress:clean-up',
pre(node) {
delete node.properties.style
}
}
] ]
const vueRE = /-vue(?=:|$)/ const vueRE = /-vue(?=:|$)/

@ -2,7 +2,6 @@ import type { MarkdownItAsync } from 'markdown-it-async'
export interface Options { export interface Options {
codeCopyButtonTitle: string codeCopyButtonTitle: string
hasSingleTheme: boolean
} }
export function preWrapperPlugin(md: MarkdownItAsync, options: Options) { export function preWrapperPlugin(md: MarkdownItAsync, options: Options) {
@ -20,7 +19,7 @@ export function preWrapperPlugin(md: MarkdownItAsync, options: Options) {
const lang = extractLang(token.info) const lang = extractLang(token.info)
return ( return (
`<div class="language-${lang}${getAdaptiveThemeMarker(options)}${active}">` + `<div class="language-${lang}${active}">` +
`<button title="${options.codeCopyButtonTitle}" class="copy"></button>` + `<button title="${options.codeCopyButtonTitle}" class="copy"></button>` +
`<span class="lang">${lang}</span>` + `<span class="lang">${lang}</span>` +
fence(...args) + 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) { export function extractTitle(info: string, html = false) {
if (html) { if (html) {
return ( return (

@ -366,15 +366,12 @@ export async function createVitePressPlugin(
pageToHashMap![chunk.name.toLowerCase()] = hash pageToHashMap![chunk.name.toLowerCase()] = hash
// inject another chunk with the content stripped // inject another chunk with the content stripped
bundle[name + '-lean'] = { this.emitFile({
...chunk, type: 'asset',
name: name + '-lean',
fileName: chunk.fileName.replace(/\.js$/, '.lean.js'), fileName: chunk.fileName.replace(/\.js$/, '.lean.js'),
preliminaryFileName: chunk.preliminaryFileName.replace( source: chunk.code.replace(staticStripRE, `""`)
/\.js$/, })
'.lean.js'
),
code: chunk.code.replace(staticStripRE, `""`)
}
// remove static markers from original code // remove static markers from original code
chunk.code = chunk.code.replace(staticRestoreRE, '') chunk.code = chunk.code.replace(staticRestoreRE, '')

@ -485,6 +485,13 @@ export namespace DefaultTheme {
*/ */
quote?: string quote?: string
/**
* Target of the home link.
*
* @default '/'
*/
link?: string
/** /**
* Set aria label for home link. * Set aria label for home link.
* *

Loading…
Cancel
Save