blog/build.sh
2019-01-01 20:56:54 -08:00

70 lines
1.3 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
}
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
}
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 ./img/* "$rootDir/img/"
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'
fi