Fetch JSON from remote URLs, transform and inject as files into metalsmith pipeline
npm install --save-dev metalsmith-remote-json-to-files
There are 2 ways of using this plugin:
- Simplified via configuration object
- Using a callback function
Configuration object should include following keys:
url— [String] URL to fetch from
transformOpts.filename— [String] A string to interpolate the resulting filename from
transformOpts.contents— [String] A string to interpolate the contents of the file from
So, if the endpoint in the
url returns something like:
the configuration object should look like:
Generate static pages from GitHub releases for this project.
This should generate a page for each release from this repository with the contents of the release. Visit https://github.com/okonet/metalsmith-remote-json-to-files/releases to compare.
Same results can be aichived using Node.js API
const metalsmith =const remote =
If you have more advanced usa case, you can always opt-out for using a callback function. This
function must return an array of objects with at least
contents keys set. But
you can add whatever you want to it and when combine with different metalsmith plugins.