codeanitdotcom / codeanitdotcom.github.io

codeanit.com by @codeanit
https://codeanit.com
MIT License
0 stars 1 forks source link

Bug: Lunr field missing #7

Closed anitsh closed 4 years ago

anitsh commented 4 years ago

Description:

  {
      resolve: 'gatsby-plugin-lunr',
      options: {
        languages: [{ name: 'en' }],
        fields: [
          { name: 'title', store: true, attributes: { boost: 20 } },
          { name: 'subtitle', store: true, attributes: { boost: 5 } },
          { name: 'content' },
          { name: 'slug', store: true },
          { name: 'date', store: true },
          { name: 'keywords', store: true },
        ],
        resolvers: {
          Mdx: {
            title: node => node.frontmatter.title,
            subtitle: node => node.frontmatter.subtitle,
            content: node => node.rawBody,
            date: node => node.frontmatter.date,
            slug: node => `/posts/${node.frontmatter.slug}`,
            keywords: node => node.formatter.keywords, // ERROR 
          },
        },

Solution:

keywords: node => node.frontmatter.keywords, // Fixed by replacing `formatter` with `frontmatter`