所以我试图添加搜索功能,但 searchContent() 总是返回空数组。我不明白为什么这不起作用。我的 Markdown 文档位于 /content 中。
这里是一些相关的软件包版本:
我的 nuxt 配置
export default defineNuxtConfig({
devtools: { enabled: true },
modules: ['@nuxt/ui', '@nuxt/content'],
content: {
experimental: {
search: {
indexed: true
}
}
}
})
搜索片段
const keywords = ref('')
const search = lodash.debounce(async () => {
const res = await searchContent(keywords)
console.log(res.value)
}, 500)
使用
.value
const keywords = ref('')
const search = lodash.debounce(async () => {
const res = await searchContent(keywords.value)
console.log(res.value)
}, 500)