feat: better basic styling, use caddy, generate caddy file
This commit is contained in:
parent
6c551a0f90
commit
1861da658e
@ -2,4 +2,6 @@ Donec vestibulum convallis odio sit amet gravida. Morbi mauris risus, accumsan n
|
||||
|
||||
Curabitur porta justo nec sapien consectetur vehicula. Integer venenatis lorem non pulvinar eleifend. Nulla ultricies lacinia purus, eleifend placerat dui gravida nec. Sed auctor scelerisque nisl, ut maximus nunc volutpat nec. Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Cras pretium, ex eu dapibus maximus, ex erat dapibus enim, sit amet maximus metus velit quis sem. Integer erat odio, feugiat quis velit ut, euismod elementum orci. Quisque fermentum leo quis odio facilisis interdum. Nullam posuere vestibulum odio, scelerisque interdum ante cursus non. Praesent congue neque nec auctor mollis. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Vestibulum vestibulum consectetur ipsum.
|
||||
|
||||
Proin orci eros, malesuada ut justo ut, luctus ultrices neque. Vestibulum sed magna vel ligula gravida tempor ut sit amet nulla. Maecenas accumsan tincidunt gravida. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Cras in lectus vitae tellus interdum porttitor. Phasellus sed erat ut ex sagittis cursus. Pellentesque rhoncus interdum placerat.
|
||||
Proin orci eros, malesuada ut justo ut, luctus ultrices neque. Vestibulum sed magna vel ligula gravida tempor ut sit amet nulla. Maecenas accumsan tincidunt gravida. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Cras in lectus vitae tellus interdum porttitor. Phasellus sed erat ut ex sagittis cursus. Pellentesque rhoncus interdum placerat.
|
||||
|
||||
<https://google.com>
|
14
pkgs-lib.nix
14
pkgs-lib.nix
@ -4,7 +4,8 @@ let
|
||||
|
||||
mkServePathScript = path: pkgs.writeScriptBin "serve" ''
|
||||
#!${pkgs.stdenv.shell}
|
||||
${pkgBin "miniserve"} --index index.html ${path}
|
||||
cd ${path}
|
||||
${pkgBin "caddy"} run --config Caddyfile
|
||||
'';
|
||||
|
||||
mkSitePath = site:
|
||||
@ -64,7 +65,7 @@ in
|
||||
)
|
||||
(readDir path);
|
||||
siteConfig = fromTOML (readFile (src + "/config.toml"));
|
||||
baseurl = if local then "http://127.0.0.1:8080" else siteConfig.baseurl or (throw "Need baseurl");
|
||||
baseurl = if local then "http://localhost:8080" else siteConfig.baseurl or (throw "Need baseurl");
|
||||
|
||||
context = {
|
||||
inherit utils pkgs baseurl;
|
||||
@ -76,6 +77,15 @@ in
|
||||
User-agent: *
|
||||
Allow: /
|
||||
'';
|
||||
"Caddyfile" = ''
|
||||
${baseurl}
|
||||
|
||||
handle_errors {
|
||||
rewrite * /{http.error.status_code}.html
|
||||
file_server
|
||||
}
|
||||
file_server
|
||||
'';
|
||||
};
|
||||
};
|
||||
in
|
||||
|
@ -1,7 +1,7 @@
|
||||
{ utils, posts, pkgs, config, pages, site, baseurl, ... }@context:
|
||||
let
|
||||
inherit (utils) readFile mapAttrsToList tags fetchGit map elemAt foldl';
|
||||
inherit (pkgs.lib) optional length splitString mapAttrs' nameValuePair;
|
||||
inherit (utils) readFile mapAttrsToList mapAttrs tags fetchGit map elemAt foldl';
|
||||
inherit (pkgs.lib) optional length splitString nameValuePair;
|
||||
|
||||
stylesheets = map tags.mkStylesheet [
|
||||
"https://unpkg.com/purecss@2.0.6/build/pure-min.css"
|
||||
@ -22,8 +22,8 @@ let
|
||||
|
||||
pagesSection =
|
||||
(map
|
||||
(name: tags.div { class = "pure-u-1"; } (tags.a { href = "${baseurl}/${name}"; class = "postheader"; } name))
|
||||
(mapAttrsToList (name: _: name) pages)) ++ [ (tags.div { class = "pure-u-1"; } (tags.a { href = "${baseurl}"; class = "postheader"; } "posts")) ];
|
||||
(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")) ];
|
||||
|
||||
postsSectionContent = with tags; [
|
||||
(a { href = "#posts"; class = "postheader"; } (h1 "# posts"))
|
||||
@ -60,19 +60,27 @@ let
|
||||
(css {
|
||||
body = {
|
||||
font-family = [ "Raleway" "Helvetica" "Arial" "sans-serif" ];
|
||||
background = "#111111";
|
||||
color = "#eeeeee";
|
||||
};
|
||||
pre = {
|
||||
font-family = [ "Iosevka Term" "Iosevka" "monospace" ];
|
||||
background = "#000000cc";
|
||||
background = "#171A21";
|
||||
color = "#eeeeee";
|
||||
};
|
||||
"a.postheader,a.postheader:hover" = {
|
||||
color = "inherit";
|
||||
"a,a:hover" = {
|
||||
color = "#ffd814";
|
||||
text-decoration = "none";
|
||||
};
|
||||
"a.postheader:hover" = {
|
||||
"a:hover" = {
|
||||
text-decoration = "underline";
|
||||
};
|
||||
"a.postheader,a.postheader:hover" = {
|
||||
color = "#fc6711";
|
||||
};
|
||||
"a.pagelink,a.pagelink:hover" = {
|
||||
color = "#ffd814";
|
||||
};
|
||||
"div.content" = {
|
||||
margin-top = "5%";
|
||||
margin-bottom = "5%";
|
||||
@ -102,6 +110,7 @@ in
|
||||
|
||||
site = site // {
|
||||
"index.html" = mkPage postsSectionContent;
|
||||
"404.html" = mkPage (tags.h1 "No such page");
|
||||
"site.css" = stylesheet;
|
||||
} // (mapAttrs' (name: value: nameValuePair (name + ".html") (mkPage value)) pages);
|
||||
} // (mapAttrs (name: value: { "index.html" = mkPage value; }) pages);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user