From 90c28d41ce0a67f6e096ce9fd355f3b0c7b1dab7 Mon Sep 17 00:00:00 2001 From: Divyansh Singh <40380293+brc-dd@users.noreply.github.com> Date: Sun, 12 Jul 2026 17:18:20 +0530 Subject: [PATCH] fix(theme): align docsearch breakpoints with the default theme closes #5213 --- src/node/plugin.ts | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/node/plugin.ts b/src/node/plugin.ts index e415bde6..94778dcf 100644 --- a/src/node/plugin.ts +++ b/src/node/plugin.ts @@ -41,7 +41,7 @@ declare module 'vite' { const themeRE = /(?:^|\/)\.vitepress\/theme\/index\.(m|c)?(j|t)s$/ const startsWithThemeRE = /^@theme(?:\/|$)/ -const docsearchRE = /\/docsearch\.css(?:$|\?)/ +const docsearchRE = /\bdocsearch\b/ // narrow it if any issue arises const hashRE = /\.([-\w]+)\.js$/ const staticInjectMarkerRE = /\bcreateStaticVNode\((?:(".*")|('.*')), (\d+)\)/g @@ -193,9 +193,13 @@ export async function createVitePressPlugin( } }, + // TODO: use plugin hook filters async transform(code, id) { if (docsearchRE.test(normalizePath(id))) { - return code.replaceAll('[data-theme=dark]', '.dark') + 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')) { return processClientJS(code, id)