11ty / eleventy

A simpler site generator. Transforms a directory of templates (of varying types) into HTML.

Home Page:https://www.11ty.dev/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

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

ahmadnassri opened this issue · comments

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

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

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

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?

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