markdown - 盖茨比无法查询frontmatter
问题描述
我现在正在学习 Gatsby.js,但遇到了问题。我已经安装了转换器插件,并且我有一个 .md 文件,其中有标题、堆栈和 slug。
title :Place Sharing Website
stack :React.js & Node.js
slug :place-sharing
---
### You can share the places that you visited
我想查询那个标题、堆栈和 slug。但我不能那样做。这是我试图这样做的代码。
allMarkdownRemark {
nodes {
frontmatter {
title
stack
slug
}
}
}
}
它没有用。
这是我的 gatsby.config 文件
module.exports = {
plugins: [
"gatsby-transformer-remark",
{
resolve: `gatsby-source-filesystem`,
options: {
name: `notes`,
path: `${__dirname}/src/notes/`,
},
},
{
resolve: `gatsby-source-filesystem`,
options: {
name: `projects`,
path: `${__dirname}/src/projects/`,
},
},
],
siteMetadata: {
title: "My Homepage",
description: "This is where I write my thoughts.",
},
}
这是我试图查询它的方式。
知道我做错了什么吗?
解决方案
我认为你有格式问题。尝试:
title: Place Sharing Website
stack: React.js & Node.js
slug: place-sharing
并检查 markdown 文件的创建,字段应包含在---
.
推荐阅读
- java - 如何用 Python 为用 Java 编写的 gRPC 服务编写 gRPC 客户端
- git - 恢复特定的 git 提交和依赖于它们的所有后续提交
- mysql - MySQL ERROR 2026 - SSL 连接错误 - Ubuntu 20.04
- mysql - SQL - 从大型数据集中返回多条记录中的最新记录
- php - Laravel 避免子表中的重复条目
- c++ - 需要对未初始化的变量进行一些澄清
- python - 在 Mac 上安装 Tkinter 以在 Pycharm 上使用
- java - 使用 Hive 的 Spark,无法使用 Hive 支持实例化 SparkSession,因为找不到 Hive 类
- mysql - 在列中创建非零天的运行总计
- javascript - 笑话:函数中的模拟类方法