Skip to content

Front Matter to JSON Action

Actions
Parse a folder of files containing yaml front matter to a json array
v1.2
Latest
Star (1)

Front Matter to JSON Action

Parse the front matter / markdown metadata of files in a directory into a JSON array.

This action outputs a JSON array which can be commited as a file, and is useful for CI purposes.

Inputs

input-directory

Required The path to the directory containing files with front matter.

An example file in the directory might look like:

---
name: QWERTY 
date: 2000-01-01
slug: qwerty 
excerpt: A popular keyboard layout 
---
Qwerty is the first keyboard layout many ....... 
...

content-field

The name of the field containing everything after the front matter. Defaults to content

Outputs

output

The JSON array containing the front matter and content.

It's shape will look like this:

[
  {
    "frontmatter1": "value",
    "frontmatter2": "value",
    "frontmatterN": "value",
    "content": "content"
  },
  {
    "frontmatter1": "value",
    "frontmatter2": "value",
    "frontmatterN": "value",
    "content": "content"
  },
  ...
]

Example usage

uses: actions/checkout@v2
uses: yzalvin/action-yaml-front-matter@v1
with:
  input-directory: './demo'
  content-field: 'description'

Front Matter to JSON Action is not certified by GitHub. It is provided by a third-party and is governed by separate terms of service, privacy policy, and support documentation.

About

Parse a folder of files containing yaml front matter to a json array
v1.2
Latest

Front Matter to JSON Action is not certified by GitHub. It is provided by a third-party and is governed by separate terms of service, privacy policy, and support documentation.