From 1023fff7ffb6d999682530172c1cb55a9dcb4f59 Mon Sep 17 00:00:00 2001 From: shockrah Date: Thu, 11 Jun 2026 14:05:46 -0700 Subject: [PATCH] Updated creation script since i keep forgetting how to use this thing --- scripts/new-post.py | 18 ++++++++++++++++++ scripts/new-post.sh | 17 ----------------- 2 files changed, 18 insertions(+), 17 deletions(-) create mode 100644 scripts/new-post.py delete mode 100644 scripts/new-post.sh diff --git a/scripts/new-post.py b/scripts/new-post.py new file mode 100644 index 0000000..68a2722 --- /dev/null +++ b/scripts/new-post.py @@ -0,0 +1,18 @@ +from pathlib import Path +from subprocess import check_call +import sys + +if __name__ == '__main__': + if len(sys.argv) == 1: + print('No title given!') + sys.exit(1) + title = ' '.join(sys.argv[1:]) + filename = title.lower().replace(' ', '-') + '.md' + + # Creating the new base post + target = Path(f'content/posts/{filename}') + if target.is_file(): + print(f'File \'{target}\' already present, nothing to do') + else: + check_call(f'hugo new {target}'.split()) + diff --git a/scripts/new-post.sh b/scripts/new-post.sh deleted file mode 100644 index 7f2d065..0000000 --- a/scripts/new-post.sh +++ /dev/null @@ -1,17 +0,0 @@ -#!/bin/bash -e - -[[ "$1" = "" ]] && echo No filename given for new post\! && exit 1 - -name="$(basename -s .md $1)" - -echo Creating new post content/posts/$name.md with metadata: -cat << EOF | tee content/posts/"$name.md" ---- -title: $(basename -s .md "$file") -date: $(date '+%F') -draft: false -description: -category: article -image: ---- -EOF