html.nix/templaters/basic.nix

55 lines
1.4 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
renderPost = name: value: with tags; [
2021-05-15 21:52:25 +03:00
(a { href = "#${name}"; class = "postheader"; } (h3 { 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:52:25 +03:00
(mkStylesheet "https://unpkg.com/purecss@2.0.6/build/pure-min.css")
(mkStylesheet "https://unpkg.com/purecss@2.0.6/build/grids-responsive-min.css")
2021-05-15 21:29:30 +03:00
(mkStylesheet "css/mine.css")
2021-05-15 21:52:25 +03:00
(meta { name = "viewport"; content = "width=device-width, initial-scale=1"; })
2021-05-15 21:29:30 +03:00
])
(body [
2021-05-15 21:52:25 +03:00
(div { class = "about"; } [
(a { href = "#About"; class = "postheader"; } (h1 "# About"))
(p config.about)
2021-05-15 21:29:30 +03:00
])
2021-05-15 21:52:25 +03:00
(div { class = "posts"; } ([
(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 = {
"mine.css" = ''
2021-05-15 21:52:25 +03:00
a.postheader,a.postheader:hover {
2021-05-15 21:29:30 +03:00
color: inherit;
text-decoration: underline;
}
2021-05-15 21:52:25 +03:00
div.posts {
margin-top: 5%;
margin-bottom: 5%;
margin-left: 20%;
margin-right: 10%;
}
div.about {
position: -webkit-sticky;
position: sticky;
top: 0;
margin-left: 3%;
2021-05-15 21:29:30 +03:00
}
'';
};
2021-05-15 19:42:16 +03:00
}