Add RSS generation and feed

This commit is contained in:
askiiart 2023-09-25 14:40:56 -05:00
parent 27824d522c
commit c3e15f50d7
No known key found for this signature in database
GPG key ID: 94789D499CBE78CE
2 changed files with 58 additions and 3 deletions

39
feed.xml Normal file
View file

@ -0,0 +1,39 @@
<?xml version="1.0" encoding="UTF-8" ?>
<rss version="2.0">
<channel>
<title>askiiart.net</title>
<description>The feed for askiiart.net, I guess</description>
<link>https://askiiart.net</link>
<lastBuildDate>Mon, 25 Sep 2023 19:29:33 +0000</lastBuildDate>
<item>
<title>Portfolio</title>
<link>https://askiiart.net/portfolio.html</link>
</item>
<item>
<title>Marlin Boot Animations</title>
<link>https://askiiart.net/blog/marlin-boot-animations.html</link>
</item>
<item>
<title>askiiart's site</title>
<link>https://askiiart.net/index.html</link>
</item>
<item>
<title>My Stack</title>
<link>https://askiiart.net/stack.html</link>
</item>
<item>
<title>Wishlist</title>
<link>https://askiiart.net/wishlist.html</link>
</item>
<item>
<title>Resume</title>
<link>https://askiiart.net/resume.html</link>
</item>
<item>
<title>Using JSON with docker compose</title>
<link>https://askiiart.net/til/using-json-with-docker-compose.html</link>
</item>
</channel>
</rss>

View file

@ -1,6 +1,6 @@
#!/bin/bash
set -e
dir=$(cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd)
git status --porcelain | awk 'match($1, "(M|A|\?\?)"){print $2}' | while read -r item; do
if [[ ${item} == *.md ]]; then
@ -10,4 +10,20 @@ git status --porcelain | awk 'match($1, "(M|A|\?\?)"){print $2}' | while read -r
fi
done
# Makes RSS feed (feed.xml)
# Currently missing description and pubDate
# Based off https://en.wikipedia.org/wiki/RSS, particularly the example
printf "<?xml version=\"1.0\" encoding=\"UTF-8\" ?>\n<rss version=\"2.0\">\n\n<channel>\n <title>askiiart.net</title>\n <description>The feed for askiiart.net, I guess</description>\n <link>https://askiiart.net</link>\n <lastBuildDate>$(TZ='UTC' date --rfc-2822)</lastBuildDate>" > feed.xml
find . -name "*.html" | while read -r item; do
# Skip template.html
if [[ ${item} == "./template.html" ]]; then
continue
fi
item="${item%.*}"
item="${item#./}"
TITLE=$(grep -m 1 -oP '(?<=^# ).*' ${item}.md | cat)
printf "\n <item>\n <title>${TITLE}</title>\n <link>https://askiiart.net/${item}.html</link>\n </item>" >>feed.xml
done
printf "\n\n</channel>\n</rss>" >> feed.xml
find . \( ! -regex './md2html.sh' \) -type f | xargs sed -i 's/sourceCode /language-/g'