From 1ee7c9ebfccc24ea0653484f597e6ae07ac71770 Mon Sep 17 00:00:00 2001 From: Yusuf Bera Ertan Date: Mon, 17 May 2021 00:08:42 +0300 Subject: [PATCH] feat: local serve support --- examples/site.nix | 1 + pkgs-lib.nix | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/examples/site.nix b/examples/site.nix index c309e30..5b6e34a 100644 --- a/examples/site.nix +++ b/examples/site.nix @@ -6,4 +6,5 @@ in htmlNix.mkServeFromSite (htmlNix.mkSiteFrom { inherit src; templater = lib.templaters.basic; + local = true; }) diff --git a/pkgs-lib.nix b/pkgs-lib.nix index ed150d7..03a3425 100644 --- a/pkgs-lib.nix +++ b/pkgs-lib.nix @@ -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;