'Gatsby v4 - Joining Author Details Into a Post [closed]

Using Gatsby v4. In my blog posts there is a field author. There is a separate authors file which includes details of the blog post authors - full name and avatar.

Post File:

---
date: "2021-12-31"
title: "Happy New Year"
author: chuck
---
## Happy New Year!

content/authors/author.yaml

- id: chuck
  name: Chuck Norris
  avatar: chuck.jpg

The GraphQL looks like this:


export const pageQuery = graphql`
    query($slug: String!) {
        markdownRemark(fields: { slug: { eq: $slug } }) {
            html
            excerpt(pruneLength: 200)
            frontmatter {
                title
                author {
                    id
                    name
                    avatar
                },
            }
            fields {
                slug
                readingTime {
                    minutes
                }
            }
        }
    }

But in the BlogPost template the data.markdownRemark.frontmatter.author is null.

In gatsby-config.js I have:

        {
            resolve: `gatsby-source-filesystem`,
            options: {
                path: `${__dirname}/content/authors`,
                name: `authors`
            }
        },

and

    mapping: {
        'MarkdownRemark.frontmatter.author': `AuthorYaml`
    }

But it doesn't help. Same code used to work on Gatsby v2 and stops working with conversion to v4.



Solution 1:[1]

Turns out there was a typo in a different place that causes this.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 rubenhak