Fediversity/website/presentation/templates.nix

37 lines
938 B
Nix
Raw Normal View History

2024-11-13 15:24:41 +01:00
{ lib }:
2024-11-13 15:24:41 +01:00
rec {
2024-11-13 15:24:41 +01:00
html = { head, body }: ''
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
${lib.indent " " head}
</head>
<body>
${lib.indent " " body}
<body>
</html>
'';
2024-11-13 15:24:41 +01:00
nav = menu: page:
2024-11-13 15:24:41 +01:00
let
render-item = item:
2024-11-13 15:24:41 +01:00
if item ? menu then ''
<li>${item.menu.label}
${lib.indent " " (item.menu.outputs.html page)}
</li>
''
else if item ? page then ''<li><a href="${page.link item.page}">${item.page.title}</a></li>''
else ''<li><a href="${item.link.url}">${item.link.label}</a></li>''
2024-11-13 15:24:41 +01:00
;
in
''
<nav>
<ul>
${with lib; indent " " (join "\n" (map render-item menu.menu.items))}
2024-11-13 15:24:41 +01:00
</ul>
</nav>
'';
2024-11-13 15:24:41 +01:00
}