Fix article sorting by date

This commit is contained in:
dogeystamp 2022-06-07 20:23:36 -04:00
parent 42b52daaee
commit 02648a8552
Signed by: dogeystamp
GPG Key ID: 7225FE3592EFFA38

14
ssg6
View File

@ -256,20 +256,22 @@ render_article_list() {
for i in $urls; do
if echo $i | grep '^posts/' > /dev/null; then
DATE=$(cat $dst/$i | grep '<!--- date: .*-.*-.* --->' | cut -d ' ' -f 3-3)
url="$date;$i"
sorted_urls="$(echo "$sorted_urls $i" | sort -r)"
url="$DATE;$i"
sorted_urls="$(echo -n "$sorted_urls\n$url" | sort -r)"
fi
done
items=""
for i in $sorted_urls; do
CLEAN_DATE=$(cat $dst/$i | grep '<!--- date: .*-.*-.* --->' | cut -d ' ' -f 3-3)
TITLE=$(cat $dst/$i | grep '<!--- title: .*--->' | awk '{for(i=3;i<NF;i++) printf $i" " }' | xargs)
url=$(echo $i | cut -d';' -f2-)
CLEAN_DATE=$(cat $dst/$url | grep '<!--- date: .*-.*-.* --->' | cut -d ' ' -f 3-3)
TITLE=$(cat $dst/$url | grep '<!--- title: .*--->' | awk '{for(i=3;i<NF;i++) printf $i" " }' | xargs)
DATE=$(date -d "$CLEAN_DATE" +"%B %d, %Y")
item="<li><a href='$i'>$TITLE</a><i>$DATE</i></li>"
item="<li><a href='$url'>$TITLE</a><i>$DATE</i></li>"
items="$items $item"
done