11ty / eleventy

A simpler site generator. Transforms a directory of templates (of varying types) into HTML.
https://www.11ty.dev/
MIT License
17.19k stars 494 forks source link

Can’t alias a non-core template syntax (one added via plugin or addExtension) #2827

Open ahmadnassri opened 1 year ago

ahmadnassri commented 1 year ago

Operating system

Linux / Debian

Eleventy

2.0.0

Describe the bug

attempting to use .html file extension for .webc files with the new aliasing feature in 2.0

config.addExtension("11ty.html", {
  key: "11ty.webc"
})

no success.

Reproduction steps

  1. config.addExtension("11ty.html", { key: "11ty.webc" })
  2. rename an existing .webc component to .html
  3. npx @11ty/eleventy --serve
  4. component is not rendered

Expected behavior

aliasing .webc components should work across all files (components / pages / layouts / etc ...).

Reproduction URL

No response

Screenshots

No response

zachleat commented 1 year ago

11ty.webc should probably be just webc there, if you're using the existing eleventy WebC plugin

ahmadnassri commented 1 year ago

will give that a shot, worth noting i followed the docs example https://www.11ty.dev/docs/languages/custom/#aliasing-an-existing-template-language

ahmadnassri commented 1 year ago

changing key: '11ty.webc' to key: 'webc' resulted in the following

[11ty] Problem writing Eleventy templates: (more in DEBUG output)
[11ty] An attempt was made to override the *already* overridden "webc" template syntax via the `addExtension` configuration API. A maximum of one override is currently supported. If you’re trying to add an alias to an existing syntax, make sure only the `key` property is present in the addExtension options object. (via Error)

the following however, worked:

config.addExtension(['webc'], {
  key: 'html'
})

I'm confused by this API ... shouldn't the first parameter of the addExtension call be an array of aliases to make to the one declared in key?

seems like it's behaving backwards? or am I mis-reading the docs?

zachleat commented 7 months ago

Looks like this feature only works with core template syntaxes: md, html, njk, liquid, and 11ty.js. Gonna file it as a bug.