{"id":15059310,"url":"https://github.com/jdvivar/eleventy-plugin-add-web-component-definitions","last_synced_at":"2025-04-10T13:12:55.598Z","repository":{"id":42513727,"uuid":"277187669","full_name":"jdvivar/eleventy-plugin-add-web-component-definitions","owner":"jdvivar","description":"This Eleventy plugin will add Web Component definitions automatically by reading custom tags from HTML pages.","archived":false,"fork":false,"pushed_at":"2023-07-18T22:45:21.000Z","size":1926,"stargazers_count":20,"open_issues_count":3,"forks_count":2,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-24T11:56:53.448Z","etag":null,"topics":["eleventy","eleventy-plugin","static-site-generator","web-component","web-components"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/jdvivar.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2020-07-04T21:27:07.000Z","updated_at":"2024-04-20T19:27:44.000Z","dependencies_parsed_at":"2024-06-19T05:31:11.855Z","dependency_job_id":null,"html_url":"https://github.com/jdvivar/eleventy-plugin-add-web-component-definitions","commit_stats":{"total_commits":81,"total_committers":5,"mean_commits":16.2,"dds":0.308641975308642,"last_synced_commit":"fbeb93a86b60565a9128d881029e83bbfc0aa459"},"previous_names":[],"tags_count":21,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jdvivar%2Feleventy-plugin-add-web-component-definitions","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jdvivar%2Feleventy-plugin-add-web-component-definitions/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jdvivar%2Feleventy-plugin-add-web-component-definitions/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jdvivar%2Feleventy-plugin-add-web-component-definitions/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jdvivar","download_url":"https://codeload.github.com/jdvivar/eleventy-plugin-add-web-component-definitions/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247774215,"owners_count":20993725,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["eleventy","eleventy-plugin","static-site-generator","web-component","web-components"],"created_at":"2024-09-24T22:41:03.578Z","updated_at":"2025-04-10T13:12:55.363Z","avatar_url":"https://github.com/jdvivar.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# eleventy-plugin-add-web-component-definitions\n\nThis plugin will automatically add Web Component definitions to your HTML pages\n\nGiven a page with this structure:\n```html\n\u003chtml\u003e\n  \u003cbody\u003e\n    \u003ccustom-tag\u003e\u003c/custom-tag\u003e\n  \u003c/body\u003e\n\u003c/html\u003e\n```\n\nThe plugin will transform it, with default options, into:\n```html\n\u003chtml\u003e\n  \u003cbody\u003e\n    \u003ccustom-tag\u003e\u003c/custom-tag\u003e\n    \u003cscript type=\"module\" src=\"/js/components/custom-tag/custom-tag.js\"\u003e\u003c/script\u003e\n  \u003c/body\u003e\n\u003c/html\u003e\n```\n\n## How to use\n\nFirst, install it:\n```bash\nnpm install --save-dev eleventy-plugin-add-web-component-definitions\n```\n\nThen, in your `.eleventy.js` configuration file, add:\n```js\n// Together with your other imports\nconst addWebComponentDefinitions = require('eleventy-plugin-add-web-component-definitions')\n\nmodule.exports = function(eleventyConfig) {\n\n  // Inside your eleventy configuration function\n  eleventyConfig.addPlugin(addWebComponentDefinitions)\n}\n```\n\n### Options\n\n| name           |  type      | default          | description         |\n|----------------|------------|------------------|---------------------|\n| `path`         | `Function or String` | ``function (tag) { return `/js/components/${tag}/${tag}.js\\` `` | Path where your components are published |\n| `specifiers` | `Object` | {}  | Input with this format `{\u003ccustom-tag\u003e: \u003cFunction or String\u003e}` to override a specific tag path, see below an example |\n| `position`     | `String`   | `beforeend`      | Position where the script tag will be put in regards to the `body` element, the other options being `afterbegin` |\n| `verbose`      | `Boolean`  | `false`          | It will console log each step, for debug purposes |\n| `quiet`        | `Boolean`  | `false`          | It won't console log anything. By default, a log of each Web Component definition is log out with this format: `[add-web-component-definitions] Adding definition for tag: custom-tag`|\n| `singleScript` | `Boolean` | `false`           | If true, only one script with import statements will be output: `\u003cscript type=\"module\"\u003eimport \"js/components/custom-tag.js;\u003c/script\u003e` |\n| `modulePreload` | `Boolean` | `false`           | If true (and `singleScript` is `false`), it will add modulepreload links to the head of the document using the `path` function |\n\n### Example\n\nSay your components live in `/components/` with no subfolders for tags and that your published website lives in a sub-folder of the domain (such as what happens in Github Pages or Gitlab Pages), you can do this:\n\n```js\neleventyConfig.addPlugin(addWebComponentDefinitions, {\n  path: tag =\u003e project.environment === 'production'\n      ? `/my-project/components/${tag}.js`\n      : `/components/${tag}.js`\n  }\n)\n```\nYou can also specify a unique path for any custom-tag, which overrides the path configuration:\n\n```js\neleventyConfig.addPlugin(addWebComponentDefinitions, {\n  specifiers: {\n    'custom-tag-one': tag =\u003e project.environment === 'production'\n      ? `/alpha-project/components/${tag}.js`\n      : `/components/${tag}.js`,\n    'custom-tag-two': 'my-module'\n  }\n)\n```\n\nFor a verbose output, do this:\n```js\neleventyConfig.addPlugin(addWebComponentDefinitions, { verbose: true })\n```\n\n### Demo\n\nPlease find a demo at `/demo`, to see it working live just:\n```sh\nnpm run demo\n```\n\n### Questions? Feature requests?\n\nPlease [open an issue](https://github.com/jdvivar/eleventy-plugin-add-web-component-definitions/issues/new) and I'll get back to you ASAP!","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjdvivar%2Feleventy-plugin-add-web-component-definitions","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjdvivar%2Feleventy-plugin-add-web-component-definitions","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjdvivar%2Feleventy-plugin-add-web-component-definitions/lists"}