Something went wrong. Try again.
a tool for shared writing and social publishing
Something went wrong. Try again.
12345678910111213141516171819202122232425262728293031323334353637383940import { PubLeafletPublicationPage } from "lexicons/api";
import type { Fact } from "src/replicache";import type { Attribute } from "src/replicache/attributes";import { processBlocksToPages, type ProcessBlocksToPagesHooks,} from "src/utils/factsToPagesRecord";
export async function leafletToPublicationPageRecord(opts: { facts: Fact<Attribute>[]; root_entity: string; // Set when the facts hold a whole draft leaflet rather than one page's. start_page?: string; publication_uri: string; path: string; title?: string; publishedAt?: string; hooks: ProcessBlocksToPagesHooks;}): Promise<PubLeafletPublicationPage.Record> { const { pages } = await processBlocksToPages({ facts: opts.facts, root_entity: opts.root_entity, start_page: opts.start_page, hooks: opts.hooks, });
return { $type: "pub.leaflet.publicationPage", publication: opts.publication_uri, path: opts.path, ...(opts.title !== undefined && { title: opts.title }), publishedAt: opts.publishedAt ?? new Date().toISOString(), content: { $type: "pub.leaflet.content", pages, }, };}