|
|
@ -60,43 +60,13 @@ function initialize(userOptions: DefaultTheme.AlgoliaSearchOptions) {
|
|
|
|
},
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
|
|
hitComponent({ hit, children }: { hit: any; children: any }) {
|
|
|
|
hitComponent({ hit, children }: { hit: any; children: any }) {
|
|
|
|
const relativeHit = hit.url.startsWith('http')
|
|
|
|
|
|
|
|
? getRelativePath(hit.url as string)
|
|
|
|
|
|
|
|
: hit.url
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return {
|
|
|
|
return {
|
|
|
|
__v: null,
|
|
|
|
__v: null,
|
|
|
|
type: 'a',
|
|
|
|
type: 'a',
|
|
|
|
ref: undefined,
|
|
|
|
ref: undefined,
|
|
|
|
constructor: undefined,
|
|
|
|
constructor: undefined,
|
|
|
|
key: undefined,
|
|
|
|
key: undefined,
|
|
|
|
|
|
|
|
props: { href: hit.url, children }
|
|
|
|
props: {
|
|
|
|
|
|
|
|
href: hit.url,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
onClick(event: MouseEvent) {
|
|
|
|
|
|
|
|
if (isSpecialClick(event)) {
|
|
|
|
|
|
|
|
return
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// we rely on the native link scrolling when user is already on
|
|
|
|
|
|
|
|
// the right anchor because Router doesn't support duplicated
|
|
|
|
|
|
|
|
// history entries.
|
|
|
|
|
|
|
|
if (route.path === relativeHit) {
|
|
|
|
|
|
|
|
return
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// if the hits goes to another page, we prevent the native link
|
|
|
|
|
|
|
|
// behavior to leverage the Router loading feature.
|
|
|
|
|
|
|
|
if (route.path !== relativeHit) {
|
|
|
|
|
|
|
|
event.preventDefault()
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
router.go(relativeHit)
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
children
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
})
|
|
|
|
})
|
|
|
@ -104,19 +74,8 @@ function initialize(userOptions: DefaultTheme.AlgoliaSearchOptions) {
|
|
|
|
docsearch(options)
|
|
|
|
docsearch(options)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
function isSpecialClick(event: MouseEvent) {
|
|
|
|
|
|
|
|
return (
|
|
|
|
|
|
|
|
event.button === 1 ||
|
|
|
|
|
|
|
|
event.altKey ||
|
|
|
|
|
|
|
|
event.ctrlKey ||
|
|
|
|
|
|
|
|
event.metaKey ||
|
|
|
|
|
|
|
|
event.shiftKey
|
|
|
|
|
|
|
|
)
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function getRelativePath(absoluteUrl: string) {
|
|
|
|
function getRelativePath(absoluteUrl: string) {
|
|
|
|
const { pathname, hash } = new URL(absoluteUrl)
|
|
|
|
const { pathname, hash } = new URL(absoluteUrl)
|
|
|
|
|
|
|
|
|
|
|
|
return pathname + hash
|
|
|
|
return pathname + hash
|
|
|
|
}
|
|
|
|
}
|
|
|
|
</script>
|
|
|
|
</script>
|
|
|
|