There’s an example of configuring a custom JavaScript format for frontmatter in the official demos. It adds functionality that is fairly similar to the component scripts in Astro.
It strikes me as something that might be nice to add to the pre-configured frontmatter formats that are shipped with Eleventy. But I have a couple of reservations as well…
First, based on the demo, it looks like it does add a dependency to core: node-retrieve-globals.
Second, there’s already the js format which allows you to specify frontmatter as a single JavaScript object. It’s not exactly the same as the javascript format in the demo, but it’s similar enough that I can imagine the difference being confusing. I’m not sure why a person might expect that js lets you define a single objects and javascript lets you write a script where all of the variable are exported to the template context.
Still, it’s not hard for me to imagine that this would be useful to people. I know a lot of people like the component scripts in Astro.
There’s an example of configuring a custom JavaScript format for frontmatter in the official demos. It adds functionality that is fairly similar to the component scripts in Astro.
It strikes me as something that might be nice to add to the pre-configured frontmatter formats that are shipped with Eleventy. But I have a couple of reservations as well…
First, based on the demo, it looks like it does add a dependency to core:
node-retrieve-globals.Second, there’s already the
jsformat which allows you to specify frontmatter as a single JavaScript object. It’s not exactly the same as thejavascriptformat in the demo, but it’s similar enough that I can imagine the difference being confusing. I’m not sure why a person might expect thatjslets you define a single objects andjavascriptlets you write a script where all of the variable are exported to the template context.Still, it’s not hard for me to imagine that this would be useful to people. I know a lot of people like the component scripts in Astro.