Ajedi32 / metalsmith-matters

A Metalsmith plugin to read file metadata from YAML frontmatter
MIT License
8 stars 2 forks source link

Add ability to pull in an external file and attach it to a frontmatter property #6

Closed dillonbheadley closed 8 years ago

dillonbheadley commented 8 years ago

Something like: books.md:

  ---
  books: data/books.yaml
  ---

Would that be possible? That way we could have a separate source of data that could be referenced by multiple files as needed.

Ajedi32 commented 8 years ago

This seems like the sort of thing that'd be best to do with a plugin further down the pipe. After .use(frontmatter()), add another plugin that reads the metadata from existing files and replaces references to other YAML files with the parsed contents of those files.

That's one of the really nice things about Metalsmith; it's easy to add extra steps like this to customize the build to your liking.

If you need an example to help you get started, metalsmith-metafiles does something similar (though not quite the same), so you could reference the source code of that plugin when writing yours.

Or alternately maybe an existing plugin like metalsmith-metadata might do what you want. (It adjusts global metadata though, not per-file metadata.)