Something went wrong. Try again.
Monorepo for wisp.place. A static site hosting service built on top of the AT Protocol. forked from nekomimi.pet/wisp.place-monorepo
Something went wrong. Try again.
867 B · 32 lines
TypeScript
at main
123456789101112131415161718192021222324252627282930313233import { existsSync, readFileSync, writeFileSync } from 'fs';import { join } from 'path';
export interface SiteMetadata { recordCid: string; fileCids: Record<string, string>; // path -> blob CID lastSync: number; // Unix timestamp}
const METADATA_FILE = '.wisp-metadata.json';
export function getMetadataPath(siteDir: string): string { return join(siteDir, METADATA_FILE);}
export function loadMetadata(siteDir: string): SiteMetadata | null { const path = getMetadataPath(siteDir); if (!existsSync(path)) { return null; } try { const content = readFileSync(path, 'utf-8'); return JSON.parse(content) as SiteMetadata; } catch { return null; }}
export function saveMetadata(siteDir: string, metadata: SiteMetadata): void { const path = getMetadataPath(siteDir); writeFileSync(path, JSON.stringify(metadata, null, 2));}