html.nix/templaters/basic.nix

57 lines
1.5 KiB
Nix
Raw Normal View History

2021-05-15 19:42:16 +03:00
{ utils, posts, pkgs, config, ... }@context:
let
2021-05-15 21:29:30 +03:00
inherit (utils) readFile mapAttrsToList tags fetchGit;
2021-05-15 19:42:16 +03:00
inherit (pkgs.lib) flatten;
2021-05-15 21:29:30 +03:00
skeleton = fetchGit {
url = "https://github.com/dhg/Skeleton.git";
rev = "88f03612b05f093e3f235ced77cf89d3a8fcf846";
};
renderPost = name: value: with tags; [
(a { href = "#${name}"; class = "postheader"; } (h4 { id = name; } ("## " + name)))
2021-05-15 19:42:16 +03:00
(readFile value)
];
allPosts = flatten (mapAttrsToList renderPost posts);
in
{
2021-05-15 21:29:30 +03:00
"index.html" = with tags;
2021-05-15 19:42:16 +03:00
html [
(head [
(title config.title)
2021-05-15 21:29:30 +03:00
(mkStylesheet "css/normalize.css")
(mkStylesheet "css/skeleton.css")
(mkStylesheet "css/mine.css")
])
(body [
(div { class = "container"; style = "margin-top: 5%; margin-bottom: 5%;"; } [
(div { class = "column"; } [
(div { class = "twelve columns"; } [
(a { href = "#About"; class = "postheader"; } (h1 "# About"))
(p config.about)
])
(div { class = "twelve columns"; } ([
(a { href = "#Posts"; class = "postheader"; } (h1 "# Posts"))
] ++ allPosts))
])
])
2021-05-15 19:42:16 +03:00
])
];
2021-05-15 21:29:30 +03:00
css = {
"normalize.css" = readFile "${skeleton}/css/normalize.css";
"skeleton.css" = readFile "${skeleton}/css/skeleton.css";
"mine.css" = ''
a.postheader {
color: inherit;
text-decoration: underline;
}
a.postheader:hover {
color: inherit;
text-decoration: underline;
}
'';
};
2021-05-15 19:42:16 +03:00
}