#!/bin/sh
domain="https://adast.dk"
# Check the operating system
os_name=$(uname -s)
if [ "$os_name" = "OpenBSD" ]; then
alias sed=gsed
alias date=gdate
alias rsync=openrsync
elif [ "$os_name" = "Darwin" ]; then
alias sed=gsed
alias date=gdate
fi
set -eu
MARKDOWN=smu
IFS=' '
# Create tab separated file with filename, title, creation date, last update
index_tsv() {
for f in "$1"/*.md
do
title=$(sed -n '/^# /{s/# //p; q}' "$f")
printf '%s\t%s\t%s\t%s\n' "$f" "${title:="No Title"}"
done
}
index_html() {
# Print header
title=$(sed -n '/^# /{s/# //p; q}' index.md)
sed "s/{{TITLE}}/$title/" header.html
# Intro text
$MARKDOWN index.md
echo '
'
# Posts
while read -r f title created; do
link=$(echo "$f" | sed -E 's|.*/(.*).md|\1/|')
created=$(echo $(head -3 "$f" | tail -1))
echo "