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" - EOF +EOF - echo " $TITLE" + echo " $TITLE" - cat <<-"EOF" + cat <<-"EOF" - + -
+
EOF - cat - cat <<-"EOF" -
+ cat + cat <<-"EOF" +
- EOF +EOF } if [ -z "$1" ]; then - echo "Missing page title" - exit 1 + echo "Missing page title" + exit 1 fi if [ -z "$2" ] && [ -t 0 ]; then - echo "Missing page body" - exit 1 + echo "Missing page body" + exit 1 fi if [ ! -t 0 ]; then - expand "$1" - exit 0 + expand "$1" "$2" + exit 0 fi -expand "$1" < "$2" +expand "$1" "$2" < "$3" diff --git a/content/posts/enjoying_internet_with_prefers_reduced_motion/note.md b/content/posts/enjoying_internet_with_prefers_reduced_motion/note.md index 7b00d78..88fddc7 100644 --- a/content/posts/enjoying_internet_with_prefers_reduced_motion/note.md +++ b/content/posts/enjoying_internet_with_prefers_reduced_motion/note.md @@ -1,6 +1,6 @@ X-Date: 2023-08-17T23:00:00Z X-Note-Id: cc2f05b8-6a95-452a-875b-887fde269c35 -Subject: Enjoing internet with prefers-reduced-motion +Subject: Enjoying internet with prefers-reduced-motion X-Slug: enjoying_internet_with_prefers_reduced_motion I didn't know this before, but you can actually set a special toggle in your operating system