Appearance
Frontend components
The frontend directory is a separate Git repository containing components/, scripts/ and styles/. The checked-in components/components.json declares the supported names and which assets they use. Current component schemas are hero, accordion and lesson. The lesson component is a worked example for a lesson-style site, not a general visual editor.
For example, the checked-in descriptor declares an accordion with CSS and JavaScript:
json
{
"htmlContract": 2,
"components": {
"accordion": { "css": true, "js": true }
}
}A page invokes a component with a fenced component block containing YAML:
md
```component
name: hero
title: Learn at your own pace
description: Short lessons and clear explanations.
image:
src: ./images/road.jpg
alt: A road through the countryside
```Foliwake validates the block against its schema and emits semantic HTML. Site code styles and enhances that HTML with plain CSS and JavaScript. hero needs only CSS; accordion uses native <details> and has JavaScript enhancement. The loader imports components/accordion/accordion.js and calls its default init(root) function once for each rendered <section data-component="accordion">:
js
export default function init(root) {
const items = root.querySelector(':scope > [data-field="items"]');
// Enhance only this component root; keep the generated content readable.
}Element IDs on a page are the authors'. An ID an author writes ({#id} after a heading or an answer, section and slide IDs) is delivered as id="…" without a prefix, so any author can create an element with any ID. Browsers expose such elements as globals (window.config can be an author's <h2 id="config">). Site code must not read settings or state from window globals that a page element could shadow, and must not find its own elements by an ID an author could also write: select inside the component root (root.querySelector) or by data-* attributes.
Component stylesheets are linked in the page <head>: for every component a page uses that the descriptor declares with "css": true, the page shell adds <link rel="stylesheet" href="…/components/<name>/<name>.css" data-component-css="<name>">, so the block is styled before any JavaScript runs. A loader from this engine version on reuses that link and marks the component error if it fails to load; a frontend released with an older scripts/components.js adds its own second link until you release it again. With "css": false no stylesheet is linked or loaded.
You can change an existing component's JS/CSS in the frontend repository. The fenced components above (hero, accordion, lesson) have schemas built into the engine. For your own blocks you need no engine change: a folder components/<name>/ defines one, and pages use it as :::name … ::: (with authoring: blocks-v3 in site.yaml, or blocks-v2). The engine binds the content to the block's fields, reports content that does not fit, and generates components/components.json from the block folders when the site has none. How to write a block is on the SDK docs site: Write a block. foliwake create starts a project with blocks, and Block examples and Storybook shows how the engine renders their examples. A group of pages can also share a stylesheet, a script and a list of allowed blocks through an optional page template.
Follow Develop a frontend to use local sample content, hosted preview or live content with your working CSS and JavaScript. The guide covers configuration, authentication and automatic reload. For a live code change, commit the frontend repository and use code prepare and promote.
