Files
alexanderwhitestone.com/scripts/aw-post
Alexander Whitestone 4fcd6a795f feat: complete The Scrolls blog — post pages, linked index, RSS, auto-rebuild (#217)
- build.py: generates individual HTML post pages from markdown
- build.py: index now links to individual post pages
- build.py: minimal markdown-to-HTML converter (paragraphs, headers, bold, italic, code, links, blockquotes)
- aw-post: auto-rebuilds blog after creating a new post
- .gitignore: excludes generated post HTML (build artifacts)
- Sample post: Hello World with content exercising all formatters
- Atom feed now includes full HTML content in entries

Closes #217, partially addresses #218 (RSS feed) and #219 (CLI tool)
2026-03-18 21:42:56 -04:00

53 lines
1.0 KiB
Bash
Executable File

#!/usr/bin/env bash
# aw-post — Quick-post a scroll from the command line
#
# Usage:
# aw-post "Title of the Post"
# aw-post "Title" < body.md
# echo "Post body here" | aw-post "Title"
#
# Creates a new markdown file in blog/posts/ with frontmatter,
# then rebuilds the blog index, post pages, and RSS feed.
set -euo pipefail
REPO_DIR="$(cd "$(dirname "$0")/.." && pwd)"
BLOG_DIR="${REPO_DIR}/blog/posts"
if [ $# -lt 1 ]; then
echo "Usage: aw-post \"Title of the Post\""
echo " Pipe or redirect body content via stdin."
exit 1
fi
TITLE="$1"
DATE=$(date +%Y-%m-%d)
SLUG=$(echo "$TITLE" | tr '[:upper:]' '[:lower:]' | tr ' ' '-' | tr -cd 'a-z0-9-')
FILENAME="${DATE}-${SLUG}.md"
FILEPATH="${BLOG_DIR}/${FILENAME}"
if [ -f "$FILEPATH" ]; then
echo "Error: $FILEPATH already exists"
exit 1
fi
# Read body from stdin if available
BODY=""
if [ ! -t 0 ]; then
BODY=$(cat)
fi
cat > "$FILEPATH" << EOF
---
title: "${TITLE}"
date: ${DATE}
---
${BODY}
EOF
echo "Created: ${FILEPATH}"
# Rebuild the blog
python3 "${REPO_DIR}/scripts/build.py"