From d111bd5a501e6b062533cd0a198423d982276dc8 Mon Sep 17 00:00:00 2001 From: Christian Wolf Date: Thu, 24 Oct 2024 15:39:22 +0200 Subject: [PATCH] Create script to help quickly generate multiple branch bundles --- scripts/create-stubs.sh | 53 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 53 insertions(+) create mode 100755 scripts/create-stubs.sh diff --git a/scripts/create-stubs.sh b/scripts/create-stubs.sh new file mode 100755 index 0000000..2eb32fb --- /dev/null +++ b/scripts/create-stubs.sh @@ -0,0 +1,53 @@ +#!/bin/bash + +if [ ! -d "content/albums" ] +then + echo "You are not in the correct directory. Aborting." + exit 1 +fi + +if [ -f "content/albums/_index.md" ] +then + echo "You already have an _index.md file. This looks like you are in the template." + echo "You need to run this script from the main page directory." + exit 1 +fi + +tmp=$(mktemp) + +find content/albums -mindepth 1 -type d | while read dir +do + ( + cd "$dir" + if [ -f _index.md ] + then + # echo "Skipping $dir" + exit 0 + fi + + echo "Marking creation of stub for $dir" + echo "$dir/_index.md" >> "$tmp" + ) +done + +cat "$tmp" | while read line +do + dirname="$(basename "$(dirname "$line")")" + escaped="$(echo "$dirname" | sed 's@-@!@' )" + IFS=! read weight name <<< "$escaped" + text="title: \"$name\"\nweight: $weight" + # echo -e "$text" + + # npm run hugo -- new content "$line" + # sed "s@^title:.*@$text@@" -i "$line" + cat > "$line" << EOF +--- +title: "$name" +weight: $weight +date: $(date -Iseconds) +draft: false +--- +EOF +done + +rm "$tmp"