mirror of
https://github.com/bitbaum/sites.git
synced 2026-12-05 02:46:59 +01:00
Reads Loki's sites / site_versions / site_domains with a SELECT-only role and renders the published version with @bitbaum/sitekit's SiteDocument and the site's theme (siteThemeCss + self-hosted faces). Answers: - <slug>.orangecat.ch and verified own domains → the published version - sites.orangecat.ch/<site id>/… → the preview version, never indexed - /_sites/ask → Caddy's on-demand TLS check, falling back to hirnli's - localhost:<port>/ → the deploy's health probe A row that does not parse is a 404 and a log line. sitekit installs from the kits commit until 0.8.0 is on npm. Step 3 of loki ADR-0001 (the sites platform). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
43 lines
1.2 KiB
TypeScript
43 lines
1.2 KiB
TypeScript
/**
|
|
* A row the engine cannot render becomes "no site" (and a log line), never a
|
|
* broken page: Loki validated it, but against the sitekit Loki had then.
|
|
*/
|
|
import { test } from 'node:test';
|
|
import assert from 'node:assert/strict';
|
|
import { toServedSite } from '../src/lib/site-data';
|
|
|
|
const SPEC = {
|
|
chrome: { name: 'Muster', tagline: 'Brot', footerNote: 'Test.' },
|
|
pages: [{ path: '', title: 'Start', sections: [{ kind: 'prose', paragraphs: ['Hallo.'] }] }],
|
|
};
|
|
const row = (over: Record<string, unknown> = {}) => ({
|
|
site_id: 's',
|
|
slug: 'muster',
|
|
noindex: true,
|
|
version_id: 'v',
|
|
n: 1,
|
|
spec: SPEC,
|
|
theme: null,
|
|
settings: {},
|
|
...over,
|
|
});
|
|
|
|
test('a valid row is served, with settings defaulted', () => {
|
|
const s = toServedSite(row());
|
|
assert.ok(s);
|
|
assert.equal(s.settings.lang, 'de-CH');
|
|
assert.equal(s.theme, null);
|
|
});
|
|
|
|
test('a row whose spec, theme or settings does not parse is not served', () => {
|
|
const quiet = console.error;
|
|
console.error = () => {};
|
|
try {
|
|
assert.equal(toServedSite(row({ spec: { ...SPEC, pages: [] } })), null);
|
|
assert.equal(toServedSite(row({ theme: { palette: {} } })), null);
|
|
assert.equal(toServedSite(row({ settings: { lang: 'German' } })), null);
|
|
} finally {
|
|
console.error = quiet;
|
|
}
|
|
});
|