I’ve been the idea of setting up a new blog together with my site for quite some time. I used to run a jekyll blog for murmel, but I thought it was time to update the stack to something a bit more fun!
Astro
Astro is a static site generator that I’ve had many people around me talking about. My colleague Magnus had spoken highly of it at some point, and it just stuck with me.
Simplicity
My main goal with the blog is to keep it extremely simple to generate and publish a new post. Markdown together with a little scripting to bootstrap posts I’m no bash pro (even if I’d love to be 🤓) but this is what I came up with.
# Check if the correct number of arguments is provided
if [ "$#" -ne 2 ]; then
echo "Usage: $0 <title> <description>"
exit 1
fi
# Assign arguments to variables
TITLE=$1
DESCRIPTION=$2
# Get the current date in YYYY-MM-DD format
CURRENT_DATE=$(date +%Y-%m-%d)
# Create a filename by replacing spaces with hyphens in the title
FILENAME="${CURRENT_DATE}-$(echo $TITLE | tr ' ' '-').mdx"
# Define the directory and file path
DIRECTORY=~/Projects/mrlorentx/src/content/posts
FILEPATH="$DIRECTORY/$FILENAME"
# Check if the directory exists, if not, create it
if [ ! -d "$DIRECTORY" ]; then
mkdir -p "$DIRECTORY"
fi
# Create the new post file with the provided content
cat <<EOL > $FILEPATH
---
title: $TITLE
description: $DESCRIPTION
publishedDate: $CURRENT_DATE
tags:
---
EOL
echo "New post created: $FILEPATH"
This is set up in my ~/usr/bin
and aliased so I can always set up an “idea” for a post without having to finish/publish!
Maybe I’ll set this up as a script in raycast aswell to make it crazy easy from any point in my system to plot down an idea..