diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 76b395f3..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.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: 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/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%); } 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 073fb38d..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 }] @@ -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 `
${title}\n` - return `

${title}

\n` + return `

${title}

\n` } else return klass === 'details' ? `
\n` : `
\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 `
${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 ( 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, '') diff --git a/types/default-theme.d.ts b/types/default-theme.d.ts index fb736290..1971173c 100644 --- a/types/default-theme.d.ts +++ b/types/default-theme.d.ts @@ -485,6 +485,13 @@ export namespace DefaultTheme { */ quote?: string + /** + * Target of the home link. + * + * @default '/' + */ + link?: string + /** * Set aria label for home link. *