metalsmith / layouts

A metalsmith plugin for layouts
MIT License
116 stars 49 forks source link

rendering custom global metadata in a partial #81

Closed fephil closed 8 years ago

fephil commented 8 years ago

Hi,

I have built my own plugin for adding metadata from multiple json files and it works fine on pages but doesn't work when references are in a partial.

Link to plugin: http://github.com/fephil/metalsmith-data-directory Link to example workflow: http://github.com/fephil/foley

I tried looking at the layouts code but I didn't see anything out of the ordinary.

Thanks

ismay commented 8 years ago

Hmm strange, the metadata should just be available everywhere. Might be a context problem if you're using a language like handlebars: http://assemble.io/docs/Context.html

Do you have an example repo that implements your plugin?

fephil commented 8 years ago

I'll produce a more stripped back example ASAP and get back to you. The reason why I mentioned it here with was that metalsmith-in-place works fine so it seemed strange.

I'll take a look into the context as well.

ismay commented 8 years ago

Ok. Well then it could be the registration of the partials (which is slightly different), or that metalsmith-in-place processes templating syntax in files from src, which metalsmith-layouts does not.

If the rest of the partial is rendering correctly it should not be the registration.

fephil commented 8 years ago

The rest of the partial is rendering correctly. I took a look at context and I don't think it applies in this situation (but I could be wrong with that).

Hope this is clear, let me know if I can do anything else.

ismay commented 8 years ago

Your setup is rather unusual, instead of putting your layouts and partials in src I'd put them at the root. src is only for files that should end up in dist. See this example.

I'd refactor to that structure and see if you still have the problem. I'm still suspecting that it's because metalsmith-layouts doesn't process templating syntax for anything in src, but refactoring to the recommended structure would rule out some other possible causes.

fephil commented 8 years ago

That makes sense. I'll experiment with this in the next few days and report back/close.

Thanks for looking into this.

fephil commented 8 years ago

Hi. This was caused by an error in my plugin sadly. Everything now works as expected. Thanks.

ismay commented 8 years ago

Ah ok cool, thanks for reporting back! 👍