Используя Gatsby JS, я пытаюсь запросить frontmatter моего поста в блоге (MDX) с GraphQL на моем hompage, который также является файлом MDX.
Я следую Руководство Гэтсби о том, как это сделать, но я продолжаю получать сообщение об ошибке «Ошибка типа: props.data.allMdx.edges.node не определена»
Страница, к которой я хочу обратиться по адресу «scr / pages / index.mdx»
import { graphql } from "gatsby"
import Container from "../components/container"
import Cards from "../components/cards"
export const pageQuery = graphql`
query IndexPageQuery {
allMdx(filter: {fileAbsolutePath: {regex: "content/posts/"}}) {
edges {
node {
id
frontmatter {
title
}
}
}
}
}
`
## Recent Posts
<Container>
{props.data.allMdx.edges.node.frontmatter.map(node => (
<Cards>
<h3>{node.title}</h3>
</Cards>
))}
</Container>
Мой gatsby-config. js file:
const remarkPlugins = [require("remark-slug")]
const website = require("./config/website")
const pathPrefix = website.pathPrefix === "/" ? "" : website.pathPrefix
module.exports = {
pathPrefix: website.pathPrefix,
siteMetadata: {
siteUrl: website.url + pathPrefix,
pathPrefix,
title: website.title,
titleAlt: website.titleAlt,
description: website.description,
banner: website.logo,
headline: website.headline,
siteLanguage: website.siteLanguage,
ogLanguage: website.ogLanguage,
author: website.author,
facebook: website.facebook,
twitter: website.twitter,
},
plugins: [
"gatsby-plugin-react-helmet",
"gatsby-plugin-catch-links",
{
resolve: `gatsby-source-filesystem`,
options: {
name: "content",
path: `${__dirname}/content/`,
},
},
{
resolve: `gatsby-source-filesystem`,
options: {
name: "posts",
path: `${__dirname}/content/posts/`,
},
},
{
resolve: `gatsby-plugin-mdx`,
options: {
extensions: [".mdx", ".md"],
remarkPlugins,
options: {
gatsbyRemarkPlugins: [
{
resolve: `gatsby-remark-images`,
options: {
maxWidth: 1200,
},
},
],
},
},
},
],
}
Что я здесь не так делаю? Я что-то упустил?