Fix article sorting by date
This commit is contained in:
parent
42b52daaee
commit
02648a8552
14
ssg6
14
ssg6
@ -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
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user