alinea
Version:
Headless git-based CMS
58 lines (56 loc) • 1.28 kB
JavaScript
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 {
[]: id,
[]: type,
[]: index,
_i18nId: i18nId,
[]: root,
[]: 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 = {
[]: id,
[]: entry.type,
[]: 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
};