Blog
-
${items}
#!/usr/bin/env bash set -euo pipefail # Generate site/blog/index.html from blog/*.md frontmatter. # Reads title, description, date from YAML frontmatter in each post. # Sorts newest first (by date string — "April 2026" > "March 2026"). OUT="site/blog/index.html" # Extract frontmatter fields from a markdown file extract() { local file="$1" field="$2" sed -n '/^---$/,/^---$/p' "$file" | grep "^${field}:" | sed "s/^${field}: *//" } # Collect posts: "date|name|title|description" per line posts="" sources="blog/*.md" if [ "${BLOG_INCLUDE_DRAFTS:-}" = "1" ] && ls drafts/*.md >/dev/null 2>&1; then sources="blog/*.md drafts/*.md" fi for f in $sources; do name=$(basename "$f" .md) title=$(extract "$f" title) desc=$(extract "$f" description) date=$(extract "$f" date) posts+="${date}|${name}|${title}|${desc}"$'\n' done # Sort by ISO date (YYYY-MM-DD), newest first posts=$(echo "$posts" | grep -v '^$' | sort -t'|' -k1 -r) # Format ISO date (YYYY-MM-DD) to "Month YYYY" format_date() { local months=(January February March April May June July August September October November December) local y="${1%%-*}" local m="${1#*-}"; m="${m%%-*}"; m=$((10#$m)) echo "${months[$((m-1))]} $y" } # Generate post list items items="" while IFS='|' read -r date name title desc; do display_date=$(format_date "$date") items+="