{"id":15016519,"url":"https://github.com/5t3ph/11ty-web-component-generator","last_synced_at":"2025-09-10T14:45:44.397Z","repository":{"id":84151508,"uuid":"303895742","full_name":"5t3ph/11ty-web-component-generator","owner":"5t3ph","description":"Use the power of 11ty to generate web components (custom elements).","archived":false,"fork":false,"pushed_at":"2020-10-23T00:37:05.000Z","size":41,"stargazers_count":55,"open_issues_count":0,"forks_count":6,"subscribers_count":4,"default_branch":"main","last_synced_at":"2025-07-05T01:41:19.734Z","etag":null,"topics":["11ty","11ty-template","custom-elements","web-component-starter","web-components"],"latest_commit_sha":null,"homepage":"https://11ty-web-component-generator.netlify.app/","language":"HTML","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/5t3ph.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"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-10-14T03:47:05.000Z","updated_at":"2024-02-11T19:46:34.000Z","dependencies_parsed_at":null,"dependency_job_id":"609c6ce1-a236-4b2a-b81b-4572200276dd","html_url":"https://github.com/5t3ph/11ty-web-component-generator","commit_stats":{"total_commits":2,"total_committers":1,"mean_commits":2.0,"dds":0.0,"last_synced_commit":"0bdbc0668fe07443c6f53370b81fd1f8229f690a"},"previous_names":[],"tags_count":0,"template":true,"template_full_name":null,"purl":"pkg:github/5t3ph/11ty-web-component-generator","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/5t3ph%2F11ty-web-component-generator","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/5t3ph%2F11ty-web-component-generator/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/5t3ph%2F11ty-web-component-generator/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/5t3ph%2F11ty-web-component-generator/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/5t3ph","download_url":"https://codeload.github.com/5t3ph/11ty-web-component-generator/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/5t3ph%2F11ty-web-component-generator/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":274478379,"owners_count":25293072,"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","status":"online","status_checked_at":"2025-09-10T02:00:12.551Z","response_time":83,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":["11ty","11ty-template","custom-elements","web-component-starter","web-components"],"created_at":"2024-09-24T19:49:01.152Z","updated_at":"2025-09-10T14:45:44.346Z","avatar_url":"https://github.com/5t3ph.png","language":"HTML","funding_links":[],"categories":["HTML"],"sub_categories":[],"readme":"![](https://repository-images.githubusercontent.com/303895742/105a8780-0da7-11eb-8c1f-7ca10b6e3713)\n\n# ⚡️ 11ty Web Component Generator\n\n\u003e [View the demo Hello World component \u003e](https://11ty-web-component-generator.netlify.app/)\n\n## Using the Generator\n\n[Eleventy (11ty) is a static site generator](https://www.11ty.dev/docs/) that makes it possible to mix templating languages. More importantly to this generator is that we can customize the _output file type_ and composite a file from _includes_.\n\nThe web components are generated within a Nunjucks (`.njk`) template that outputs the final `.js` file.\n\nThis generator works with the inherent features of Eleventy, including that it expects templates and template partials to be placed in `_includes`.\n\nThis leads to the following file structure to create a web component with styles and additional scripting.\n\nFirst, create the component template file in `src/components/[component-name].njk`. _It is important to kebab-case the file name_\n\nThen within `_includes/components/` create:\n\n```bash\n[component-name]/\n  script.js\n  style.css\n```\n\nKeep the names of `script.js` and `style.css` so that the `_includes/component.njk` template can successfully include their contents to generate the web component.\n\n## Using a Generated Web Component\n\nThe final web component will be output within `public/components/[component-name].js` and is ready to be included in another project such as:\n\n```html\n\u003cscript type=\"module\" src=\"path/to/component-name.js\"\u003e\u003c/script\u003e\n\u003ccomponent-name\u003e\u003c/component-name\u003e\n```\n\n### Display a Component Within This Generator Project\n\nCreate additional pages in this project directly within `src` as Nunjuck (`.njk`) files and add the following frontmatter in addition to any HTML and Nunjuck template tags.\n\n```md\ntitle: Page Title\ncomponent: component-name\n```\n\nThen the `page.njk` template will use the `component` value to include the relative path to the web component script.\n\n## Project Scripts\n\n- **`npm start`** - run Eleventy on localhost with included Browsersync hot-reload\n- **`npm run build`** - run only Eleventy for creating a production build of the generator project\n\n## Web Component Resources\n\nFirst a little disclaimer - I am brand new to web components, so I know this doesn't cover all the things you may want to do, or the best way to generically composite them. Submit a PR if you want to help extend this generator!\n\nHere are some resources that helped me put together [my first web component](https://github.com/5t3ph/css-webring):\n\n- [Encapsulating Style and Structure with Shadow DOM](https://css-tricks.com/encapsulating-style-and-structure-with-shadow-dom/)\n- [Using custom elements](https://developer.mozilla.org/en-US/docs/Web/Web_Components/Using_custom_elements#Working_through_some_simple_examples)\n- [Creating a Custom Element from Scratch](https://css-tricks.com/creating-a-custom-element-from-scratch/)\n- [Custom Elements v1: Reusable Web Components](https://developers.google.com/web/fundamentals/web-components/customelements)\n\n## 11ty Resources\n\nI'm very fond of 11ty, so here's a list of my other resources:\n\n**Learn to build an 11ty site in 20 mins** with my [egghead video course](https://5t3ph.dev/learn-11ty) and see how to add a blog and custom data.\n\n**Add auto-generated social media images** by following [my tutorial](https://dev.to/5t3ph/automated-social-sharing-images-with-puppeteer-11ty-and-netlify-22ln)\n\n**Explore advanced setup of custom data** through my [tutorial on building a community site](https://css-tricks.com/a-community-driven-site-with-eleventy-building-the-site/)\n\n**For a full-featured starter** check out my [11ty Netlify Jumpstart](https://11ty-netlify-jumpstart.netlify.app/) (also works for hosts other than Netlify).\n\n**For a featureless Sass starter** grab the template for my [11ty Sass Skeleton](https://github.com/5t3ph/11ty-sass-skeleton)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2F5t3ph%2F11ty-web-component-generator","html_url":"https://awesome.ecosyste.ms/projects/github.com%2F5t3ph%2F11ty-web-component-generator","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2F5t3ph%2F11ty-web-component-generator/lists"}