|
|
@ -1,8 +1,8 @@
|
|
|
|
<script setup lang="ts">
|
|
|
|
<script setup lang="ts">
|
|
|
|
import type { DefaultTheme } from 'vitepress/theme'
|
|
|
|
|
|
|
|
import docsearch from '@docsearch/js'
|
|
|
|
import docsearch from '@docsearch/js'
|
|
|
|
import { onMounted, watch } from 'vue'
|
|
|
|
import { useRoute, useRouter } from 'vitepress'
|
|
|
|
import { useRouter, useRoute } from 'vitepress'
|
|
|
|
import type { DefaultTheme } from 'vitepress/theme'
|
|
|
|
|
|
|
|
import { nextTick, onMounted, watch } from 'vue'
|
|
|
|
import { useData } from '../composables/data'
|
|
|
|
import { useData } from '../composables/data'
|
|
|
|
|
|
|
|
|
|
|
|
const props = defineProps<{
|
|
|
|
const props = defineProps<{
|
|
|
@ -18,7 +18,8 @@ type DocSearchProps = Parameters<typeof docsearch>[0]
|
|
|
|
onMounted(update)
|
|
|
|
onMounted(update)
|
|
|
|
watch(localeIndex, update)
|
|
|
|
watch(localeIndex, update)
|
|
|
|
|
|
|
|
|
|
|
|
function update() {
|
|
|
|
async function update() {
|
|
|
|
|
|
|
|
await nextTick()
|
|
|
|
const options = {
|
|
|
|
const options = {
|
|
|
|
...props.algolia,
|
|
|
|
...props.algolia,
|
|
|
|
...props.algolia.locales?.[localeIndex.value]
|
|
|
|
...props.algolia.locales?.[localeIndex.value]
|
|
|
@ -86,12 +87,7 @@ function initialize(userOptions: DefaultTheme.AlgoliaSearchOptions) {
|
|
|
|
|
|
|
|
|
|
|
|
function getRelativePath(url: string) {
|
|
|
|
function getRelativePath(url: string) {
|
|
|
|
const { pathname, hash } = new URL(url, location.origin)
|
|
|
|
const { pathname, hash } = new URL(url, location.origin)
|
|
|
|
return (
|
|
|
|
return pathname.replace(/\.html$/, site.value.cleanUrls ? '' : '.html') + hash
|
|
|
|
pathname.replace(
|
|
|
|
|
|
|
|
/\.html$/,
|
|
|
|
|
|
|
|
site.value.cleanUrls ? '' : '.html'
|
|
|
|
|
|
|
|
) + hash
|
|
|
|
|
|
|
|
)
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
</script>
|
|
|
|
</script>
|
|
|
|
|
|
|
|
|
|
|
|