yeojz / metalsmith-react-templates

A metalsmith plugin to render files using React / Preact / JSX based templates.
MIT License
92 stars 17 forks source link

json instead of markdown? #42

Closed ghost closed 7 years ago

ghost commented 8 years ago

Hi. Thanks a lot for this nice plugin! Is it possible to store my data into json files instead of markdown files in the /src/ directory?

yeojz commented 8 years ago

@justfunk should not be a problem.

Metalsmith reads all files in the directory. As for this plugin, you can set the pattern to only read from json pattern: **/*.json

Contents of the file will still be in the content prop.

yeojz commented 7 years ago

@justfunk Closing this. Please reopen if needed. Thanks!

ablackledge commented 7 years ago

Hi @yeojz , I'm also want to use json instead of markdown for the data I'll pass into the React template, when I've added a json file although it is being read and used it's just interpreted as one big string. Is there something I need to do so that it's being treated as a proper json object?

Thanks

yeojz commented 7 years ago

@ablackledge you'll probably need to use JSON.parse() on the value.

ablackledge commented 7 years ago

Oh damn sorry, so simple should have come to that conclusion myself! 😳 Thanks for the quick reply