website/articles/generate_listing.sh

24 lines
394 B
Bash
Raw Normal View History

2019-06-19 19:14:23 +02:00
#!/usr/bin/env bash
set -euo pipefail
cat << EOF
---
title: Articles
---
EOF
2019-06-20 10:08:04 +02:00
listing=""
2019-06-19 19:14:23 +02:00
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)
2019-06-20 10:08:04 +02:00
listing="$listing- $date: [$title]($link)\n"
2019-06-19 19:14:23 +02:00
done
2019-06-20 10:08:04 +02:00
echo -e $listing | sort --reverse