52 lines
1.2 KiB
Bash
52 lines
1.2 KiB
Bash
|
#!/bin/bash
|
||
|
|
||
|
set -e
|
||
|
|
||
|
pd=/usr/bin/pandoc
|
||
|
g=/bin/grep
|
||
|
postDir=/home/vilmibm/blog
|
||
|
|
||
|
function makeHTML() {
|
||
|
htmlDir=/home/vilmibm/public_html/blog
|
||
|
htmlIndexTmpl=/home/vilmibm/blog/index.tmpl.html
|
||
|
htmlIndex=/home/vilmibm/public_html/blog/index.html
|
||
|
|
||
|
|
||
|
if [ -e "${htmlIndex}" ]
|
||
|
then
|
||
|
cp $htmlIndex "${htmlIndex}.bak"
|
||
|
fi
|
||
|
|
||
|
cp $htmlIndexTmpl $htmlIndex
|
||
|
|
||
|
cd $postDir > /dev/null
|
||
|
for p in $(ls *.md)
|
||
|
do
|
||
|
pubdate=$($g "pubdate:" $p | sed 's/pubdate://')
|
||
|
title=$($g "title:" $p | sed 's/title://')
|
||
|
slug=$($g "slug:" $p | sed 's/slug://' | tr -d \[:blank:\])
|
||
|
if [ -z "$pubdate" ] || [ -z "$title" ]
|
||
|
then
|
||
|
echo "warning: missing at least one of: pubdate, slug, title in ${p}"
|
||
|
else
|
||
|
echo "<h2 class=\"title\">${title}</h2>" >> $htmlIndex
|
||
|
echo "<a class=\"pubdate\" name=\"${slug}\" href=\"https://tilde.town/~vilmibm/blog#${slug}\">${pubdate}</a>" >> $htmlIndex
|
||
|
echo "<div class=\"post\">" >> $htmlIndex
|
||
|
$g -v "pubdate:" $p | $g -v "title:" | $g -v "slug:" |$pd -fmarkdown -thtml >> $htmlIndex
|
||
|
echo "</div>" >> $htmlIndex
|
||
|
fi
|
||
|
done
|
||
|
|
||
|
echo "</body></html>" >> $htmlIndex
|
||
|
}
|
||
|
|
||
|
#function makeGopher() {
|
||
|
# # TODO
|
||
|
#}
|
||
|
#
|
||
|
#function makeGemini() {
|
||
|
# # TODO
|
||
|
#}
|
||
|
|
||
|
makeHTML
|