2024-06-23 12:18:49 -04:00
|
|
|
#!/bin/bash
|
|
|
|
|
|
2024-06-23 20:15:56 -04:00
|
|
|
check_existing_blog_file() {
|
|
|
|
|
if [ -e "src/blog/$1/index.md" ]; then
|
|
|
|
|
echo "Error: A file with the name 'index.md' already exists in the 'src/blog/$1' directory."
|
2024-06-23 12:18:49 -04:00
|
|
|
exit 1
|
|
|
|
|
fi
|
|
|
|
|
}
|
|
|
|
|
|
2024-06-23 20:15:56 -04:00
|
|
|
check_existing_feed_file() {
|
|
|
|
|
if [ -e "src/feed/$1.md" ]; then
|
|
|
|
|
echo "Error: A file with the name '$1.md' already exists in the 'src/feed' directory."
|
|
|
|
|
exit 1
|
|
|
|
|
fi
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if [ -n "$1" ]; then
|
|
|
|
|
title=$1
|
|
|
|
|
else
|
|
|
|
|
read -p "Enter the title for the new blog post: " title
|
|
|
|
|
fi
|
|
|
|
|
|
2024-06-23 12:18:49 -04:00
|
|
|
kebab_title=$(echo "$title" | tr '[:upper:]' '[:lower:]' | tr ' ' '-')
|
|
|
|
|
|
2024-06-23 20:15:56 -04:00
|
|
|
check_existing_blog_file "$kebab_title"
|
|
|
|
|
check_existing_feed_file "$kebab_title"
|
2024-06-23 12:18:49 -04:00
|
|
|
|
2024-06-23 20:15:56 -04:00
|
|
|
mkdir -p "src/blog/$kebab_title"
|
|
|
|
|
echo "---" > "src/blog/$kebab_title/index.md"
|
|
|
|
|
echo "title: $title" >> "src/blog/$kebab_title/index.md"
|
|
|
|
|
echo "layout: article.njk" >> "src/blog/$kebab_title/index.md"
|
|
|
|
|
echo "date: git Last Modified" >> "src/blog/$kebab_title/index.md"
|
|
|
|
|
echo "tags: post" >> "src/blog/$kebab_title/index.md"
|
|
|
|
|
echo "excerpt: Placeholder text for excerpt" >> "src/blog/$kebab_title/index.md"
|
|
|
|
|
echo "---" >> "src/blog/$kebab_title/index.md"
|
|
|
|
|
echo -e "\nThis is the content of the new blog post." >> "src/blog/$kebab_title/index.md"
|
2024-06-23 12:18:49 -04:00
|
|
|
|
|
|
|
|
echo "---" > "src/feed/$kebab_title.md"
|
|
|
|
|
echo "title: $title" >> "src/feed/$kebab_title.md"
|
|
|
|
|
echo "relativeUrl: /blog/$kebab_title" >> "src/feed/$kebab_title.md"
|
|
|
|
|
echo "date: git Created" >> "src/feed/$kebab_title.md"
|
|
|
|
|
echo "tags: feed" >> "src/feed/$kebab_title.md"
|
|
|
|
|
echo "---" >> "src/feed/$kebab_title.md"
|
|
|
|
|
echo -e "\nThis is the content of the new blog post." >> "src/feed/$kebab_title.md"
|
|
|
|
|
|
2024-06-23 20:15:56 -04:00
|
|
|
$EDITOR "src/blog/$kebab_title/index.md"
|