homepage/content/blog/new

40 lines
570 B
Plaintext
Raw Permalink Normal View History

2023-09-25 12:23:31 -06:00
#! /bin/sh
cd $(dirname $0)
case "$1" in
""|-*)
cat <<EOD 1>&2; exit 1
Usage: $0 SLUG [TITLE]
Makes a new blog page with the slug SLUG.
Also uses SLUG for the page title,
unless you provide TITLE.
You can, of course, change this later.
EOD
esac
SLUG="$1"
TITLE="${2:-$SLUG}"
2023-09-25 17:23:49 -06:00
YYYY="$(date +%Y)"
MM="$(date +%m)"
DD="$(date +%d)"
2023-09-25 12:23:31 -06:00
2024-08-14 21:24:18 -06:00
slug=$(echo "$SLUG" | tr 'A-Z ' 'a-z-' | tr -d ':')
2023-09-25 17:23:49 -06:00
dir="$YYYY/$MM-$DD-$slug"
index="$dir/index.md"
2023-09-25 12:23:31 -06:00
2023-09-25 17:23:49 -06:00
mkdir -p "$dir"
cat <<EOD >"$index"
2023-09-25 12:23:31 -06:00
---
2024-08-14 21:24:18 -06:00
title: "$TITLE"
2023-09-25 17:23:49 -06:00
date: $YYYY-$MM-$DD
2023-09-25 12:23:31 -06:00
tags:
- untagged
---
EOD
echo $index
2024-11-28 13:37:01 -07:00
emacs $index