breathe-easy-events / breathe-easy.uk

https://breathe-easy.uk/
0 stars 0 forks source link

breathe-easy.uk

Based on 11tsy-starter

Development

The approach with this starter is to treat Eleventy layouts as wrappers for stateless UI components so they can be easily tested and reasoned about. The contract between these components and Eleventy can be expressed as types in eleventy.ts.

Although JSX is used for the templates there is no connection to react and these components will be rendered to static HTML in the build process with no hydration.

Prerequisites

Setup & install instructions

Build

Testing

You can use Vitest and Testing Library to make assertions about how your components render. See this example. Currently there is no test server delivering assets so things like links to CSS files will raise warnings if you test a full layout.

Tests are co-located with their source.

src
├── _components
│   ├── Heading.test.tsx
│   └── Heading.tsx

Cache Busting

As static sites are often hosted on CDNs it is a good idea to hash assets so you don't get outdated CSS, etc loading after an update has been made. This is currently handles through an Eleventy transform and can be triggered by adding data-asset-hash attribute to an element but the href/src needs to be pointing to the root. For example.

<link data-asset-hash href="https://github.com/breathe-easy-events/breathe-easy.uk/blob/main/css/styles.css" rel="stylesheet" />

Code & configs

This site is built with Elm and bundled by Vite

What it's for

baseURL

the BASE_URL environment variable is set by doing.

BASE_URL="https://breathe-easy.uk" npm start

This will then be accessed as globalData in templates under data.baseURL

Content

Currently the only content is ./src/index.md but Eleventy's documentation on templates and data give many interesting examples of how to source and organize content. If you'd like a quick intro to get the feel for this check out this Build an 11ty Site in 3 Minutes video.

pages

Pages accept the following front-matter

layout: "which template to use"
title: "for pages h1 and opengraph metadata"
description: "[optional] for opengraph metadata"
emoji: "[optional] for insertion to favicon"
socialImage: "[optional] for opengraph metadata (external link or path to file)"
socialImageAlt: "[optional] alt text describing social preview image, if you do not include this then it will fallback to the default image / alt"