From 494c634eb1d77963e555a736fa057dcb23700989 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=BD=E5=AE=81?= Date: Thu, 27 Apr 2023 17:11:15 +0800 Subject: [PATCH] fix(theme): local search get 404 on build when use route rewrites in windows (#2301) --- src/node/plugins/localSearchPlugin.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/node/plugins/localSearchPlugin.ts b/src/node/plugins/localSearchPlugin.ts index c12d03d3..0afa1adb 100644 --- a/src/node/plugins/localSearchPlugin.ts +++ b/src/node/plugins/localSearchPlugin.ts @@ -5,7 +5,7 @@ import fs from 'fs-extra' import _debug from 'debug' import type { SiteConfig } from '../config' import { createMarkdownRenderer } from '../markdown/markdown' -import { resolveSiteDataByRoute } from '../shared' +import { resolveSiteDataByRoute, slash } from '../shared' const debug = _debug('vitepress:local-search') @@ -95,7 +95,7 @@ export async function localSearchPlugin( } function getDocId(file: string) { - let relFile = path.relative(siteConfig.srcDir, file) + let relFile = slash(path.relative(siteConfig.srcDir, file)) relFile = siteConfig.rewrites.map[relFile] || relFile let id = path.join(siteConfig.site.base, relFile) id = id.replace(/\/index\.md$/, '/')