blog/make.sh
2019-01-11 12:31:47 -08:00

57 lines
1.4 KiB
Bash
Executable File

# compiles new post into target directory
rootDir='./_site/'
post() {
# check directory existence
if [ -f markdown/post/$1 ]
then
# CSS file is always relative to the target html location
pandoc markdown/post/$1 --css style.css -s -o $rootDir/post/${1%.*}.html
else
# error message incase file was not found
echo "File \"$1\" not found in markdown/post"
fi
}
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
}
page() {
# we want to enforce maintainence of directory structure
if [ -f markdown/pages/$1 ]
then
pandoc markdown/pages/$1 --css style.css -s -o $rootDir/page/${1%.*}.html
else
echo "File \"$1\" not found in markdown/pages"
fi
}
# literally just updates the index file nothing else
index() {
# base index file
pandoc ./markdown/index.md --css style.css -s -o $rootDir/index.html # typing succs
# next we inject the navbar html stuff
sed -i '7r ./templates/navbar.html' $rootDir/index.html
}
# taking function names as param
"$@"
if [ -z $1 ]
then
echo './make.sh post file.md - make new post'
echo './make.sh style - update & sync style sheets'
echo './make.sh page file.md - make new page'
echo './make.sh index - update index'
fi