gatsby-frontmatter-template-parser

1.1.0 • Public • Published

Gatsby Frontmatter Template Parser

This plugin will allow you to write template strings on the frontmatter of your markdown files.

This plugin was developed to be used on Gatsby projects.

How to Use

Install it with

$ npm install --save gatsby-frontmatter-template-parser

Then on your gatsby-config.js:

const gatsbyFrontMatterTemplateParser = require('gatsby-frontmatter-template-parser');
const path = require('path');
const yamlModelsDirectory = path.join(__dirname, 'yaml-models');
 
module.exports = {
    ...
    plugins: [
        ...
        {
            "resolve": `gatsby-transformer-remark`,
            "options": {
                engines: {
                    yaml: gatsbyFrontMatterTemplateParser({
                        yamlModelsDirectory
                    })
                }
            }
        }
    ]
}

At this point you have already completed the setup for this plugin. Check below to see the usage for your YAML models:

namespace: authors # This is required. When you access this yaml model you'll access using this namespace. e.g: "{{authors.johnDoe}}" 
 
johnDoe:
    name: John Doe
    age: 26

On your frontmatter, you'll simply need to use the {{}} notation. See below:

---
author: "{{authors.johnDoe}}"
---

The plugin will make sure that {{authors.johnDoe}} will be translated to the matching object.

Readme

Keywords

Package Sidebar

Install

npm i gatsby-frontmatter-template-parser

Weekly Downloads

1

Version

1.1.0

License

ISC

Unpacked Size

12.3 kB

Total Files

13

Last publish

Collaborators

  • bluehood