Page MenuHomeSealhub

navbar.ts
No OneTemporary

navbar.ts

import type { BaseContext } from "koa";
import type { FlatTemplatable } from "tempstream";
import { SignInURL, LogoutURL, RulesCRUDURL } from "../urls.js";
export async function default_navbar(ctx: BaseContext): Promise<FlatTemplatable> {
const isLoggedIn = !!ctx.$context.session_id;
const linkData = isLoggedIn
? [
{ text: "Rules", url: RulesCRUDURL },
{ text: "Logout", url: LogoutURL, has_side_effects: true },
]
: [{ text: "Login", url: SignInURL }];
const linksHTML = linkData
.map((link) =>
link.url === new URL(ctx.url, "https://a.com").pathname
? `<li class="active"><span>${link.text}</span></li>`
: /* HTML */ `<li>
<a
href="${link.url}"
${link.has_side_effects ? `data-turbo="false"` : ""}
>${link.text}</a
>
</li>`
)
.join("\n");
return /* HTML */ ` <nav>
<a href="/" class="nav-logo">
<img
src="/assets/logo"
alt="${ctx.$app.manifest.name} - logo"
width="50"
height="50"
/>
${ctx.$app.manifest.name}
</a>
<ul>
${linksHTML}
</ul>
</nav>`;
}

File Metadata

Mime Type
text/html
Expires
Tue, Feb 25, 10:24 (1 d, 13 h)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
610537
Default Alt Text
navbar.ts (1 KB)

Event Timeline