fix(theme): local search get 404 on build when use route rewrites in windows (#2301)

pull/2565/head
烽宁 2 years ago committed by GitHub
parent 69c7646daf
commit 494c634eb1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -5,7 +5,7 @@ import fs from 'fs-extra'
import _debug from 'debug' import _debug from 'debug'
import type { SiteConfig } from '../config' import type { SiteConfig } from '../config'
import { createMarkdownRenderer } from '../markdown/markdown' import { createMarkdownRenderer } from '../markdown/markdown'
import { resolveSiteDataByRoute } from '../shared' import { resolveSiteDataByRoute, slash } from '../shared'
const debug = _debug('vitepress:local-search') const debug = _debug('vitepress:local-search')
@ -95,7 +95,7 @@ export async function localSearchPlugin(
} }
function getDocId(file: string) { 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 relFile = siteConfig.rewrites.map[relFile] || relFile
let id = path.join(siteConfig.site.base, relFile) let id = path.join(siteConfig.site.base, relFile)
id = id.replace(/\/index\.md$/, '/') id = id.replace(/\/index\.md$/, '/')

Loading…
Cancel
Save