This repo is an example of using 11ty and Lit together.
Dev mode:
npm i && npm run dev
Prod mode:
npm i && npm start
11ty is a static site builder. Lit is a library that makes it easy to build Web Components. In this example, we combine the two so that you can sprinkle interactivity in a static site with Lit. We also use 11ty islands to make it easy to SSR your components and control how they are hydrated to provide an "island of interactivity".
This directory holds your 11ty templates. See the 11ty docs for more info.
This is for templates global to the 11ty templating system. Here we have a default.html
layout and a layouts
directory for layouts that are specific to a page or set of pages.
Make sure to include default.html
in your layouts and in your 11ty json
config files or simply extend them in nunjucks.
This holds your css files. Later, you may want to minify these.
These hold your fonts and images. They are empty right now, but they will be copied over to the dist
directory.
Most of these are for templating in 11ty. See the 11ty docs for more info. If you'd like to hook into the 11ty data system you may want to add a _data
directory and consult the 11ty docs.
This directory holds your Lit components. If you add a component here, to hook it up to SSR, add it to the src/ssr.ts
file and make sure to add it to tsEntrypoints
in esbuild.config.mjs
to make sure it's included in the bundler. If you don't want to SSR a component, you can add it to the appropriate file in src/pages/<your page name>.ts
;
This is a place to put logic for individual pages. If you want to add a component to a page, you can import it here and just use it in your templates. These files are automatically added to the build.
This loads the files onto the server for Server-side rendering. 11ty will then server-side render any components on the page.
This creates your bundles. It uses esbuild to bundle your components and your pages. You can add more entrypoints here if you want to add more entrypoints for hydration. The output of this will then be copied over to 11ty's appropriate output directory into the /js
directory. e.g. dev mode will output _dev/js/
and prod mode will output _prod/js/
.
This is the configuration file for 11ty. Please consult the docs.
This directory includes some files that modularize and organize the 11ty config file so that it does not become a giant mess of a file.