Skip to content
Creates files from supplied JSON
JavaScript
Branch: master
Clone or download

Latest commit

Fetching latest commit…
Cannot retrieve the latest commit at this time.

Files

Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
lib
test
.editorconfig
.eslintrc
.gitignore
.prettierignore
.prettierrc
.travis.yml
LICENSE
README.md
package-lock.json
package.json

README.md

Metalsmith JSON to files plugin

Build Status

npm version code style: prettier metalsmith: plugin

Creates files from supplied JSON

A Metalsmith plugin that lets you generate files from JSON.

Features

  • Many JSON files can be located in one directory for processing
  • Filename is configurable and generated from JSON source file
  • Permalink style filenames make for pretty URLs

Installation

$ npm install metalsmith-json-to-files

Usage

Initialise plugin

var json_to_files = require('metalsmith-json-to-files');

metalsmith.use(
  json_to_files({
    source_path: '../path/to/json_files/'
  })
);

Use plugin

---
name: My Posts
template: posts.hbs
json_files:
  source_file: posts
  filename_pattern: posts/:date-:fields.slug
  as_permalink: true
  template: post.hbs
---

Take a look...

Any extra metadata within the json_files object will be passed through to the files it generates as data.

Rename data object

The data object can be renamed by including rename_data_to in the front matter:

---
name: My Posts
template: posts.hbs
json_files:
    rename_data_to: itemData
---

Examples

See the metalsmith-json-to-files CLI example

License

GPL-2.0

You can’t perform that action at this time.