30 lines
1.3 KiB
Bash
Executable file
30 lines
1.3 KiB
Bash
Executable file
#!/bin/bash
|
|
set -e
|
|
|
|
|
|
git status --porcelain | awk 'match($1, "(M|A|\?\?)"){print $2}' | while read -r item; do
|
|
if [[ ${item} == *.md ]]; then
|
|
item="${item%.*}"
|
|
echo "Currently processing ${item}"
|
|
pandoc -f markdown-smart --data-dir . --template ${dir}/template.html -t html -o ${item}.html ${item}.md --metadata title="$(grep -m 1 -oP '(?<=^# ).*' ${item}.md | cat)"
|
|
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'
|