#! /usr/bin/env bash
title_wrapper() {
# remove extension
# snake to title case
echo "$1" | sed -E -e "s/\..+$//g" -e "s/_(.)/ \u\1/g" -e "s/^(.)/\u\1/g"
}
link_wrapper() {
# 1 - id
# 2 - title
# 2 - date
echo -ne "
"
}
# meta
echo "
n
" > ./docs/index.html
# body
echo "
n
" >> docs/index.html
# begin posts
echo "
" >> docs/index.html
# posts
posts=$(ls -t ./posts);
mkdir -p docs/posts
for f in $posts; do
file="./posts/"$f
echo "generating post $file"
id="${file##*/}" # ill name my posts just fine
# generate posts
html=$(lowdown "$file")
commit="$(git log -n1 --oneline "$file" | sed -e 's/\s.*$//g')"
post_title=$(title_wrapper "$id")
post_date=$(date -r "$file" "+%d/%m %Y")
post_link=$(link_wrapper "${id%.*}" "$post_title" "$post_date")
echo -ne "$post_link" >> docs/index.html
esh -s /bin/bash \
-o "docs/posts/${id%.*}.html" \
"./post.esh" \
file="$file" \
date="$post_date" \
commit="$commit" \
title="$post_title"
first_visible="0"
done
echo "
" >> docs/index.html