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

42 lines
987 B
Bash
Raw Normal View History

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