import type { Context } from "koa"; import { TempstreamJSX } from "tempstream"; import { get_breadcrumbs_from_path } from "../url-tree.js"; const arrow_width = 8; const arrow_height = 28; function arrow_tail() { return ( { /* HTML */ `` } ); } function arrow_head() { return ( { /* HTML */ `` } ); } export async function breadcrumbs(ctx: Context) { const breadcrumbs = await Promise.all( get_breadcrumbs_from_path(ctx.path).map(async (e, i, all) => { if (!e.actionName) { return ""; } const breadcrumbLabel = e.breadcrumbLabel?.({ ...ctx }); const breadcrumbLabelResult = await breadcrumbLabel; if (i == all.length - 1) { return {breadcrumbLabelResult || e.actionName}; } return ( <> {i !== 0 ? arrow_tail() : ""} {breadcrumbLabelResult || e.actionName} {arrow_head()} ); }) ); return ; }