devon.lol/create-blog-post.sh
Devon Campbell ae0487886b Restructure for animated gifs
Animated gifs can't go through the asset pipeline since they come out as
a single frame of the original animation. Previously, I had only a
couple of them and didn't have my assets structured very well. I had the
assets that needed to be passthrough copied alongside those that could
go through the pipeline. It wasn't bad since there weren't many
animations. I mapped just those to passthrough copy to go to a single
directory. This will become more fraught as I add more since there's
more opportunity for collisions. When mapping to an output directory, I
can't maintain the inner structure of that directory. The files are
flattened. I moved everything around, both to separate images that can
go through the pipeline from those which can't and to allow for a simple
passthrough copy that will maintain the directory structure so that each
blog post can have its own directory of passthrough copied animated gifs
in the build.
2024-06-24 00:21:09 -04:00

46 lines
1.6 KiB
Bash
Executable file

#!/bin/bash
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."
exit 1
fi
}
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
kebab_title=$(echo "$title" | tr '[:upper:]' '[:lower:]' | tr ' ' '-')
check_existing_blog_file "$kebab_title"
check_existing_feed_file "$kebab_title"
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"
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"
$EDITOR "src/blog/$kebab_title/index.md"