From c1cc945d512b1f06e7958a428d9e8d5c19e5c3a7 Mon Sep 17 00:00:00 2001 From: Chris C Date: Tue, 24 Feb 2026 09:10:59 -0700 Subject: [PATCH 1/7] Add categories and tags placeholders to blog post templates --- create_post.ps1 | 8 +++++++- create_post.sh | 10 +++++++++- 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/create_post.ps1 b/create_post.ps1 index 32455617..eaf8da05 100644 --- a/create_post.ps1 +++ b/create_post.ps1 @@ -43,6 +43,10 @@ title: "$title" date: $date authors: - chris | norm | omar +categories: + - CATEGORY_HERE (use existing categories when possible) +tags: + - TAG_HERE (use existing tags when possible) --- TOPIC_INTRODUCTION_HERE @@ -55,4 +59,6 @@ Everyone and anyone are welcome to [join](https://weeklydevchat.com/join/) as lo # Write the content to the file Set-Content -Path $filePath -Value $yamlContent -Write-Output "Blog post template created at $filePath" \ No newline at end of file +Write-Output "Blog post template created at $filePath" +Write-Output "" +Write-Output "Reminder: Use existing categories and tags when possible." \ No newline at end of file diff --git a/create_post.sh b/create_post.sh index 596ee4ac..917f0cab 100644 --- a/create_post.sh +++ b/create_post.sh @@ -27,6 +27,10 @@ title: "Your Blog Post Title" date: $tuesday authors: - chris | norm | omar +categories: + - CATEGORY_HERE +tags: + - TAG_HERE --- TOPIC_INTRODUCTION_HERE @@ -36,4 +40,8 @@ Everyone and anyone are welcome to [join](https://weeklydevchat.com/join/) as lo ![alt text](${tuesday}_image_filename.webp) EOF -echo "Blog post template created at $file_path" \ No newline at end of file +echo "Blog post template created at $file_path" +echo "" +echo "Reminder: Use existing categories and tags when possible." +echo " Existing categories: Business, Career, Community, Culture, Security, Technical" +echo " To see existing tags, run: grep -rh ' - ' docs/posts/*/index.md docs/posts/*/*/index.md docs/posts/*/*/*/index.md | grep -v '^authors' | sort -u" \ No newline at end of file From 602c2f02c47d55a516ba2d76ff81db0e128f118a Mon Sep 17 00:00:00 2001 From: Chris C Date: Tue, 24 Feb 2026 09:14:14 -0700 Subject: [PATCH 2/7] Refactor reminder messages in create_post.sh to be consistent with the PowerShell version. --- create_post.sh | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/create_post.sh b/create_post.sh index 917f0cab..41ec0889 100644 --- a/create_post.sh +++ b/create_post.sh @@ -42,6 +42,4 @@ EOF echo "Blog post template created at $file_path" echo "" -echo "Reminder: Use existing categories and tags when possible." -echo " Existing categories: Business, Career, Community, Culture, Security, Technical" -echo " To see existing tags, run: grep -rh ' - ' docs/posts/*/index.md docs/posts/*/*/index.md docs/posts/*/*/*/index.md | grep -v '^authors' | sort -u" \ No newline at end of file +echo "Reminder: Use existing categories and tags when possible." \ No newline at end of file From 5a5618e49c9319d8ab7de73035a458dd7aafbe1c Mon Sep 17 00:00:00 2001 From: Chris C Date: Tue, 24 Feb 2026 09:19:30 -0700 Subject: [PATCH 3/7] Refactor date calculation in create_post.sh for compatibility with macOS and Linux --- create_post.sh | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/create_post.sh b/create_post.sh index 41ec0889..6bfb826e 100644 --- a/create_post.sh +++ b/create_post.sh @@ -1,17 +1,21 @@ #!/bin/bash # Calculate the next Tuesday (or today if it's Tuesday) -# In Linux date, weekday: 0=Sunday, 1=Monday, ..., 6=Saturday current_weekday=$(date +%w) # 0=Sun ... 6=Sat days_to_tuesday=$(( (2 - current_weekday + 7) % 7 )) -# If today is Tuesday, days_to_tuesday will be 0 → perfect -# Add the calculated days -tuesday=$(date -d "+${days_to_tuesday} days" +%Y-%m-%d) - -year=$(date -d "$tuesday" +%Y) -month=$(date -d "$tuesday" +%02m) -day=$(date -d "$tuesday" +%02d) +# 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" From e768f37e34ff6262d1bdf6ce4179d0d24f832696 Mon Sep 17 00:00:00 2001 From: Chris C Date: Wed, 25 Feb 2026 09:25:46 -0700 Subject: [PATCH 4/7] Add comment to category and tag section reminding people to use existing categories/tags when possible. Based on the feedback from Norm in the PR review. --- README.md | 6 ++++-- create_post.ps1 | 8 ++++++-- create_post.sh | 8 ++++++-- 3 files changed, 16 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index 3fcca455..f83a430a 100644 --- a/README.md +++ b/README.md @@ -97,9 +97,11 @@ These scripts will: authors: - chris categories: - - Category Name + - CategoryOne + - CategoryTwo tags: - - relevant-tag + - relevant-tag-one + - relevent-tag-two --- ``` diff --git a/create_post.ps1 b/create_post.ps1 index eaf8da05..30448a9b 100644 --- a/create_post.ps1 +++ b/create_post.ps1 @@ -44,9 +44,13 @@ date: $date authors: - chris | norm | omar categories: - - CATEGORY_HERE (use existing categories when possible) + # use existing categories when possible, in YAML list format. + - CATEGORY_ONE + - CATEGORY_TWO tags: - - TAG_HERE (use existing tags when possible) + # use existing tags when possible, in YAML list format. + - TAG_ONE + - TAG_TWO --- TOPIC_INTRODUCTION_HERE diff --git a/create_post.sh b/create_post.sh index 6bfb826e..a861e90c 100644 --- a/create_post.sh +++ b/create_post.sh @@ -32,9 +32,13 @@ date: $tuesday authors: - chris | norm | omar categories: - - CATEGORY_HERE + # use existing categories when possible, in YAML list format. + - CATEGORY_ONE + - CATEGORY_TWO tags: - - TAG_HERE + # use existing tags when possible, in YAML list format. + - TAG_ONE + - TAG_TWO --- TOPIC_INTRODUCTION_HERE From 7700ed37f1731ee5701b03603453165dd0cb22bc Mon Sep 17 00:00:00 2001 From: Chris C Date: Wed, 25 Feb 2026 09:34:32 -0700 Subject: [PATCH 5/7] Fix indentation in YAML frontmatter comments and correct typo in README.md --- README.md | 2 +- create_post.sh | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index f83a430a..21619ac9 100644 --- a/README.md +++ b/README.md @@ -101,7 +101,7 @@ These scripts will: - CategoryTwo tags: - relevant-tag-one - - relevent-tag-two + - relevant-tag-two --- ``` diff --git a/create_post.sh b/create_post.sh index a861e90c..adb2dc98 100644 --- a/create_post.sh +++ b/create_post.sh @@ -32,11 +32,11 @@ date: $tuesday authors: - chris | norm | omar categories: - # use existing categories when possible, in YAML list format. + # use existing categories when possible, in YAML list format. - CATEGORY_ONE - CATEGORY_TWO tags: - # use existing tags when possible, in YAML list format. + # use existing tags when possible, in YAML list format. - TAG_ONE - TAG_TWO --- From 6073e578d6408b304b091b0a17820dc2134948da Mon Sep 17 00:00:00 2001 From: "Norman Lorrain (lille)" Date: Wed, 25 Feb 2026 13:15:37 -0700 Subject: [PATCH 6/7] Add a script to harvest tags and categories. Initially by Grok, then fine-tuned. --- create_post.sh | 18 +++++---- docs/find_tags_categories.py | 77 ++++++++++++++++++++++++++++++++++++ 2 files changed, 88 insertions(+), 7 deletions(-) create mode 100644 docs/find_tags_categories.py diff --git a/create_post.sh b/create_post.sh index adb2dc98..62336db0 100644 --- a/create_post.sh +++ b/create_post.sh @@ -1,8 +1,8 @@ #!/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 )) +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 @@ -13,9 +13,10 @@ else tuesday=$(date -d "+${days_to_tuesday} days" +%Y-%m-%d) fi -year=${tuesday%%-*} # 2026 -month=${tuesday#*-}; month=${month%-*} # 02 -day=${tuesday##*-} # 24 +year=${tuesday%%-*} # 2026 +month=${tuesday#*-} +month=${month%-*} # 02 +day=${tuesday##*-} # 24 # Define paths folder_path="docs/posts/$year/$month/$day" @@ -25,7 +26,7 @@ file_path="$folder_path/index.md" mkdir -p "$folder_path" # YAML frontmatter -cat << EOF > "$file_path" +cat <"$file_path" --- title: "Your Blog Post Title" date: $tuesday @@ -50,4 +51,7 @@ EOF echo "Blog post template created at $file_path" echo "" -echo "Reminder: Use existing categories and tags when possible." \ No newline at end of file +echo "Reminder: Use existing categories and tags when possible." + +python "./docs/find_tags_categories.py" + diff --git a/docs/find_tags_categories.py b/docs/find_tags_categories.py new file mode 100644 index 00000000..fdf3cb22 --- /dev/null +++ b/docs/find_tags_categories.py @@ -0,0 +1,77 @@ +#!/usr/bin/env python3 +""" +Lists all unique tags and categories found in YAML front matter of .md files. +Looks for both 'tags' and 'categories' keys (common variations). +""" + +import os +import yaml +from pathlib import Path +from typing import Set + +DOCS_DIR = Path(__file__).parent +EXTENSIONS = (".md", ".markdown", ".mkd") + +def extract_frontmatter(file_path: Path) -> dict: + """Extract YAML front matter if present.""" + content = file_path.read_text(encoding="utf-8") + if not content.startswith("---"): + return {} + try: + parts = content.split("---", 2) + if len(parts) < 3: + return {} + fm = yaml.safe_load(parts[1]) or {} + return fm if isinstance(fm, dict) else {} + except yaml.YAMLError: + print(f"Warning: Invalid YAML in {file_path}") + return {} + +def collect_tags() -> tuple[Set[str], Set[str]]: + all_tags: Set[str] = set() + all_categories: Set[str] = set() + + docs_path = Path(DOCS_DIR) + if not docs_path.is_dir(): + print(f"Error: Directory not found: {docs_path}") + return all_tags, all_categories + + for file_path in docs_path.rglob("*"): + if not file_path.is_file() or not file_path.suffix.lower() in EXTENSIONS: + continue + + fm = extract_frontmatter(file_path) + + # Handle 'tags' + tags = fm.get("tags", []) + if isinstance(tags, str): + tags = [t.strip() for t in tags.split(",") if t.strip()] + if isinstance(tags, list): + all_tags.update(str(t).strip() for t in tags if t) + + # Handle 'categories' (sometimes used instead / in addition) + cats = fm.get("categories", []) + if isinstance(cats, str): + cats = [c.strip() for c in cats.split(",") if c.strip()] + if isinstance(cats, list): + all_categories.update(str(c).strip() for c in cats if c) + + all_tags.discard('TAG_ONE') + all_tags.discard('TAG_TWO') + all_categories.discard('CATEGORY_ONE') + all_categories.discard('CATEGORY_TWO') + + return all_tags, all_categories + + +def main(): + tags, categories = collect_tags() + + print(f"\nExisting categories: {', '.join(sorted(categories))}", ) + print(f"\nExisting tags: {', '.join(sorted(tags))}", ) + + +if __name__ == "__main__": + main() + + From 57a0a98e8cfd99ba83514da3216f3972f0e571de Mon Sep 17 00:00:00 2001 From: "Norman Lorrain (lille)" Date: Wed, 25 Feb 2026 13:30:58 -0700 Subject: [PATCH 7/7] restored the mistakenly auto-formatted lines --- create_post.sh | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/create_post.sh b/create_post.sh index 62336db0..a0777946 100644 --- a/create_post.sh +++ b/create_post.sh @@ -1,8 +1,8 @@ #!/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)) +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 @@ -13,10 +13,9 @@ else tuesday=$(date -d "+${days_to_tuesday} days" +%Y-%m-%d) fi -year=${tuesday%%-*} # 2026 -month=${tuesday#*-} -month=${month%-*} # 02 -day=${tuesday##*-} # 24 +year=${tuesday%%-*} # 2026 +month=${tuesday#*-}; month=${month%-*} # 02 +day=${tuesday##*-} # 24 # Define paths folder_path="docs/posts/$year/$month/$day" @@ -26,7 +25,7 @@ file_path="$folder_path/index.md" mkdir -p "$folder_path" # YAML frontmatter -cat <"$file_path" +cat << EOF > "$file_path" --- title: "Your Blog Post Title" date: $tuesday @@ -54,4 +53,3 @@ echo "" echo "Reminder: Use existing categories and tags when possible." python "./docs/find_tags_categories.py" -