Add tests for backend asset handling and frontend boot sequence, remove outdated MOTD script, and add icons.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
0ad5b5f44f
commit
7937879ace
34 files changed
+613
-116
No files matched your search
@@ -1,5 +1,7 @@
|
||||
import { existsSync, readdirSync, readFileSync } from 'node:fs';
|
||||
import { readFile } from 'node:fs/promises';
|
||||
import { extname, join, relative, sep } from 'node:path';
|
||||
import type { Font } from '@homepage/indexer';
|
||||
|
||||
export type Asset = {
|
||||
body: Buffer;
|
||||
@@ -50,3 +52,24 @@ export function loadAssets(directory: string): Map<string, Asset>
|
||||
if (index) assets.set('/', index);
|
||||
return assets;
|
||||
}
|
||||
|
||||
const FONT = /^\/assets\/jetbrains-mono-latin-(400|700)-normal-[^/]+\.woff2$/;
|
||||
|
||||
/** The Latin JetBrains Mono files of the frontend, so the static pages use the same font. */
|
||||
export function siteFonts(assets: Map<string, Asset>): Font[]
|
||||
{
|
||||
return [...assets.keys()].flatMap((path) =>
|
||||
{
|
||||
const match = FONT.exec(path);
|
||||
return match ? [{ url: path, weight: Number(match[1]) }] : [];
|
||||
});
|
||||
}
|
||||
|
||||
/** The built in theme followed by the optional override, whose rules win because they come later. */
|
||||
export async function readTheme(base: Buffer | undefined, overrideFile: string): Promise<Buffer | undefined>
|
||||
{
|
||||
if (!base) return undefined;
|
||||
|
||||
const override = await readFile(overrideFile).catch(() => undefined);
|
||||
return override ? Buffer.concat([base, Buffer.from('\n'), override]) : base;
|
||||
}
|
||||
Reference in new issue
Block a user