how does · unni-web
How does the Unni shared builder work?
Overview
shared/build.js is a zero-dependency Node script. It takes a site folder with
content fragments and wraps every page in one shared shell: header, nav, footer,
design tokens, analytics and Ko-fi links. A site never copies the shell.
Mechanics
shared/sites.jsonis the single source for site URLs, social links and analytics tokens.- A site provides
site.json(key, title, description, optional per-page metadata),src/**/*.html(the<main>content) andstyles/site.css. - The builder walks
src/, and for every.htmlfile:- looks up its title/description in
site.json.pages; - computes
{{BASE}}(./at the root,../one level down) so nested pages still find the stylesheets; - fills
{{ROOT_URL}},{{GAMES_URL}}, … and other placeholders; - inserts the page into
shared/layout/base.html.
- looks up its title/description in
- Non-HTML files under
src/are copied unchanged todist/(fonts, images, downloads). buildSite(dir, { content })lets a site render its own content first.unni-portfoliouses it to turndata/projects.jsoninto cards.
Example
sites/root/src/license/index.html becomes
sites/root/dist/license/index.html. Because it sits one level down, its
stylesheet links use ../styles/..., which the verifier checks by resolving
every href on disk.
Gotchas
- Placeholders are filled after content is inserted, so content may use site
URLs but must not contain accidental
{{SOMETHING}}text. - A site that brings its own full page shell (the migrated games site) sets
"mode": "static". The shared builder is bypassed and its own build copiessrc/todist/. - A site with its own framework (the Astro research site) sets
"mode": "astro"and uses its ownbuild.js; it still imports the shared header, footer, tokens and analytics. dist/is generated. Never edit it by hand.