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
|
for i in $urls; do
|
||||||
if echo $i | grep '^posts/' > /dev/null; then
|
if echo $i | grep '^posts/' > /dev/null; then
|
||||||
DATE=$(cat $dst/$i | grep '<!--- date: .*-.*-.* --->' | cut -d ' ' -f 3-3)
|
DATE=$(cat $dst/$i | grep '<!--- date: .*-.*-.* --->' | cut -d ' ' -f 3-3)
|
||||||
url="$date;$i"
|
url="$DATE;$i"
|
||||||
sorted_urls="$(echo "$sorted_urls $i" | sort -r)"
|
sorted_urls="$(echo -n "$sorted_urls\n$url" | sort -r)"
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
|
||||||
items=""
|
items=""
|
||||||
|
|
||||||
for i in $sorted_urls; do
|
for i in $sorted_urls; do
|
||||||
CLEAN_DATE=$(cat $dst/$i | grep '<!--- date: .*-.*-.* --->' | cut -d ' ' -f 3-3)
|
url=$(echo $i | cut -d';' -f2-)
|
||||||
TITLE=$(cat $dst/$i | grep '<!--- title: .*--->' | awk '{for(i=3;i<NF;i++) printf $i" " }' | xargs)
|
|
||||||
|
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")
|
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"
|
items="$items $item"
|
||||||
done
|
done
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user