import { labelify } from "../utils/string.ts"; import { getPath } from "../utils/path.ts"; import breadcrumb from "./breadcrumb.ts"; import type { CMSContent, SiteInfo, Versioning } from "../../types.ts"; import type Document from "../document.ts"; import type Collection from "../collection.ts"; import type Upload from "../upload.ts"; interface Props { options: CMSContent; collections: Record; documents: Record; uploads: Record; versioning?: Versioning; site: SiteInfo; } export default async function template( { options, collections, documents, uploads, versioning, site }: Props, ) { const { basePath } = options; const url = site.url ? `

${site.url} ↗

` : ""; return ` ${breadcrumb(options, await versioning?.current())}

${site.name}

${site.description ?? ""} ${url}
${versioning && await versions(options, versioning) || ""} `; } async function versions(options: CMSContent, versioning: Versioning) { return `

Available versions

    ${ (await Array.fromAsync(versioning)).map((version) => `
  • ${ version.isCurrent ? ` ${labelify(version.name)} ` : `
    ` } ${ !version.isProduction && `
    ` || "" }
  • `).join("") }
`; }