#! /usr/bin/env bash
post_title() {
# remove extension
# snake to title case
echo "$1" | sed -E -e "s/\..+$//g" -e "s/_(.)/ \u\1/g" -e "s/^(.)/\u\1/g"
}
post_wrapper() {
# 1 - post id
# 2 - post content
title="$( post_title $1 )"
d="none";
if [ "$4" = "1" ]; then
d="block"
fi
echo -ne "
"
}
# meta
echo "
n
" > ./docs/index.html
# script
echo ' ' >> docs/index.html
# body
echo "
n
" >> docs/index.html
# begin posts
echo "
" >> docs/index.html
# posts
posts=$(ls -t ./posts);
first_visible="1"
for f in $posts; do
file="./posts/"$f
echo "generating post $file"
id="${file##*/}" # ill name my posts just fine
html=$(lowdown "$file")
post_date=$(date -r "$file" "+%d/%m %Y")
post_div=$(post_wrapper "$id" "$html" "$post_date" "$first_visible")
echo -ne "$post_div" >> docs/index.html
first_visible="0"
done
echo "
" >> docs/index.html