Skip to content

Commit e035027

Browse files
committed
fix: temporary fix for docsearch navigation
1 parent f93d415 commit e035027

File tree

3 files changed

+37
-59
lines changed

3 files changed

+37
-59
lines changed

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -95,8 +95,8 @@
9595
"*": "prettier --write --ignore-unknown"
9696
},
9797
"dependencies": {
98-
"@docsearch/css": "3.8.2",
99-
"@docsearch/js": "3.8.2",
98+
"@docsearch/css": "^3.8.3",
99+
"@docsearch/js": "^3.8.3",
100100
"@iconify-json/simple-icons": "^1.2.21",
101101
"@shikijs/core": "^2.1.0",
102102
"@shikijs/transformers": "^2.1.0",

pnpm-lock.yaml

Lines changed: 33 additions & 33 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/client/theme-default/components/VPAlgoliaSearchBox.vue

Lines changed: 2 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<script setup lang="ts">
22
import docsearch from '@docsearch/js'
3-
import { useRoute, useRouter } from 'vitepress'
3+
import { useRouter } from 'vitepress'
44
import type { DefaultTheme } from 'vitepress/theme'
55
import { nextTick, onMounted, watch } from 'vue'
66
import { useData } from '../composables/data'
@@ -10,7 +10,6 @@ const props = defineProps<{
1010
}>()
1111
1212
const router = useRouter()
13-
const route = useRoute()
1413
const { site, localeIndex, lang } = useData()
1514
1615
type DocSearchProps = Parameters<typeof docsearch>[0]
@@ -51,17 +50,7 @@ function initialize(userOptions: DefaultTheme.AlgoliaSearchOptions) {
5150
5251
navigator: {
5352
navigate({ itemUrl }) {
54-
const { pathname: hitPathname } = new URL(
55-
window.location.origin + itemUrl
56-
)
57-
58-
// router doesn't handle same-page navigation so we use the native
59-
// browser location API for anchor navigation
60-
if (route.path === hitPathname) {
61-
window.location.assign(window.location.origin + itemUrl)
62-
} else {
63-
router.go(itemUrl)
64-
}
53+
router.go(itemUrl)
6554
}
6655
},
6756
@@ -71,17 +60,6 @@ function initialize(userOptions: DefaultTheme.AlgoliaSearchOptions) {
7160
url: getRelativePath(item.url)
7261
})
7362
})
74-
},
75-
76-
hitComponent({ hit, children }) {
77-
return {
78-
__v: null,
79-
type: 'a',
80-
ref: undefined,
81-
constructor: undefined,
82-
key: undefined,
83-
props: { href: hit.url, children }
84-
}
8563
}
8664
}) as DocSearchProps
8765

0 commit comments

Comments
 (0)