Files
Neocities/newpost.sh
2025-11-04 10:04:21 -06:00

30 lines
802 B
Bash
Executable File

#!/bin/sh
postDir="pages/blog/"
rssFeed="xml/voidblog.xml "
echo "Enter Date"
read name
echo "Enter Title: "
read title
echo "Enter Subtitle: "
read subtitle
echo "Enter Date: "
read date
echo "Enter post type"
read postType
# Modify RSS Feed File with new File Data
rssItem=$(sed "s/#TITLE/$title/g; s/#CATEGORY/$postType/g; s/#LINK/https:\/\/voidwillow.neocities.org\/pages\/templates\/blog\?$name/g; s/#DESCRIPTION/$subtitle/g; s/#DATE/$(date "+%a %d %b %Y %H:%M:%S CST")/g")
#Add new Item to feed below the <!--Feed--> Comment
sed '/<!--Feed-->/a\'$rssItem $rssFeed
#Create new Post from provided info
cd $postDir
if [ -e $name.json ]
then
nvim $name.json
else
cp template.json $name.json
sed -i "s/#TITLE/$title/g; s/#SUBTITLE/$subtitle/g; s/#DATE/$date/g" $name.json
nvim $name.json
fi