-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcreate_post.sh
More file actions
executable file
·61 lines (49 loc) · 1.8 KB
/
create_post.sh
File metadata and controls
executable file
·61 lines (49 loc) · 1.8 KB
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
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
#!/bin/bash
# Calculate the next Tuesday (or today if it's Tuesday)
current_weekday=$(date +%w) # 0=Sun ... 6=Sat
days_to_tuesday=$(( (2 - current_weekday + 7) % 7 ))
# Add the calculated days (compatible with both macOS and Linux)
if date -v +0d &>/dev/null; then
# macOS (BSD date)
tuesday=$(date -v "+${days_to_tuesday}d" +%Y-%m-%d)
else
# Linux (GNU date)
tuesday=$(date -d "+${days_to_tuesday} days" +%Y-%m-%d)
fi
year=${tuesday%%-*} # 2026
month=${tuesday#*-}; month=${month%-*} # 02
day=${tuesday##*-} # 24
# Define paths
folder_path="docs/posts/$year/$month/$day"
file_path="$folder_path/index.md"
# Create the directory (including parents) if it doesn't exist
mkdir -p "$folder_path"
# YAML frontmatter
cat << EOF > "$file_path"
---
title: "Your Blog Post Title"
date: $tuesday
authors:
- chris | norm | omar
categories:
# use existing categories when possible, in YAML list format.
- CATEGORY_ONE
- CATEGORY_TWO
tags:
# use existing tags when possible, in YAML list format.
- TAG_ONE
- TAG_TWO
---
TOPIC_INTRODUCTION_HERE
Everyone and anyone are welcome to [join](https://weeklydevchat.com/join/) as long as you are kind, supportive, and respectful of others. Zoom link will be posted at 12pm MDT.

EOF
echo "Blog post template created at $file_path"
echo ""
echo "Reminder: Use existing categories and tags when possible."
# Optionally suggest existing tags and categories using the helper script, if available
if command -v python3 &>/dev/null; then
python3 "./scripts/find_tags_categories.py" || echo "Warning: tag/category suggestion script failed, but the blog post file was created."
else
echo "Warning: Python 3 was not found on this system. Skipping tag/category suggestion step."
fi