tildelog/lib/list_posts.sh

21 lines
542 B
Bash

#!/usr/bin/env bash
# Displays a list of the posts
list_posts() {
declare date_format
declare date_locale
if ls ./*.html > /dev/null; then
echo "No posts yet. Use 'bb.sh post' to create one" && return
fi
lines=""
n=1
while IFS='' read -r i; do
is_boilerplate_file "$i" && continue
line="$n # $(get_post_title "$i") # $(LC_ALL=$date_locale date -r "$i" +"$date_format")"
lines+=$line\\n
n=$(( n + 1 ))
done < <(ls -t ./*.html)
echo -e "$lines" | column -t -s "#"
}