yeojz / metalsmith-react-templates

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

add a `hydrator` param that allows adding/modifying file attributes #57

Closed manuhabitela closed 6 years ago

manuhabitela commented 6 years ago

This is in relation to my question in #56.

Adding a function allowing full control of how data is set on the syntheticFile allows me to handle React Helmet in static-only mode.

Here is a gist to show how I managed to get what I want.

yeojz commented 6 years ago

@Leimi Thank you so much for sending in a PR!!.. Looks great. 👍

2 suggestions:

Thanks again!!

manuhabitela commented 6 years ago

Oh I forgot to link the gist I was talking about to show how I made everything work, here it is https://gist.github.com/Leimi/b62975a28b202fb6919fa7feb7688f5b.

About the postRender renaming, if you want, but I'm not sure. I'm not that fond of "hydrator" myself but I choosed it because it implied the function was supposed to return some attributes to put in an object. postRender doesn't give that information at all...postRenderHydrator? :p

manuhabitela commented 6 years ago

I added some more info in the README, what do you think?

Waiting on your final input on the naming to change things if needed. Thanks!

yeojz commented 6 years ago

Noted on that point. Personally, I was hesitant about hydrator partly also because the newer ReactDOM also has a hydrate function which may be confusing.

It is a bit of a mouthful, but let's go with your suggestion of postRenderHydrator. :+1:

Will merge after that change. Thanks!

manuhabitela commented 6 years ago

Okay thanks, I updated the branch.

manuhabitela commented 6 years ago

Thanks for merging!