代码之家  ›  专栏  ›  技术社区  ›  Totty.js

如何用gatsby transformer remark在markdown中获得自定义备注?

  •  0
  • Totty.js  · 技术社区  · 7 年前

    我的降价有一些额外的备注,如下所示:

    ---
    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
            }
          }
        }
      }
    }
    
    1 回复  |  直到 7 年前
        1
  •  1
  •   Z. Zlatev    7 年前

    嗯,降价文件的头部分通常被称为 frontmatter 并且会自动为您转换,所以只需添加 description frontmatter { ... } title 例如字段。

    推荐文章