-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathjustfile
More file actions
27 lines (22 loc) · 756 Bytes
/
justfile
File metadata and controls
27 lines (22 loc) · 756 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# Create a new blog post
new-blog title:
#!/bin/zsh
set -e
# Get today's date in YYYY-MM-DD format
date=$(date +%Y-%m-%d)
# Convert title to kebab-case (lowercase, replace spaces with hyphens)
name=$(printf '%s' "{{ title }}" | \
tr '[:upper:]' '[:lower:]' | \
sed 's/[^a-z0-9 ]//g' | \
tr ' ' '-' | \
sed 's/-\+/-/g' | \
sed 's/^-\|-$//' \
)
# Create directory
dir="blog/posts/${date}-${name}"
mkdir -p "$dir"
# Copy template and update frontmatter
cp blog/_post-template.qmd "$dir/index.qmd"
sed -i '' "s/title: \"\"/title: \"{{ title }}\"/" "$dir/index.qmd"
sed -i '' "s/date: \"\"/date: \"$date\"/" "$dir/index.qmd"
echo "Created blog post: $dir"