如何使用 gatsby-transformer-remark 在 markdown 中获取自定义备注?
How to get custom remarks in markdown with gatsby-transformer-remark?
我的 markdown 有一些额外的注释,看起来像这样:
---
path: "/"
date: "2018-10-12"
title: "xxxx"
description: "desccc"
---
some of the text
如何获取描述?
{
allMarkdownRemark(
sort: { order: DESC, fields: [frontmatter___date] }
limit: 1000
) {
edges {
node {
frontmatter {
path
title
date
}
}
}
}
}
好吧,markdown 文档的头部通常被称为 frontmatter
并且会自动为您转换,因此只需将 description
字段添加到 [=12= 内的 graphql 查询中] 结构并像使用 title
字段一样使用它。
我的 markdown 有一些额外的注释,看起来像这样:
---
path: "/"
date: "2018-10-12"
title: "xxxx"
description: "desccc"
---
some of the text
如何获取描述?
{
allMarkdownRemark(
sort: { order: DESC, fields: [frontmatter___date] }
limit: 1000
) {
edges {
node {
frontmatter {
path
title
date
}
}
}
}
}
好吧,markdown 文档的头部通常被称为 frontmatter
并且会自动为您转换,因此只需将 description
字段添加到 [=12= 内的 graphql 查询中] 结构并像使用 title
字段一样使用它。