From b6a96ef07e7d6b18f38bb30b5d37bfe91b04d40d Mon Sep 17 00:00:00 2001 From: Yusuf Bera Ertan Date: Thu, 6 Apr 2023 06:45:41 +0300 Subject: [PATCH] fix pages with spaces --- .../site/posts/{_looong.md => _looong looooong.md} | 0 pkgs-lib.nix | 13 +++++++++---- 2 files changed, 9 insertions(+), 4 deletions(-) rename examples/site/posts/{_looong.md => _looong looooong.md} (100%) diff --git a/examples/site/posts/_looong.md b/examples/site/posts/_looong looooong.md similarity index 100% rename from examples/site/posts/_looong.md rename to examples/site/posts/_looong looooong.md diff --git a/pkgs-lib.nix b/pkgs-lib.nix index 8321d3e..3e10f81 100644 --- a/pkgs-lib.nix +++ b/pkgs-lib.nix @@ -82,8 +82,13 @@ in { local ? false, config ? {}, } @ args: let + getPath = from: name: + l.path { + name = l.strings.sanitizeDerivationName name; + path = "${toString from}/${name}"; + }; postsRendered = let - path = src + "/posts"; + path = "${toString src}/posts"; in l.pipe (l.readDir path) [ (l.mapAttrsToList ( @@ -99,7 +104,7 @@ in { if date == "" then null else date; - content = l.readFile (parseMarkdown id (path + "/${name}")); + content = l.readFile (parseMarkdown id (getPath path name)); } )) (l.sort ( @@ -117,14 +122,14 @@ in { )) ]; pagesRendered = let - path = src + "/pages"; + path = "${toString src}/pages"; in l.mapAttrsToList ( name: _: rec { displayName = l.head (l.splitString "." name); id = l.replaceStrings [" "] ["_"] displayName; - content = l.readFile (parseMarkdown id (path + "/${name}")); + content = l.readFile (parseMarkdown id (getPath path name)); } ) (l.readDir path);