|
|
@ -1,9 +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 { DocSearchHit } from '@docsearch/react/dist/esm/types'
|
|
|
|
|
|
|
|
import { onMounted } from 'vue'
|
|
|
|
import { onMounted } from 'vue'
|
|
|
|
import { useRouter, useRoute, useData } from 'vitepress'
|
|
|
|
import { useRouter, useRoute, useData } from 'vitepress'
|
|
|
|
import { DefaultTheme } from '../config'
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const router = useRouter()
|
|
|
|
const router = useRouter()
|
|
|
|
const route = useRoute()
|
|
|
|
const route = useRoute()
|
|
|
@ -52,7 +51,7 @@ function initialize(userOptions: DefaultTheme.AlgoliaSearchOptions) {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
|
|
transformItems(items: DocSearchHit[]) {
|
|
|
|
transformItems(items: any[]) {
|
|
|
|
return items.map((item) => {
|
|
|
|
return items.map((item) => {
|
|
|
|
return Object.assign({}, item, {
|
|
|
|
return Object.assign({}, item, {
|
|
|
|
url: getRelativePath(item.url)
|
|
|
|
url: getRelativePath(item.url)
|
|
|
@ -60,7 +59,7 @@ function initialize(userOptions: DefaultTheme.AlgoliaSearchOptions) {
|
|
|
|
})
|
|
|
|
})
|
|
|
|
},
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
|
|
hitComponent({ hit, children }: { hit: DocSearchHit, children: any }) {
|
|
|
|
hitComponent({ hit, children }: { hit: any; children: any }) {
|
|
|
|
const relativeHit = hit.url.startsWith('http')
|
|
|
|
const relativeHit = hit.url.startsWith('http')
|
|
|
|
? getRelativePath(hit.url as string)
|
|
|
|
? getRelativePath(hit.url as string)
|
|
|
|
: hit.url
|
|
|
|
: hit.url
|
|
|
|