Describe the bug
I use Forestry.io for clients to update their 11ty content. Fields get written to front matter, including Markdown textarea fields. Unfortunately I can't get those markdown fields rendered with my nunjucks templates. It is always output as is and not parsed with Markdown. Is there any way to make this work besides a custom filter?
To Reproduce
Put markdown in front matter nunjucks template.
Environment:
@chromadesign do you use the content body in Forestry?
I have this line in my forestry configuration: hide_body: false
The body is editable, and goes into the Markdown file body, not in the front matter.
Here's the configuration for this blog:
https://github.com/nhoizey/precious-prana.com/blob/master/.forestry/front_matter/templates/billet.yml
Here is one of the blog posts:
https://github.com/nhoizey/precious-prana.com/blob/master/src/blog/2020-04-30-decouvrez-le-bain-de-gong-pour-apprivoiser-et-apprecier-la-guerison-par-le-son.md
Yes, partially. The "problem" is that I use a repeatable field group in Forestry which results in nested front matter, so there will be multiple instances of Markdown which is why I can't use the body field for this anyhow.
Ok, I understand now.
As you suggested in your question, you'll need to use a filter to parse these Markdown contents.
Here's how I add this filter with the same configuration as for "body" Markdown:
https://github.com/nhoizey/nicolas-hoizey.com/blob/master/.eleventy.js#L145-L148
Fantastic, thanks a lot! I just wanted to make sure I didn't overlook or misunderstand something. :)
@chromadesign you're welcome.
@nhoizey thanks for this. works really well.
I'd lost a few hours to this and trying this solution https://github.com/11ty/eleventy/issues/236 adding templateEngineOverride: njk,md to the layout njk file rendered out the front matter markdown, but caused the surrounding html body to be output as escaped/unsafe
Most helpful comment
Ok, I understand now.
As you suggested in your question, you'll need to use a filter to parse these Markdown contents.
Here's how I add this filter with the same configuration as for "body" Markdown:
https://github.com/nhoizey/nicolas-hoizey.com/blob/master/.eleventy.js#L145-L148