如何解决如何使用SitePage查询填充搜索索引?
我正在尝试在我的gastby博客中实施搜索。我看过很多教程和插件,但是它们都使用Markdown,我的博客是用Stradi构建的,页面是动态创建的。我意识到节点allSitePage可以提供搜索索引所需的所有信息,我尝试在gatsby-config.js中的flexsearch插件中使用它:
{
resolve: "gatsby-plugin-flexsearch",options: {
languages: ["en"],type: "allSitePage",fields: [
{
name: "title",indexed: true,resolver: "fields.title",attributes: {
encode: "balance",tokenize: "strict",threshold: 6,depth: 3,},store: true,{
name: "context",resolver: "fields.context",store: false,{
name: "url",indexed: false,resolver: "fields.path",],
但是我的索引为空。关于如何使其工作或更简单的替代方案有什么想法?
解决方法
如果有人还在研究这个:
- 删除类型中的“all”(因此,从“allSitePage”到“SitePage”)
- 删除“字段”。在解析器定义中(因此,从“fields.title”到“title”)
更改后 OP 的代码应如下所示:
{
resolve: "gatsby-plugin-flexsearch",options: {
languages: ["en"],type: "SitePage",fields: [
{
name: "title",indexed: true,resolver: "title",attributes: {
encode: "balance",tokenize: "strict",threshold: 6,depth: 3,},store: true,{
name: "context",resolver: "context",store: false,{
name: "url",indexed: false,resolver: "path",],
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。