Skip to content

Commit

Permalink
fix(build): uniform handling of windows slash in localSearchPlugin (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
zonemeen committed May 10, 2023
1 parent 2f482af commit b31933f
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 4 deletions.
3 changes: 1 addition & 2 deletions src/client/theme-default/components/VPLocalSearchBox.vue
Expand Up @@ -29,7 +29,6 @@ import {
import type { ModalTranslations } from '../../../../types/local-search'
import { dataSymbol } from '../../app/data'
import { pathToFile } from '../../app/utils'
import { slash } from '../../shared'
import { useData } from '../composables/data'
import { createTranslate } from '../support/translation'
Expand Down Expand Up @@ -218,7 +217,7 @@ debouncedWatch(
)
async function fetchExcerpt(id: string) {
const file = pathToFile(slash(id.slice(0, id.indexOf('#'))))
const file = pathToFile(id.slice(0, id.indexOf('#')))
try {
return { id, mod: await import(/*@vite-ignore*/ file) }
} catch (e) {
Expand Down
4 changes: 2 additions & 2 deletions src/node/plugins/localSearchPlugin.ts
Expand Up @@ -60,7 +60,7 @@ export async function localSearchPlugin(
}

function getLocaleForPath(file: string) {
const relativePath = path.relative(siteConfig.srcDir, file)
const relativePath = slash(path.relative(siteConfig.srcDir, file))
const siteData = resolveSiteDataByRoute(siteConfig.site, relativePath)
return siteData?.localeIndex ?? 'root'
}
Expand Down Expand Up @@ -97,7 +97,7 @@ export async function localSearchPlugin(
function getDocId(file: string) {
let relFile = slash(path.relative(siteConfig.srcDir, file))
relFile = siteConfig.rewrites.map[relFile] || relFile
let id = path.join(siteConfig.site.base, relFile)
let id = slash(path.join(siteConfig.site.base, relFile))
id = id.replace(/\/index\.md$/, '/')
id = id.replace(/\.md$/, siteConfig.cleanUrls ? '' : '.html')
return id
Expand Down

0 comments on commit b31933f

Please sign in to comment.