revert search box changes

pull/4507/head
Divyansh Singh 8 months ago
parent bc137980c0
commit 36ec75268d

@ -1,6 +1,6 @@
<script setup lang="ts"> <script setup lang="ts">
import docsearch from '@docsearch/js' import docsearch from '@docsearch/js'
import { useRoute, useRouter } from 'vitepress' import { useRouter } from 'vitepress'
import type { DefaultTheme } from 'vitepress/theme' import type { DefaultTheme } from 'vitepress/theme'
import { nextTick, onMounted, watch } from 'vue' import { nextTick, onMounted, watch } from 'vue'
import { useData } from '../composables/data' import { useData } from '../composables/data'
@ -10,7 +10,6 @@ const props = defineProps<{
}>() }>()
const router = useRouter() const router = useRouter()
const route = useRoute()
const { site, localeIndex, lang } = useData() const { site, localeIndex, lang } = useData()
type DocSearchProps = Parameters<typeof docsearch>[0] type DocSearchProps = Parameters<typeof docsearch>[0]
@ -51,17 +50,7 @@ function initialize(userOptions: DefaultTheme.AlgoliaSearchOptions) {
navigator: { navigator: {
navigate({ itemUrl }) { navigate({ itemUrl }) {
const { pathname: hitPathname } = new URL( router.go(itemUrl)
window.location.origin + itemUrl
)
// router doesn't handle same-page navigation so we use the native
// browser location API for anchor navigation
if (route.path === hitPathname) {
window.location.assign(window.location.origin + itemUrl)
} else {
router.go(itemUrl)
}
} }
}, },
@ -71,17 +60,6 @@ function initialize(userOptions: DefaultTheme.AlgoliaSearchOptions) {
url: getRelativePath(item.url) url: getRelativePath(item.url)
}) })
}) })
},
hitComponent({ hit, children }) {
return {
__v: null,
type: 'a',
ref: undefined,
constructor: undefined,
key: undefined,
props: { href: hit.url, children }
}
} }
}) as DocSearchProps }) as DocSearchProps

Loading…
Cancel
Save