Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Set frontmatter from within component's <script> tag #45

Closed
georgedoescode opened this issue Jan 19, 2023 · 4 comments
Closed

Set frontmatter from within component's <script> tag #45

georgedoescode opened this issue Jan 19, 2023 · 4 comments
Labels
education enhancement New feature or request

Comments

@georgedoescode
Copy link

We can currently update frontmatter within a .webc page like this:

---js
{
  layout: "my-layout.webc",
  title: "My page title",
  currentDate: function() {
    // You can have a JavaScript function here!
    return (new Date()).toLocaleString();
  }
}
---

It would be great if we could also do this within a component's <script> tag!

@zachleat
Copy link
Member

Just for me, this is useful to set eleventy configuration properties to the data cascade (permalink, pagination, etc):

https://www.11ty.dev/docs/data-configuration/

Marginally related to 11ty/webc#109

@zachleat
Copy link
Member

@zachleat
Copy link
Member

https://github.com/11ty/demo-eleventy-js-front-matter has the demo of this in action!

@zachleat zachleat added education enhancement New feature or request labels Feb 21, 2023
@zachleat
Copy link
Member

https://www.11ty.dev/docs/data-frontmatter-customize/#example-use-javascript-in-your-front-matter is the new home on the docs. I think we’ll attempt to roll with this for a bit and see if it’s sufficient before we go forward with a special <script> in WebC to populate the data cascade

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
education enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants