import { escape } from "../../../deps/std.ts"; import { getPath } from "../../utils/path.ts"; import { prepareField } from "../../utils/data.ts"; import breadcrumb from "../breadcrumb.ts"; import type Collection from "../../collection.ts"; import type Document from "../../document.ts"; import type { CMSContent, Version } from "../../../types.ts"; interface Props { options: CMSContent; collection: Collection; document: Document; version?: Version; } export default async function template( { options, collection, document, version }: Props, ) { const data = await document.read(); const fields = await Promise.all(document.fields.map(async (field) => ` <${field.tag} data-nameprefix="changes" data-value="${escape(JSON.stringify(data[field.name] ?? null))}" data-field="${escape(JSON.stringify(await prepareField(field)))}" > `)); const { basePath } = options; return ` ${ breadcrumb(options, version, [ collection.name, getPath(basePath, "collection", collection.name), ], "Editing file") }

Editing file

${fields.join("")}
`; }