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