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

Dynamic permalinks and WebC #27

Closed
voxpelli opened this issue Nov 14, 2022 · 4 comments
Closed

Dynamic permalinks and WebC #27

voxpelli opened this issue Nov 14, 2022 · 4 comments
Assignees
Labels
bug Something isn't working

Comments

@voxpelli
Copy link

When using liquid I had a news.11tydata.json containing:

{
  "layout": "layouts/post",
  "tags": ["news"],
  "permalink": "{{ page.date | date: '%Y/%m' }}/{{ title | slug }}/index.html"
}

When using WebC I should instead be using WebC for that? Feels like a challenge? I would preferably use eg. liquid for my permalinks and only WebC for my actual HTML

You may use data variables here (and template syntax, too). These will be parsed with the current template’s rendering engine.

This plugin could provide a custom behavior by setting permalink in compilerOptions to a function or false:

compileOptions: {
cache: true,
getCacheKey: function(contents, inputPath) {
// if global components change, recompile!
return contents + inputPath + componentsMapKey;
}
},

I think it should done of:

  1. Have an example of a dynamic permalink in WebC
  2. Provide an alternative renderer for permalinks
  3. Disable permalink link rendering if its not feasible with WebC
@voxpelli
Copy link
Author

Some progress on 1.:

  "permalink": "<div webc:nokeep @text='`subdir/${slugify(title)}/index.html`'></div>"

@zachleat
Copy link
Member

Yeahhhhhh… this is a hefty bug—sorry. But easily fixable. I just need to map the dynamic attribute JavaScript parsing code to the Eleventy Custom template permalink stuff: https://www.11ty.dev/docs/languages/custom/#compileoptions.permalink-to-override-permalink-compilation

@zachleat zachleat added the bug Something isn't working label Nov 15, 2022
@zachleat zachleat self-assigned this Nov 15, 2022
@zachleat zachleat added this to the Eleventy WebC Plugin v0.7.0 milestone Nov 15, 2022
@zachleat
Copy link
Member

This will ship with Eleventy WebC 0.7.0

@rijkvanzanten
Copy link

Glad to see my workaround for #36 is no longer needed 😄

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants