diff --git a/Makefile b/Makefile index 4d645b3..a941e67 100644 --- a/Makefile +++ b/Makefile @@ -27,7 +27,7 @@ $(ODIR)/posts/%/index.html: content/posts/%/note.md cat "$<" | ./bin/mdpage.sh > "$@" $(ODIR)/posts/index.html: $(POSTS_SRC) - ./bin/toc.sh content/posts "/posts" | awk -f ./bin/markdown.awk | ./bin/page.sh Posts > "$@" + ./bin/toc.sh content/posts "/posts" | awk -f ./bin/markdown.awk | ./bin/page.sh Posts "" > "$@" $(ODIR)/rss.xml: $(POSTS_SRC) ./bin/rss.sh content/posts "https://knazarov.com" "/posts" > "$@" diff --git a/bin/mdpage.sh b/bin/mdpage.sh index 930d40b..bba60a9 100755 --- a/bin/mdpage.sh +++ b/bin/mdpage.sh @@ -3,37 +3,40 @@ set -e render() { - NOTITLE="$1" - LASTLINE="" - TITLE="" + NOTITLE="$1" + LASTLINE="" + TITLE="" - while read -r line ; do - if [[ "$line" =~ ^Subject:\ .*$ ]]; then - TITLE="${line#* }" - fi - if [[ ! "$line" =~ ^[^\ ]*:\ .*$ ]]; then - LASTLINE="$line" - break - fi - done + while read -r line ; do + if [[ "$line" =~ ^Subject:\ .*$ ]]; then + TITLE="${line#* }" + fi + if [[ "$line" =~ ^X-Date:\ .*$ ]]; then + DATE="${line#* }" + fi + if [[ ! "$line" =~ ^[^\ ]*:\ .*$ ]]; then + LASTLINE="$line" + break + fi + done - { - [ "$NOTITLE" == "0" ] && echo "# $TITLE"; - echo "$LASTLINE"; - cat - } | awk -f ./bin/markdown.awk | ./bin/page.sh "$TITLE" + { + [ "$NOTITLE" == "0" ] && echo "# $TITLE"; + echo "$LASTLINE"; + cat + } | awk -f ./bin/markdown.awk | ./bin/page.sh "$TITLE" "$DATE" } NOTITLE=0 if [ "$1" == "--notitle" ]; then - NOTITLE=1 + NOTITLE=1 fi if [ -t 0 ]; then - echo "Missing Markdown body" - exit 1 + echo "Missing Markdown body" + exit 1 fi render "$NOTITLE" diff --git a/bin/page.sh b/bin/page.sh index 016735f..2503ea6 100755 --- a/bin/page.sh +++ b/bin/page.sh @@ -2,22 +2,31 @@ expand() { TITLE="$1" + DATE="$2" cat <<-"EOF"
+EOF + if [ "$DATE" != "" ]; then + echo " " + echo " " + echo " " + fi + + cat <<-"EOF"