handle pages and posts not existing
This commit is contained in:
parent
c6bd196fdc
commit
4ffd5d4fa5
86
pkgs-lib.nix
86
pkgs-lib.nix
@ -94,49 +94,55 @@ in {
|
|||||||
postsRendered = let
|
postsRendered = let
|
||||||
path = "${toString src}/posts";
|
path = "${toString src}/posts";
|
||||||
in
|
in
|
||||||
l.pipe (l.readDir path) [
|
if l.pathExists postsRendered
|
||||||
(l.mapAttrsToList (
|
then
|
||||||
name: _: let
|
l.pipe (l.readDir path) [
|
||||||
__displayName = l.head (l.splitString "." name);
|
(l.mapAttrsToList (
|
||||||
_displayName = l.splitString "_" __displayName;
|
name: _: let
|
||||||
id = l.replaceStrings [" "] ["_"] __displayName;
|
__displayName = l.head (l.splitString "." name);
|
||||||
date = l.head _displayName;
|
_displayName = l.splitString "_" __displayName;
|
||||||
in {
|
id = l.replaceStrings [" "] ["_"] __displayName;
|
||||||
inherit id;
|
date = l.head _displayName;
|
||||||
displayName = l.last _displayName;
|
in {
|
||||||
date =
|
inherit id;
|
||||||
if date == ""
|
displayName = l.last _displayName;
|
||||||
then null
|
date =
|
||||||
else date;
|
if date == ""
|
||||||
content = l.readFile (parseMarkdown id (getPath path name));
|
then null
|
||||||
}
|
else date;
|
||||||
))
|
content = l.readFile (parseMarkdown id (getPath path name));
|
||||||
(l.sort (
|
}
|
||||||
p: op: let
|
))
|
||||||
extractDate = date: l.splitString "-" date;
|
(l.sort (
|
||||||
getPart = date: el: l.removeSuffix "0" (l.elemAt (extractDate date) el);
|
p: op: let
|
||||||
d = getPart p.date;
|
extractDate = date: l.splitString "-" date;
|
||||||
od = getPart op.date;
|
getPart = date: el: l.removeSuffix "0" (l.elemAt (extractDate date) el);
|
||||||
in
|
d = getPart p.date;
|
||||||
if p.date == null
|
od = getPart op.date;
|
||||||
then false
|
in
|
||||||
else if op.date == null
|
if p.date == null
|
||||||
then true
|
then false
|
||||||
else !(d 0 > od 0 && d 1 > od 1 && d 2 > od 2)
|
else if op.date == null
|
||||||
))
|
then true
|
||||||
];
|
else !(d 0 > od 0 && d 1 > od 1 && d 2 > od 2)
|
||||||
|
))
|
||||||
|
]
|
||||||
|
else [];
|
||||||
pagesRendered = let
|
pagesRendered = let
|
||||||
path = "${toString src}/pages";
|
path = "${toString src}/pages";
|
||||||
in
|
in
|
||||||
l.mapAttrsToList
|
if l.pathExists path
|
||||||
(
|
then
|
||||||
name: _: rec {
|
l.mapAttrsToList
|
||||||
displayName = l.head (l.splitString "." name);
|
(
|
||||||
id = l.replaceStrings [" "] ["_"] displayName;
|
name: _: rec {
|
||||||
content = l.readFile (parseMarkdown id (getPath path name));
|
displayName = l.head (l.splitString "." name);
|
||||||
}
|
id = l.replaceStrings [" "] ["_"] displayName;
|
||||||
)
|
content = l.readFile (parseMarkdown id (getPath path name));
|
||||||
(l.readDir path);
|
}
|
||||||
|
)
|
||||||
|
(l.readDir path)
|
||||||
|
else [];
|
||||||
baseurl =
|
baseurl =
|
||||||
if local
|
if local
|
||||||
then "http://localhost:8080"
|
then "http://localhost:8080"
|
||||||
|
Loading…
Reference in New Issue
Block a user