fix(build): don't apply docsearch css transform to pages matching its filter

A markdown or Vue file whose path contains the word "docsearch" was
intercepted by the @docsearch/css transform and never compiled,
failing the build. Check page extensions first.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
pull/5014/head
Divyansh Singh 1 month ago
parent 7ee811b7e6
commit fa0e48c8df

@ -208,12 +208,6 @@ export async function createVitePressPlugin(
transform: { transform: {
filter: { id: [docsearchRE, /\.vue$/, /\.md$/] }, filter: { id: [docsearchRE, /\.vue$/, /\.md$/] },
async handler(code, id) { async handler(code, id) {
if (docsearchRE.test(normalizePath(id))) {
return code
.replaceAll('[data-theme=dark]', '.dark')
.replaceAll(/\(max-width:\s*768px\)/g, '(max-width: 767px)')
.replaceAll(/\(min-width:\s*769px\)/g, '(min-width: 768px)')
}
if (id.endsWith('.vue')) { if (id.endsWith('.vue')) {
return processClientJS(code, id) return processClientJS(code, id)
} }
@ -254,6 +248,12 @@ export async function createVitePressPlugin(
} }
return processClientJS(vueSrc, id) return processClientJS(vueSrc, id)
} }
if (docsearchRE.test(normalizePath(id))) {
return code
.replaceAll('[data-theme=dark]', '.dark')
.replaceAll(/\(max-width:\s*768px\)/g, '(max-width: 767px)')
.replaceAll(/\(min-width:\s*769px\)/g, '(min-width: 768px)')
}
} }
}, },

Loading…
Cancel
Save