fix(search): avoid double base

pull/2224/head
Divyansh Singh 2 years ago
parent 77db39be2e
commit 25a1fe90bd

@ -260,7 +260,7 @@ const router = useRouter()
onKeyStroke('Enter', () => { onKeyStroke('Enter', () => {
const selectedPackage = results.value[selectedIndex.value] const selectedPackage = results.value[selectedIndex.value]
if (selectedPackage) { if (selectedPackage) {
router.go(withBase(selectedPackage.id)) router.go(selectedPackage.id)
emit('close') emit('close')
} }
}) })
@ -391,7 +391,7 @@ useEventListener('popstate', (event) => {
<a <a
v-for="(p, index) in results" v-for="(p, index) in results"
:key="p.id" :key="p.id"
:href="withBase(p.id)" :href="p.id"
class="result" class="result"
:class="{ :class="{
selected: selectedIndex === index selected: selectedIndex === index

@ -97,7 +97,7 @@ export async function localSearchPlugin(
function getDocId(file: string) { function getDocId(file: string) {
let relFile = path.relative(siteConfig.srcDir, file) let relFile = path.relative(siteConfig.srcDir, file)
relFile = siteConfig.rewrites.map[relFile] || relFile relFile = siteConfig.rewrites.map[relFile] || relFile
let id = path.join(siteConfig.userConfig.base ?? '', relFile) let id = path.join(siteConfig.userConfig.base ?? '/', relFile)
id = id.replace(/\.md$/, siteConfig.cleanUrls ? '' : '.html') id = id.replace(/\.md$/, siteConfig.cleanUrls ? '' : '.html')
return id return id
} }

Loading…
Cancel
Save