import { labelify } from "../../utils/string.ts";
import { getPath, normalizePath } from "../../utils/path.ts";
import breadcrumb from "../breadcrumb.ts";
import createTree from "../tree.ts";
import type { Tree } from "../tree.ts";
import type Upload from "../../upload.ts";
import type { CMSContent, Version } from "../../../types.ts";
interface Props {
options: CMSContent;
upload: Upload;
version?: Version;
}
export default async function template(
{ options, upload, version }: Props,
) {
const { publicPath, name } = upload;
const files = await Array.fromAsync(upload);
const tree = createTree(files);
const content = folder({ options, collection: name, tree, publicPath })
.trim();
return `
${breadcrumb(options, version, name)}
${upload.description}${labelify(name)}
${
upload.description
? `
No results
' } `; } interface FolderProps { options: CMSContent; collection: string; publicPath: string; tree: Tree; } function folder({ options, collection, publicPath, tree }: FolderProps) { const folders: string[] = Array.from(tree.folders?.entries() || []) .map(([name, subTree]) => `