feat: local serve support

This commit is contained in:
dusk 2021-05-17 00:08:42 +03:00
parent 3a5d9ee9a6
commit 1ee7c9ebfc
Signed by: dusk
GPG Key ID: 1D8F8FAF2294D6EA
2 changed files with 3 additions and 2 deletions

View File

@ -6,4 +6,5 @@ in
htmlNix.mkServeFromSite (htmlNix.mkSiteFrom {
inherit src;
templater = lib.templaters.basic;
local = true;
})

View File

@ -31,7 +31,7 @@ in
inherit mkServePathScript mkSitePath parseMarkdown;
mkServeFromSite = site: mkServePathScript (mkSitePath site);
mkSiteFrom = { src, templater }:
mkSiteFrom = { src, templater, local ? false }:
let
inherit (utils) readDir readFile fromTOML mapAttrsToList sort elemAt;
inherit (pkgs.lib) nameValuePair head splitString pipe removeSuffix mapAttrs';
@ -64,7 +64,7 @@ in
)
(readDir path);
siteConfig = fromTOML (readFile (src + "/config.toml"));
baseurl = siteConfig.baseurl or (throw "Need baseurl");
baseurl = if local then "http://127.0.0.1:8080" else siteConfig.baseurl or (throw "Need baseurl");
context = {
inherit utils pkgs baseurl;