blog/build.sh
2019-01-24 17:25:55 -08:00

75 lines
1.4 KiB
Bash
Executable File

# Because sometimes you just have to rebuild everything
rootDir='./_site/'
index() {
pandoc ./markdown/index.md --css style.css -s -o $rootDir/index.html
sed -i '7r ./templates/navbar.html' $rootDir/index.html
}
post() {
for file in ./markdown/post/*
do
fileName=$(basename $file)
pandoc $file --css style.css -s -o $rootDir/post/${fileName%.*}.html
done
}
page() {
for file in ./markdown/pages/*
do
pandoc $file --css style.css -s -o $rootDir/page/${fileName%.*}.html
done
}
img() {
cp -r img/ "$rootDir/img/"
}
style() {
# Updating index style
cp style.css $rootDir/style.css
# Updating page style
cp style.css $rootDir/page/style.css
sed -i 's/(.\/fonts/(..\/fonts/g' $rootDir/page/style.css
# Updating post style
cp style.css $rootDir/post/style.css
sed -i 's/(.\/fonts/(..\/fonts/g' $rootDir/post/style.css
}
yeet() {
post
page
style
# finally we'll upload the site itself to neocities
neocities push _site/
}
# Setups site directory from scratch
init() {
mkdir -p "$rootDir/page/" "$rootDir/post/" "$rootDir/fonts/" "$rootDir/img/"
cp -r img/ "$rootDir"
cp ./fonts/* "$rootDir/fonts/"
post
page
index
style
}
"$@"
if [ -z $1 ]
then
echo './build.sh init - create website from scratch'
echo './build.sh post - builds posts'
echo './build.sh page - builds pages'
echo './build.sh style - builds style'
echo './build.sh yeet - upload to neocties'
echo './build.sh img - currently super busted so don't bother
fi