#! /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" } read_time() { minu="$(eva -f 1 $1/150 | xargs)" echo "$minu" } height() { cm="$(eva -f 2 $1*18*0.0222 | xargs)" echo "$cm" } link_wrapper() { # 1 - id # 2 - title # 3 - date # 4 - read time echo -ne "
$3
$2 $4 min " } cat > ./docs/index.html << EOF peppe.rs

n

nerdypepper's μblog

EOF # 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") stats=$(wc "$file") words="$(echo $stats | awk '{print $2}')" lines="$(echo $stats | awk '{print $1}')" r_time="$(read_time $words)" height="$(height $lines)" post_title=$(title_wrapper "$id") post_date=$(date -r "$file" "+%d/%m — %Y") post_link=$(link_wrapper "${id%.*}" "$post_title" "$post_date" "$r_time" "$height") echo -ne "$post_link" >> docs/index.html id="${id%.*}" mkdir -p "docs/posts/$id" esh -s /bin/bash \ -o "docs/posts/$id/index.html" \ "./post.esh" \ file="$file" \ date="$post_date" \ title="$post_title" \ read_time="$r_time" \ height="$height" done cat >> ./docs/index.html << EOF
EOF