UNPKG

alinea

Version:
58 lines (56 loc) 1.28 kB
import "../chunks/chunk-NZLE2WMY.js"; // src/core/EntryRecord.ts var EntryRecord; ((EntryRecord2) => { EntryRecord2.id = "_id"; EntryRecord2.type = "_type"; EntryRecord2.index = "_index"; EntryRecord2.root = "_root"; EntryRecord2.seeded = "_seeded"; })(EntryRecord || (EntryRecord = {})); function parseRecord(record) { const { [EntryRecord.id]: id, [EntryRecord.type]: type, [EntryRecord.index]: index, _i18nId: i18nId, [EntryRecord.root]: root, [EntryRecord.seeded]: seeded, ...data } = record; return { meta: { id: i18nId ?? id, type, index, root, seeded }, data, v0Id: typeof i18nId === "string" ? id : void 0 }; } function createRecord(entry, status) { const { path = entry.path, title = entry.title, ...data } = entry.data; const id = entry.id; const meta = { [EntryRecord.id]: id, [EntryRecord.type]: entry.type, [EntryRecord.index]: entry.index }; if (entry.seeded) meta[EntryRecord.seeded] = entry.seeded; if (!entry.parentId) meta[EntryRecord.root] = entry.root; const result = { ...meta, title, path, ...data }; if (status !== "draft") delete result.path; return result; } export { EntryRecord, createRecord, parseRecord };