2021-05-16 23:51:59 +03:00
|
|
|
{ utils, posts, pkgs, config, pages, site, baseurl, ... }@context:
|
2021-05-15 19:42:16 +03:00
|
|
|
let
|
2021-05-17 03:26:48 +03:00
|
|
|
inherit (utils) readFile mapAttrsToList mapAttrs tags fetchGit map elemAt foldl';
|
|
|
|
inherit (pkgs.lib) optional length splitString nameValuePair;
|
2021-05-15 19:42:16 +03:00
|
|
|
|
2021-05-16 03:05:10 +03:00
|
|
|
stylesheets = map tags.mkStylesheet [
|
|
|
|
"https://unpkg.com/purecss@2.0.6/build/pure-min.css"
|
|
|
|
"https://unpkg.com/purecss@2.0.6/build/grids-responsive-min.css"
|
2021-05-16 23:51:59 +03:00
|
|
|
"${baseurl}/site.css"
|
2021-05-16 03:05:10 +03:00
|
|
|
];
|
2021-05-16 00:43:38 +03:00
|
|
|
|
2021-05-16 03:57:35 +03:00
|
|
|
renderPost = { name, value }:
|
|
|
|
let
|
|
|
|
parts = splitString "_" name;
|
|
|
|
id = elemAt parts 1;
|
|
|
|
in
|
|
|
|
with tags; article [
|
|
|
|
(a { href = "#${id}"; class = "postheader"; } (h3 { inherit id; } ("## " + id)))
|
|
|
|
(h6 ("date: " + (elemAt parts 0)))
|
2021-05-16 22:47:53 +03:00
|
|
|
value
|
2021-05-16 03:57:35 +03:00
|
|
|
];
|
|
|
|
|
2021-05-16 22:47:53 +03:00
|
|
|
pagesSection =
|
2021-05-16 23:22:34 +03:00
|
|
|
(map
|
2021-05-17 03:26:48 +03:00
|
|
|
(name: tags.div { class = "pure-u-1"; } (tags.a { href = "${baseurl}/${name}"; class = "pagelink"; } name))
|
|
|
|
(mapAttrsToList (name: _: name) pages)) ++ [ (tags.div { class = "pure-u-1"; } (tags.a { href = "${baseurl}"; class = "pagelink"; } "posts")) ];
|
2021-05-16 00:43:38 +03:00
|
|
|
|
2021-05-16 02:56:54 +03:00
|
|
|
postsSectionContent = with tags; [
|
2021-05-16 00:43:38 +03:00
|
|
|
(a { href = "#posts"; class = "postheader"; } (h1 "# posts"))
|
2021-05-16 03:57:35 +03:00
|
|
|
] ++ (map renderPost posts);
|
2021-05-16 00:43:38 +03:00
|
|
|
|
2021-05-16 22:47:53 +03:00
|
|
|
sidebarSection = optional ((length pagesSection) > 0) (
|
2021-05-16 00:43:38 +03:00
|
|
|
with tags; nav { class = "sidebar"; } ([
|
|
|
|
(a { href = "#pages"; class = "postheader"; } (h1 "# pages"))
|
2021-05-16 22:47:53 +03:00
|
|
|
(div { class = "pure-g"; } pagesSection)
|
2021-05-16 00:43:38 +03:00
|
|
|
])
|
|
|
|
);
|
2021-05-16 02:56:54 +03:00
|
|
|
|
|
|
|
mkPage = content: with tags;
|
2021-05-16 23:51:59 +03:00
|
|
|
''
|
|
|
|
<!DOCTYPE html>
|
|
|
|
${html [
|
|
|
|
(head (stylesheets ++ [
|
|
|
|
(title config.title)
|
|
|
|
(meta { name = "viewport"; content = "width=device-width, initial-scale=1"; })
|
|
|
|
]))
|
|
|
|
(body (sidebarSection ++ [ (div { class = "content"; } content) ]))
|
|
|
|
]}
|
|
|
|
'';
|
2021-05-15 21:29:30 +03:00
|
|
|
|
2021-05-16 02:56:54 +03:00
|
|
|
stylesheet =
|
|
|
|
with utils.css;
|
2021-05-16 03:05:10 +03:00
|
|
|
let
|
|
|
|
marginMobile = {
|
|
|
|
margin-left = "3%";
|
|
|
|
margin-right = "3%";
|
|
|
|
};
|
|
|
|
in
|
2021-05-16 02:56:54 +03:00
|
|
|
css [
|
|
|
|
(css {
|
|
|
|
body = {
|
|
|
|
font-family = [ "Raleway" "Helvetica" "Arial" "sans-serif" ];
|
2021-05-17 03:26:48 +03:00
|
|
|
background = "#111111";
|
|
|
|
color = "#eeeeee";
|
2021-05-16 02:56:54 +03:00
|
|
|
};
|
2021-05-16 04:25:22 +03:00
|
|
|
pre = {
|
2021-05-16 02:56:54 +03:00
|
|
|
font-family = [ "Iosevka Term" "Iosevka" "monospace" ];
|
2021-05-17 03:26:48 +03:00
|
|
|
background = "#171A21";
|
2021-05-16 02:56:54 +03:00
|
|
|
color = "#eeeeee";
|
|
|
|
};
|
2021-05-17 03:26:48 +03:00
|
|
|
"a,a:hover" = {
|
|
|
|
color = "#ffd814";
|
2021-05-16 02:56:54 +03:00
|
|
|
text-decoration = "none";
|
|
|
|
};
|
2021-05-17 03:26:48 +03:00
|
|
|
"a:hover" = {
|
2021-05-16 02:56:54 +03:00
|
|
|
text-decoration = "underline";
|
|
|
|
};
|
2021-05-17 03:26:48 +03:00
|
|
|
"a.postheader,a.postheader:hover" = {
|
|
|
|
color = "#fc6711";
|
|
|
|
};
|
|
|
|
"a.pagelink,a.pagelink:hover" = {
|
|
|
|
color = "#ffd814";
|
|
|
|
};
|
2021-05-16 02:56:54 +03:00
|
|
|
"div.content" = {
|
|
|
|
margin-top = "5%";
|
|
|
|
margin-bottom = "5%";
|
|
|
|
margin-left = "20%";
|
|
|
|
margin-right = "10%";
|
|
|
|
};
|
|
|
|
"nav.sidebar" = {
|
|
|
|
position = "fixed";
|
|
|
|
top = 0;
|
|
|
|
margin-left = "3%";
|
|
|
|
z-index = 1000;
|
|
|
|
};
|
|
|
|
})
|
|
|
|
(media "max-width: 48em" {
|
|
|
|
"nav.sidebar" = {
|
|
|
|
position = "relative";
|
|
|
|
margin-top = "5%";
|
2021-05-16 03:05:10 +03:00
|
|
|
} // marginMobile;
|
2021-05-16 02:56:54 +03:00
|
|
|
"div.content" = {
|
|
|
|
margin-top = 0;
|
2021-05-16 03:05:10 +03:00
|
|
|
} // marginMobile;
|
2021-05-16 02:56:54 +03:00
|
|
|
})
|
|
|
|
];
|
|
|
|
in
|
|
|
|
{
|
|
|
|
inherit stylesheets sidebarSection mkPage stylesheet;
|
|
|
|
|
2021-05-16 23:51:59 +03:00
|
|
|
site = site // {
|
2021-05-16 02:56:54 +03:00
|
|
|
"index.html" = mkPage postsSectionContent;
|
2021-05-17 03:26:48 +03:00
|
|
|
"404.html" = mkPage (tags.h1 "No such page");
|
2021-05-16 23:51:59 +03:00
|
|
|
"site.css" = stylesheet;
|
2021-05-17 03:26:48 +03:00
|
|
|
} // (mapAttrs (name: value: { "index.html" = mkPage value; }) pages);
|
2021-05-15 19:42:16 +03:00
|
|
|
}
|