pleshevski.ru/src/components/page_layout.mts

35 lines
966 B
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

import { AnyNode, Ea, Elem } from "ren";
import { Context } from "../context.mjs";
import { div } from "../utils.mjs";
export function PageLayout(ctx: Context, ...children: AnyNode[]): Elem {
return Ea("div", { id: "main" }, [
Header(ctx.locPath),
Ea("div", { class: "content" }, children),
// Footer(),
]);
}
export function Header(locPath: string): Elem {
return Ea("header", { class: "header" }, [
div({ class: "content-width" }, HeaderNav(locPath)),
]);
}
export function HeaderNav(locPath: string): Elem {
return Ea("nav", { class: "main-menu" }, [
NavLink(locPath, "/", "Обо мне"),
NavLink(locPath, "/works", "Работы"),
]);
}
export function NavLink(locPath: string, href: string, text: string): Elem {
const attrs = { href };
if (locPath === href) attrs["aria-current"] = "true";
return Ea("a", attrs, text);
}
export function Footer(): Elem {
return Ea("footer", { class: "footer" }, "footer");
}