allow posts without dates
This commit is contained in:
parent
46b3656161
commit
f3904cdd4f
12
pkgs-lib.nix
12
pkgs-lib.nix
@ -90,10 +90,14 @@ in {
|
|||||||
__displayName = l.head (l.splitString "." name);
|
__displayName = l.head (l.splitString "." name);
|
||||||
_displayName = l.splitString "_" __displayName;
|
_displayName = l.splitString "_" __displayName;
|
||||||
id = l.replaceStrings [" "] ["_"] __displayName;
|
id = l.replaceStrings [" "] ["_"] __displayName;
|
||||||
|
date = l.head _displayName;
|
||||||
in {
|
in {
|
||||||
inherit id;
|
inherit id;
|
||||||
displayName = l.last _displayName;
|
displayName = l.last _displayName;
|
||||||
date = l.head _displayName;
|
date =
|
||||||
|
if date == ""
|
||||||
|
then null
|
||||||
|
else date;
|
||||||
content = l.readFile (parseMarkdown id (l.readFile (path + "/${name}")));
|
content = l.readFile (parseMarkdown id (l.readFile (path + "/${name}")));
|
||||||
}
|
}
|
||||||
))
|
))
|
||||||
@ -104,7 +108,11 @@ in {
|
|||||||
d = getPart p.date;
|
d = getPart p.date;
|
||||||
od = getPart op.date;
|
od = getPart op.date;
|
||||||
in
|
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
|
pagesRendered = let
|
||||||
|
@ -15,7 +15,11 @@
|
|||||||
with html;
|
with html;
|
||||||
article [
|
article [
|
||||||
(h1 {inherit (post) id;} post.displayName)
|
(h1 {inherit (post) id;} post.displayName)
|
||||||
|
(
|
||||||
|
l.optionalString
|
||||||
|
(post.date != null)
|
||||||
(h4 {class = "nohashtag";} ("date: " + post.date))
|
(h4 {class = "nohashtag";} ("date: " + post.date))
|
||||||
|
)
|
||||||
post.content
|
post.content
|
||||||
];
|
];
|
||||||
|
|
||||||
@ -70,7 +74,8 @@
|
|||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
postsLinks = with html;
|
mkPostsLinks = posts:
|
||||||
|
with html;
|
||||||
l.singleton
|
l.singleton
|
||||||
(ul (
|
(ul (
|
||||||
l.map
|
l.map
|
||||||
@ -78,13 +83,23 @@
|
|||||||
post:
|
post:
|
||||||
li (
|
li (
|
||||||
a {href = "${ctx.baseurl}/${post.id}";}
|
a {href = "${ctx.baseurl}/${post.id}";}
|
||||||
"${post.date} - ${post.displayName}"
|
(
|
||||||
|
if post.date != null
|
||||||
|
then "${post.date} - ${post.displayName}"
|
||||||
|
else post.displayName
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
ctx.posts
|
)
|
||||||
|
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 (
|
postsRendered = l.listToAttrs (
|
||||||
l.map
|
l.map
|
||||||
|
Loading…
Reference in New Issue
Block a user