#! /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 )"
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);
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")
echo -ne "$post_div" >> docs/index.html
first_visible="0"
done
echo "
" >> docs/index.html