2022-06-08 23:24:19 +03:00
|
|
|
import { AnyNode, Attrs, E, Elem } from "ren/node.ts";
|
|
|
|
import { classNames } from "ren/attrs.ts";
|
|
|
|
import { Context, getLangHref, iterLangs, Lang } from "../../context.ts";
|
2023-06-20 16:30:27 +03:00
|
|
|
import { Link } from "../../uikit/link.ts";
|
|
|
|
import { renderDate } from "../../render.ts";
|
|
|
|
|
|
|
|
const SITE_UPDATED_AT = new Date();
|
2022-06-08 23:24:19 +03:00
|
|
|
|
|
|
|
export function PageLayout(ctx: Context, children: AnyNode[]): Elem {
|
|
|
|
return E("div", { id: "main" }, [
|
|
|
|
Header(ctx),
|
|
|
|
E("div", classNames("content"), children),
|
|
|
|
Footer(ctx),
|
|
|
|
]);
|
|
|
|
}
|
|
|
|
|
|
|
|
export function Header(ctx: Context): AnyNode {
|
|
|
|
return E("header", classNames("header gap-v-1x5"), [
|
|
|
|
E("div", classNames("content-width"), [HeaderNav(ctx)]),
|
|
|
|
]);
|
|
|
|
}
|
|
|
|
|
|
|
|
export function HeaderNav(ctx: Context): AnyNode {
|
|
|
|
return E("nav", classNames("main-menu"), [
|
|
|
|
Link(ctx.tr.About, navLink("/", ctx)),
|
|
|
|
Link(ctx.tr.Works, navLink("/works", ctx)),
|
|
|
|
]);
|
|
|
|
}
|
|
|
|
|
|
|
|
function navLink(lhref: string, ctx?: Context): Attrs {
|
|
|
|
const attrs: Attrs = { lhref };
|
|
|
|
if (ctx?.locPath === lhref) attrs["aria-current"] = "true";
|
|
|
|
return attrs;
|
|
|
|
}
|
|
|
|
|
|
|
|
export function Footer(ctx: Context): AnyNode {
|
|
|
|
return E("footer", classNames("footer"), [
|
|
|
|
E("div", classNames("content-width row-sta-bet"), [
|
2022-06-21 00:01:06 +03:00
|
|
|
E("div", classNames("gap-v-1x5"), [
|
|
|
|
E("div", [], [
|
|
|
|
E("b", [], "Updated At:"),
|
2023-06-20 16:30:27 +03:00
|
|
|
renderDate(SITE_UPDATED_AT),
|
2022-06-21 00:01:06 +03:00
|
|
|
]),
|
|
|
|
E("div", [], [
|
2023-06-20 16:30:27 +03:00
|
|
|
Link(ctx.tr.Source_code, {
|
|
|
|
href: "https://git.pleshevski.ru/pleshevskiy/pleshevski.ru",
|
|
|
|
}),
|
2022-06-21 00:01:06 +03:00
|
|
|
]),
|
|
|
|
]),
|
2022-06-08 23:24:19 +03:00
|
|
|
ChangeLang(ctx),
|
|
|
|
]),
|
|
|
|
]);
|
|
|
|
}
|
|
|
|
|
|
|
|
export function ChangeLang(ctx: Context): AnyNode {
|
|
|
|
const dropdownId = "change_langs";
|
|
|
|
return E("div", classNames("dropdown"), [
|
|
|
|
E("input", { id: dropdownId, type: "checkbox" }),
|
|
|
|
E("label", { for: dropdownId }, ctx.lang),
|
|
|
|
E(
|
|
|
|
"ul",
|
|
|
|
[],
|
|
|
|
iterLangs().filter((l) => l !== ctx.lang).map((l) =>
|
|
|
|
ChangeLangBtn(ctx, l)
|
|
|
|
),
|
|
|
|
),
|
|
|
|
]);
|
|
|
|
}
|
|
|
|
|
|
|
|
export function ChangeLangBtn(ctx: Context, lang: Lang): AnyNode {
|
|
|
|
return Link(lang, { "href": getLangHref(lang, ctx.locPath) });
|
|
|
|
}
|