Currently doesn't support client-side Javascript, but who needs that anyway! 😅
This starter project uses Svelte.js as a server-side templating engine for Eleventy. Svelte allows us to leverage SFC's (single file components) to build (extremely) static content-only websites. Storybook is used as a component workbench that allows you to work on individual components in isolation.
This example features a few layouts to showcase a homepage, a blog index and a blog post.
This project tries to stick to as many Eleventy and Storybook defaults as possible.
_includes/svelte.11ty.js
layout via this hack in _data/layout.js
.svelte.11ty.js
layout does two things:_includes/base.njk
,
where the Svelte HTML is injected into the <body>
and the CSS is inlined in the <head>
.npm run lint
command)
because if you care enough about HTML to use a template like this, you probably want it to look good._includes/styles/global.css
to provide some consistant typography (from Typebase.less ). Since Svelte
localizes all CSS by default, you may want a globl CSS file for variables or typography or stuff like that._layout
key to the front-matter of a file
e.g. a file with _layout: Post.svelte
will be rendered with the following layout _includes/layouts/Post.svelte
.Huge shout-outs go to Marcus oberlehner for his Preact + Eleventy post, on which this approach is largely based.