refactor: some docs, refactor basic template a lil bit

This commit is contained in:
dusk 2021-05-16 03:05:10 +03:00
parent 5dab512a5d
commit 6d61daa842
Signed by: dusk
GPG Key ID: 1D8F8FAF2294D6EA
3 changed files with 20 additions and 7 deletions

View File

@ -6,7 +6,10 @@ in
htmlNix.mkServeFromSite (htmlNix.mkSiteFrom { htmlNix.mkServeFromSite (htmlNix.mkSiteFrom {
inherit src; inherit src;
templater = context: pkgs.lib.pipe context [ templater = context: pkgs.lib.pipe context [
# Add basic template
lib.templaters.basic lib.templaters.basic
# Add about page
({ site, mkPage, ... }@result: { ({ site, mkPage, ... }@result: {
site = site // { site = site // {
"about.html" = with lib.tags; mkPage [ "about.html" = with lib.tags; mkPage [

View File

@ -10,10 +10,14 @@
utils = import ./utils.nix; utils = import ./utils.nix;
lib = { lib = {
# Convert Nix expressions to HTML
tags = import ./tags.nix { inherit utils; }; tags = import ./tags.nix { inherit utils; };
# Convert Nix expressions to CSS
css = import ./css.nix { inherit utils; }; css = import ./css.nix { inherit utils; };
# Various site templaters
templaters = { templaters = {
# Basic templater with purecss, mobile responsive layout and supports posts
basic = import ./templaters/basic.nix; basic = import ./templaters/basic.nix;
}; };
}; };

View File

@ -3,7 +3,11 @@ let
inherit (utils) readFile mapAttrsToList tags fetchGit map; inherit (utils) readFile mapAttrsToList tags fetchGit map;
inherit (pkgs.lib) flatten optional length; inherit (pkgs.lib) flatten optional length;
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" "mine.css" ]; 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"
"mine.css"
];
renderPost = name: value: with tags; article [ renderPost = name: value: with tags; article [
(a { href = "#${name}"; class = "postheader"; } (h3 { id = name; } ("## " + name))) (a { href = "#${name}"; class = "postheader"; } (h3 { id = name; } ("## " + name)))
@ -37,6 +41,12 @@ let
stylesheet = stylesheet =
with utils.css; with utils.css;
let
marginMobile = {
margin-left = "3%";
margin-right = "3%";
};
in
css [ css [
(css { (css {
body = { body = {
@ -71,14 +81,10 @@ let
"nav.sidebar" = { "nav.sidebar" = {
position = "relative"; position = "relative";
margin-top = "5%"; margin-top = "5%";
margin-left = "3%"; } // marginMobile;
margin-right = "3%";
};
"div.content" = { "div.content" = {
margin-top = 0; margin-top = 0;
margin-left = "3%"; } // marginMobile;
margin-right = "3%";
};
}) })
]; ];
in in