KiwiKilian/eleventy-plugin-og-image

Feature request: ignore frontmatter

edwardhorsford opened this issue ยท 6 comments

Firstly, thank you for producing this plugin.

My request is for the plugin to ignore any frontmatter it comes across. At the moment, it's unhandled and gets rendered in to the final image.

Background:
I found testing the rendering to be a bit cumbersome - as I often wanted to directly edit the styles in the browser. To get around this, I've set up Eleventy to render the template as a normal page. So the same template is used to render a page for development, and for the opengraph plugin. I've tried using Frontmatter to set some testing data, assuming it wouldn't get used by the plugin. However it still gets rendered.

I can obviously work around this, but feel it would be good for the plugin to either make use of front-matter, or disregard it.

To add, my workaround is to test for the page object - which is available when Eleventy is rendering the page, and not available when rendered under the plugin. So if it's available, I can set some default values.

Thanks for reporting the issue about frontmatter. I will see if this can be fixed.

Regarding your workaround this will not work from 3.2.0 onwards. I've recently implemented the population of the page object during OG rendering in #211.

@KiwiKilian Actually it was useful that the page object wasn't present - as I can have eleventy render it with some defaults if it is, and without the defaults when this plugin renders it.

I'm happy if it does get included, but I'd then request the plugin expose some data so the template can know if it's being rendered by the plugin. Perhaps ogPlugin: true or something?

๐ŸŽ‰ This issue has been resolved in version 3.2.0-beta.4 ๐ŸŽ‰

The release is available on:

Your semantic-release bot ๐Ÿ“ฆ๐Ÿš€

The plugin uses the internal functionality of the official Render Plugin. Which actually doesn't support front matter, so feel free to upvote in 11ty/eleventy#2712.

From my point of view there are enough other possibilities to add data and I don't think it's in the realm of this plugin to strip away the front matter. But I do understand the need to determine if the rendering is initiated by the plugin. Therefore I've added a eleventyPluginOgImage data key with some options for such detection.

๐ŸŽ‰ This issue has been resolved in version 4.0.0 ๐ŸŽ‰

The release is available on:

Your semantic-release bot ๐Ÿ“ฆ๐Ÿš€