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 { htmlNix.mkServeFromSite (htmlNix.mkSiteFrom {
inherit src; inherit src;
templater = lib.templaters.basic; templater = lib.templaters.basic;
local = true;
}) })

View File

@ -31,7 +31,7 @@ in
inherit mkServePathScript mkSitePath parseMarkdown; inherit mkServePathScript mkSitePath parseMarkdown;
mkServeFromSite = site: mkServePathScript (mkSitePath site); mkServeFromSite = site: mkServePathScript (mkSitePath site);
mkSiteFrom = { src, templater }: mkSiteFrom = { src, templater, local ? false }:
let let
inherit (utils) readDir readFile fromTOML mapAttrsToList sort elemAt; inherit (utils) readDir readFile fromTOML mapAttrsToList sort elemAt;
inherit (pkgs.lib) nameValuePair head splitString pipe removeSuffix mapAttrs'; inherit (pkgs.lib) nameValuePair head splitString pipe removeSuffix mapAttrs';
@ -64,7 +64,7 @@ in
) )
(readDir path); (readDir path);
siteConfig = fromTOML (readFile (src + "/config.toml")); 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 = { context = {
inherit utils pkgs baseurl; inherit utils pkgs baseurl;