更改页面的内容
Some checks failed
CI / lint (push) Failing after 29m56s
CI / typecheck (push) Failing after 8m26s
CI / build (ubuntu-latest) (push) Failing after 18s

This commit is contained in:
2025-07-31 15:04:22 +08:00
parent a301b4c692
commit ce50120e40
39 changed files with 2692 additions and 110 deletions

View File

@@ -0,0 +1,51 @@
<script setup lang="ts">
import MiniSearch from 'minisearch'
const query = ref('')
const { data } = await useAsyncData('search-data', () => queryCollectionSearchSections('docs'))
const miniSearch = new MiniSearch({
fields: ['title', 'content'],
storeFields: ['title', 'content'],
searchOptions: {
prefix: true,
fuzzy: 0.2,
},
})
// Add data to the MiniSearch instance
miniSearch.addAll(toValue(data.value || []))
const result = computed(() => miniSearch.search(toValue(query)).slice(0, 10))
</script>
<template>
<UContainer class="p-4">
<UCard>
<UInput
v-model="query"
placeholder="Search..."
class="w-full"
/>
<ul>
<li
v-for="link of result"
:key="link.id"
class="mt-2"
>
<UButton
variant="ghost"
class="w-full"
:to="link.id"
>
<div class="flex flex-col">
<span class="text-black dark:text-white font-semibold">{{ link.title }}</span>
<span class="text-gray-500 text-xs truncate">
{{ link.content?.slice(0, 100) }}...
</span>
</div>
</UButton>
</li>
</ul>
</UCard>
</UContainer>
</template>