11ty / 11ty-website

Documentation site for the Eleventy static site generator.
https://www.11ty.dev/
MIT License
471 stars 680 forks source link

Configuration Docs Do Not Reference `addTemplateFormats` API #1697

Open naomiyaki opened 4 months ago

naomiyaki commented 4 months ago

I wanted to add a couple of template formats to my build without effecting the defaults. Looks like there's a function that does just that, but it isn't in the docs anywhere!

https://github.com/11ty/11ty-website/blob/a5585afce586c9d9faed605a10fafab2feae5d70/src/docs/config.md?plain=1#L263

I couldn't find a precedent on this page for how an additional function would be added here, but if someone wants to provide guidance I'd be happy to write it up in a PR. Otherwise, go for it 💖

Snapstromegon commented 4 months ago

Hi @naomiyaki, seems like you're correct and this is not yet documented. Looking at the code (since I haven't used that function myself), it looks like it works like setTemplateFormats, but instead of replacing the existing template formats, it just adds them to the list.

So you'd call it as:

eleventyConfig.addTemplateFormats("myformat,other");
// or
eleventyConfig.addTemplateFormats(["myformat", "other"]);