Monorepo for wisp.place. A static site hosting service built on top of the AT Protocol.
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

at main 32 lines 867 B view raw
1import { existsSync, readFileSync, writeFileSync } from 'fs'; 2import { join } from 'path'; 3 4export interface SiteMetadata { 5 recordCid: string; 6 fileCids: Record<string, string>; // path -> blob CID 7 lastSync: number; // Unix timestamp 8} 9 10const METADATA_FILE = '.wisp-metadata.json'; 11 12export function getMetadataPath(siteDir: string): string { 13 return join(siteDir, METADATA_FILE); 14} 15 16export function loadMetadata(siteDir: string): SiteMetadata | null { 17 const path = getMetadataPath(siteDir); 18 if (!existsSync(path)) { 19 return null; 20 } 21 try { 22 const content = readFileSync(path, 'utf-8'); 23 return JSON.parse(content) as SiteMetadata; 24 } catch { 25 return null; 26 } 27} 28 29export function saveMetadata(siteDir: string, metadata: SiteMetadata): void { 30 const path = getMetadataPath(siteDir); 31 writeFileSync(path, JSON.stringify(metadata, null, 2)); 32}