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
'@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.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.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:
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.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.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:
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)
'@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.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.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':
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.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.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:
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.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.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)
why-is-node-running: 2.3.0
optionalDependencies:

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

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

@ -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);
}

@ -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,

@ -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 ? `<div class="vp-raw">\n` : `</div>\n`
})
.use(...createCodeGroup(options, md))
.use(...createCodeGroup(md))
}
type ContainerArgs = [typeof container, string, { render: RenderRule }]
@ -69,16 +46,18 @@ 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 `<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`
}
}
]
}
function createCodeGroup(options: Options, md: MarkdownItAsync): ContainerArgs {
function createCodeGroup(md: MarkdownItAsync): ContainerArgs {
return [
container,
'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`
}

@ -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(?=:|$)/

@ -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 (
`<div class="language-${lang}${getAdaptiveThemeMarker(options)}${active}">` +
`<div class="language-${lang}${active}">` +
`<button title="${options.codeCopyButtonTitle}" class="copy"></button>` +
`<span class="lang">${lang}</span>` +
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 (

@ -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, '')

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

Loading…
Cancel
Save