Create script to help quickly generate multiple branch bundles
This commit is contained in:
parent
d19cf32e12
commit
d111bd5a50
53
scripts/create-stubs.sh
Executable file
53
scripts/create-stubs.sh
Executable file
@ -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"
|
Loading…
Reference in New Issue
Block a user