simplify handling of date for rss feed and add custom date format for blog-index

This commit is contained in:
Kosaki 2020-07-18 22:43:25 +02:00
parent af773b4de2
commit ce337cf373

View File

@ -22,13 +22,13 @@ add_header() {
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
<author><name>Lucy</name></author>
<title type="text">Lucys blog</title>'
output_rss " <updated>$(date --rfc-3339=seconds | sed 's/ /T/')</updated>
output_rss " <updated>$(date --iso-8601=seconds)</updated>
<id>https://lucy.moe/rss.xml</id>
<link href=\"https://lucy.moe/rss.xml\" rel=\"self\" type=\"application/atom+xml\"/>"
}
add_footer() {
html_entry "https://asagi.moe" "before July 2020" "Old site" "de/en"
html_entry "https://asagi.moe" "before July 2020" "Old site"
output '</table>'
output_rss '</feed>'
}
@ -50,8 +50,8 @@ rss_entry() {
# The sed expression is stolen from https://stackoverflow.com/questions/12873682/12873723#12873723
output_rss " <entry>
<title type=\"text\">$1</title>
<published>$(date --rfc-3339=seconds -d $4 | sed 's/ /T/')</published>
<updated>$(date --rfc-3339=seconds -r $3 | sed 's/ /T/')</updated>
<published>$(date --iso-8601=seconds -d $4)</published>
<updated>$(date --iso-8601=seconds -r $3)</updated>
<id>$blog_domain$2</id>
<link href=\"$blog_domain$2\" type=\"text/html\" title=\"$1\"/>
<summary type=\"html\">
@ -72,7 +72,8 @@ create_entry() {
# then add it to the index
title=$(grep -h '<title>' "dist/$outpath" | sed 's/<title>//g;s/<\/title>//g')
created=$(grep -h '^date: ' "$path" | sed 's/date: //g')
html_entry "$outpath" "$created" "$title"
created_date=$(date +%x --date="$created")
html_entry "$outpath" "$created_date" "$title"
rss_entry "$title" "$outpath" $path $created
}