Build Awesome (11ty)
Build Awesome (11ty) is relatively unopinionated, so there are several ways to add Web Awesome — the simplest is via npm, which your project most likely already uses.
Installation
To add Web Awesome to your Build Awesome site, install the package from npm.
npm install @awesome.me/webawesome
Usage
Copy the Assets
Web Awesome's assets must be available to the browser. Add addPassthroughCopy to your eleventy.config.js to copy them into your build output — create the file if you don't have one yet:
// eleventy.config.js const webawesomeDir = './node_modules/@awesome.me/webawesome'; export default async function (eleventyConfig) { eleventyConfig.addPassthroughCopy({ webawesomeDir: 'webawesome', }); } export const config = { markdownTemplateEngine: 'njk', dir: { input: 'pages', includes: '_includes', layouts: '_layouts', }, templateFormats: ['njk', 'md'], };
Load the Styles & Loader
Add the stylesheet and component loader to your layout's <head>:
<head> <link href="/webawesome/dist-cdn/styles/webawesome.css" rel="stylesheet"> <script type="module" src="/webawesome/dist-cdn/webawesome.loader.js"></script> </head>
Web Awesome is ready to use.
Want server-side rendering too?
Server-Side Rendering
With server-side rendering, your Web Awesome components render to HTML on the server, so pages display fully styled before client-side JavaScript loads. Learn more in the SSR docs.
To add SSR support to Build Awesome (11ty), follow the steps below.
Install the Plugin
Install the @lit-labs/eleventy-plugin-lit plugin from npm:
npm install @lit-labs/eleventy-plugin-lit
Register the Plugin
Once installed, register the plugin in your eleventy.config.js file.
// eleventy.config.js import litPlugin from '@lit-labs/eleventy-plugin-lit'; import * as fs from 'node:fs'; import * as path from 'node:path'; const webawesomeDir = './node_modules/@awesome.me/webawesome'; const webawesomeComponentsDir = path.join(webawesomeDir, 'dist', 'components'); const webawesomeComponents = fs.readdirSync(webawesomeComponentsDir).map(componentName => { return path.join(webawesomeComponentsDir, componentName, componentName + '.js'); }); export default async function (eleventyConfig) { eleventyConfig.addPlugin(litPlugin, { mode: 'worker', componentModules: webawesomeComponents, }); eleventyConfig.addPassthroughCopy({ webawesomeDir: 'webawesome', }); } export const config = { markdownTemplateEngine: 'njk', dir: { input: 'pages', includes: '_includes', layouts: '_layouts', }, templateFormats: ['njk', 'md'], };
Swap in the SSR Loader
Update your layout to use the SSR loader instead of the default loader:
<head> <link href="/webawesome/dist-cdn/styles/webawesome.css" rel="stylesheet"> <script type="module" src="/webawesome/dist-cdn/webawesome.ssr-loader.js"></script> </head>
See It in Action
Need an example of a complete Build Awesome (11ty) SSR project using Web Awesome?
A complete Build Awesome (11ty) SSR project using Web Awesome.
See the 11ty SSR example deployed and running.
Next Steps
Using Web Awesome with Build Awesome (11ty)?
Found a bug or have a suggestion? Help make things more awesome!