#!/usr/bin/env bash

set -euo pipefail

cat << EOF
---
title: Articles
---

EOF

listing=""
for file in *.md; do
    if [ $file = "index.md" ]; then
        continue
    fi

    link=$(basename $file .md).html
    date=$(sed -n 's/date: \(.*\)/\1/p' $file)
    title=$(sed -n 's/title: \(.*\)/\1/p' $file)
    listing="$listing- $date: [$title]($link)\n"
done
echo -e $listing | sort --reverse
