Skip to content
This repository has been archived by the owner on Jul 5, 2023. It is now read-only.

Clarified docs and fixed JSON #3

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion Readme.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@

<img src="https://travis-ci.org/mattly/metalsmith-placeholder.svg" data-bindattr-818="818" title="Build Status Images">

A metalsmith plugin to allow stub metadata files, such as `index.html.yaml`.
A metalsmith plugin to allow stub metadata files, such as `index.html.yaml`. The plugin parses files having extension `.yml`, `.yaml`, and `.json`, strips this extension from metalsmith's representation of the file, and replaces the file's unparsed data with the parsed data in the form of per-file metadata. The contents (buffer) of the resulting pipeline file is an empty string.

The implementation requires support for ES6.

## Usage

Expand Down
6 changes: 3 additions & 3 deletions src/placeholder.es6
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@ export default function(config) {
, metadata
;
try {
if (extName.match(/\.yaml?/)) {
if (extName.match(/\.ya?ml/)) {
metadata = yaml.safeLoad( page.contents.toString() );
} else if (extName == 'json') {
metadata = JSON.stringify(page.contents.toString());
} else if (extName == '.json') {
metadata = JSON.parse(page.contents.toString());
}
}
catch(e) { done(e); }
Expand Down