import type { Context } from "koa"; import { button } from "src/back/elements/button.js"; import { tempstream } from "tempstream"; import type { FlatTemplatable } from "tempstream"; import { breadcrumbs } from "./breadcrumbs.js"; import { insert_nbsp } from "@sealcode/jdd"; export async function default_navbar(ctx: Context): Promise { const { items: navbar_items } = await ctx.$app.collections["navbar-links"] .list(ctx.$context) .fetch(); const linkData = navbar_items.map((e) => ({ text: e.get("label"), url: e.get("href"), })); const linksHTML = linkData .map( (link) => /* HTML */ tempstream`
  • ${button({ text: insert_nbsp(link.text || ""), href: link.url || "", variant: "accent1", disabled: link.url == new URL(ctx.url, "https://a.com").pathname, // checking if it's the current path we're looking at })}
  • ` ) .join("\n"); return tempstream /* HTML */ ` ${breadcrumbs(ctx)} `; }