Introducing Socket Firewall: Free, Proactive Protection for Your Software Supply Chain.Learn More
Socket
Book a DemoInstallSign in
Socket

gatsby-transformer-remark-frontmatter

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

gatsby-transformer-remark-frontmatter

Allows querying frontmatter fields as markdown with gatsby-transformer-remark

latest
Source
npmnpm
Version
1.1.0
Version published
Maintainers
1
Created
Source

gatsby-transformer-remark-frontmatter

Allows querying Markdown frontmatter fields as markdown. Currently only works on top-level string typed keys in the frontmatter, but support for string fields in objects or lists can be added if people ask for it enough or someone submits a pull request.

Install

npm i gatsby-transformer-remark-frontmatter

How to use

// in your gatsby-config.js
plugins: [
  'gatsby-transformer-remark',
  'gatsby-transformer-remark-frontmatter'
]

Add the @md directive to fields in your GraphQL schema that you want to parse as Markdown.

Example

Given the following markdown file

---
templateKey: index-template
sidebar: |
  # Some Markdown Content
  ![My Fancy Image](../image.png)
list:
  - item: |
     # Currently Supported
---

# Main Content

Some Text

The following GraphQL schema can be combined with the query below to get the body content and the sidebar markdown as html.

Schema:

type ListItem {
  item: String @md
}
type Frontmatter @infer {
  sidebar: String @md
  list: [ListItem!]
}
type MarkdownRemark implements Node @infer {
  frontmatter: Frontmatter!
}

Query:

query {
  allMarkdownRemark(filter: { frontmatter: { templateKey: { eq: "index-template" } } }) {
    html
    frontmatter {
      templateKey
      sidebar {
        html
      }
      list {
        item {
          html
        }
      }
    }
  }
}

Possible Issues

Many plugins expect all MarkdownRemark nodes to have File node parents. This plugin passes data through those plugins, but at the moment doesn't link the parent node to the original file. This may cause some plugins that depend on MarkdownRemark parents to fail (such as gatsby-remark-images).

Keywords

gatsby

FAQs

Package last updated on 26 Jun 2021

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts