Skip to content

Commit 296edda

Browse files
committed
This script crreates an empty post for the next (or current) Tuesday.
1 parent a4037ed commit 296edda

File tree

1 file changed

+39
-0
lines changed

1 file changed

+39
-0
lines changed

create_post.sh

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
#!/bin/bash
2+
3+
# Calculate the next Tuesday (or today if it's Tuesday)
4+
# In Linux date, weekday: 0=Sunday, 1=Monday, ..., 6=Saturday
5+
current_weekday=$(date +%w) # 0=Sun ... 6=Sat
6+
days_to_tuesday=$(( (2 - current_weekday + 7) % 7 ))
7+
8+
# If today is Tuesday, days_to_tuesday will be 0 → perfect
9+
# Add the calculated days
10+
tuesday=$(date -d "+${days_to_tuesday} days" +%Y-%m-%d)
11+
12+
year=$(date -d "$tuesday" +%Y)
13+
month=$(date -d "$tuesday" +%02m)
14+
day=$(date -d "$tuesday" +%02d)
15+
16+
# Define paths
17+
folder_path="docs/posts/$year/$month/$day"
18+
file_path="$folder_path/index.md"
19+
20+
# Create the directory (including parents) if it doesn't exist
21+
mkdir -p "$folder_path"
22+
23+
# YAML frontmatter
24+
cat << EOF > "$file_path"
25+
---
26+
title: "Your Blog Post Title"
27+
date: $tuesday
28+
authors:
29+
- chris | norm | omar
30+
---
31+
32+
TOPIC_INTRODUCTION_HERE
33+
34+
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.
35+
36+
![alt text](${tuesday}_image_filename.webp)
37+
EOF
38+
39+
echo "Blog post template created at $file_path"

0 commit comments

Comments
 (0)