diff --git a/examples/site/posts/2021-04-12_looong.md b/examples/site/posts/_looong.md similarity index 100% rename from examples/site/posts/2021-04-12_looong.md rename to examples/site/posts/_looong.md diff --git a/pkgs-lib.nix b/pkgs-lib.nix index 85ebdf1..7a07f60 100644 --- a/pkgs-lib.nix +++ b/pkgs-lib.nix @@ -90,10 +90,14 @@ in { __displayName = l.head (l.splitString "." name); _displayName = l.splitString "_" __displayName; id = l.replaceStrings [" "] ["_"] __displayName; + date = l.head _displayName; in { inherit id; displayName = l.last _displayName; - date = l.head _displayName; + date = + if date == "" + then null + else date; content = l.readFile (parseMarkdown id (l.readFile (path + "/${name}"))); } )) @@ -104,7 +108,11 @@ in { d = getPart p.date; od = getPart op.date; in - !(((d 0) > (od 0)) && ((d 1) > (od 1)) && ((d 2) > (od 2))) + if p.date == null + then false + else if op.date == null + then true + else !(d 0 > od 0 && d 1 > od 1 && d 2 > od 2) )) ]; pagesRendered = let diff --git a/templaters/simple/default.nix b/templaters/simple/default.nix index aee71be..8e58301 100644 --- a/templaters/simple/default.nix +++ b/templaters/simple/default.nix @@ -15,7 +15,11 @@ with html; article [ (h1 {inherit (post) id;} post.displayName) - (h4 {class = "nohashtag";} ("date: " + post.date)) + ( + l.optionalString + (post.date != null) + (h4 {class = "nohashtag";} ("date: " + post.date)) + ) post.content ]; @@ -70,21 +74,32 @@ ) ); - postsLinks = with html; - l.singleton - (ul ( - l.map - ( - post: - li ( - a {href = "${ctx.baseurl}/${post.id}";} - "${post.date} - ${post.displayName}" - ) - ) - ctx.posts - )); + mkPostsLinks = posts: + with html; + l.singleton + (ul ( + l.map + ( + post: + li ( + a {href = "${ctx.baseurl}/${post.id}";} + ( + if post.date != null + then "${post.date} - ${post.displayName}" + else post.displayName + ) + ) + ) + posts + )); + postsLinksWithDate = mkPostsLinks (l.filter (p: p.date != null) ctx.posts); + postsLinksWithoutDate = mkPostsLinks (l.filter (p: p.date == null) ctx.posts); - postsSectionContent = [(html.h1 "posts")] ++ postsLinks; + postsSectionContent = + [(html.h1 "posts")] + ++ postsLinksWithDate + ++ [(html.h2 "miscellaneous")] + ++ postsLinksWithoutDate; postsRendered = l.listToAttrs ( l.map