Files
personal-website/scripts/build-website.sh

40 lines
962 B
Bash
Executable File

#! /bin/bash
# just gonna assume you're executing in the scripts folder
# build the blog files
cd ../blog
CONTENTNUM=$(ls content-* | wc -l )
for ((i=-1;i<$CONTENTNUM;i++))
do
padint="$(printf %03d $i)"
contentname="content-$padint"
quotename="quote-$padint"
tailname="tail-$padint"
blogname="blog-$padint"
# interactive tail
if [[ $i >= 0 ]];then
cp filetail "$tailname"
padintprev="$(printf %03d $(($i - 1)) )"
if [[ $(($i+1)) == $CONTENTNUM ]];then
padintnext="$(printf %03d -1 )"
else
padintnext="$(printf %03d $(($i + 1)) )"
fi
sed -i "s/PREVPADINT/$padintprev/g" "$tailname"
sed -i "s/NEXTPADINT/$padintnext/g" "$tailname"
fi
# cat together
cat filehead "$contentname" "$tailname" "$quotename" > "$blogname"
done
# clean up non prod files
cd ../blog
#rm filehead filetail content* quote* .blog.* tail*
cd ../
#rm -rf .git scripts .index.html.* README.md
find . -type f | xargs chmod 600
find . -type d | xargs chmod 700