#!/bin/sh

SNIPPETS_DIR=./snippets
SNIPPETS_INDEX=snippets.md

echo "# Snippets" > $SNIPPETS_INDEX
for I in `ls $SNIPPETS_DIR | sort -r`; do
  TITLE=`head -4 $SNIPPETS_DIR/$I | awk '/^title:/ { sub($1 FS, ""); print }'`
  DATE=`head -4 $SNIPPETS_DIR/$I | awk '/^date:/ { sub($1 FS, ""); print }'`
  echo "- [$TITLE ($DATE)]($SNIPPETS_DIR/$I)" >> $SNIPPETS_INDEX
done

