bunteshaus.de/new.sh
2022-06-24 19:00:02 +02:00

44 lines
1.4 KiB
Bash
Executable File

#!/bin/bash
echo "Titel des Artikels"
read -p ": " title
title=${title//[^[:print:]]/}
title=${title//#/}
newfoldername="${title//[^[:alnum:][:blank:]-]/}"
newfoldername=${newfoldername// /-}
newfoldername=${newfoldername/%-/}
newfoldername=${newfoldername/-/}
title="${title//\//\\\/}" # / -> \/
title="${title//\"/\\\"}" # " -> \"
date_long=$(date +%Y-%m-%dT%H:%M:00+0200)
date=$(date +%Y-%m-%d)
mkdir -p "content/posts/${date}-${newfoldername}"
touch "content/posts/${date}-${newfoldername}/index.de.md"
# echo "---" > "content/posts/${date}-${newfoldername}/index.de.md"
# echo "title: \"${title}\"" >> "content/posts/${date}-${newfoldername}/index.de.md"
# echo "date: ${date_long}" >> "content/posts/${date}-${newfoldername}/index.de.md"
# echo "---" >> "content/posts/${date}-${newfoldername}/index.de.md"
git add "content/posts/${date}-${newfoldername}/"
git commit -m "New Post: ${date}-${newfoldername}"
for i in vim nano gedit kate; do
if command -v $i > /dev/null; then
editor="$i"
fi
done
echo ""
echo ""
echo "Schreibe nun mit einem einfachen Editor deinen Artikel."
echo ""
echo "'${editor} content/posts/${date}-${newfoldername}/index.de.md'"
echo ""
echo "'https://buha.rotce.de/de/tools/generator/' hilft dir!"
echo ""
echo "Lege vielleicht noch Bilder in den Ordner 'content/posts/${date}-${newfoldername}'"
echo ""
echo "Wenn du fertig bist, nutze './push.sh' um das hochzuladen."