Something went wrong. Try again.
Migrating content using the Ghost API to Offprint / Standard Site on atproto
Something went wrong. Try again.
123456789101112131415161718192021222324252627282930313233343536import { readFile, writeFile } from 'node:fs/promises';import type { AssetState } from './assets.js';
export interface PostState { ghostSlug: string; ghostTitle: string; documentUri?: string; documentCid?: string; articleUri?: string; articleCid?: string;}
export interface AppState { publicationAtUri?: string; accountDid?: string; assets?: Record<string, AssetState>; posts: Record<string, PostState>;}
export async function loadState(path: string): Promise<AppState> { try { const raw = await readFile(path, 'utf-8'); const parsed = JSON.parse(raw) as AppState; return Object.assign({ posts: {} }, parsed); } catch (err: any) { if (err?.code === 'ENOENT') { return { posts: {} }; } throw err; }}
export async function saveState(path: string, state: AppState): Promise<void> { await writeFile(path, JSON.stringify(state, null, 2), 'utf-8');}