blog/make.sh

58 lines
1.5 KiB
Bash
Raw Normal View History

# compiles new post into target directory
2018-12-23 05:40:40 +00:00
rootDir='./_site/'
2018-06-22 20:19:27 +00:00
post() {
# check directory existence
if [ -f markdown/post/$1 ]
then
2018-12-23 05:40:40 +00:00
# CSS file is always relative to the target html location
pandoc markdown/post/$1 --css style.css -s -o post/${1%.*}.html
else
# error message incase file was not found
2018-06-23 02:44:06 +00:00
echo "File \"$1\" not found in markdown/post"
2018-06-22 20:19:27 +00:00
fi
}
2018-12-17 07:09:29 +00:00
updatestyle() {
2018-12-23 05:40:40 +00:00
# Updating index style
cp style.css $rootDir/style.css
sed -i 's/.\/fonts/..\/fonts/g' $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/page/style.css
}
2018-06-22 20:19:27 +00:00
page() {
2018-06-25 05:26:19 +00:00
# we want to enforce maintainence of directory structure
2018-06-22 20:19:27 +00:00
if [ -f markdown/pages/$1 ]
then
2018-12-23 05:40:40 +00:00
pandoc markdown/pages/$1 --css style.css -s -o $rootDir/page/${1%.*}.html
2018-06-22 20:19:27 +00:00
else
echo "File \"$1\" not found in markdown/pages"
fi
}
# literally just updates the index file nothing else
2018-06-23 23:19:37 +00:00
index() {
2018-12-17 07:09:29 +00:00
# base index file
2018-12-23 05:40:40 +00:00
pandoc ./markdown/index.md --css style.css -s -o $rootDir/index.html # typing succs
2018-12-17 07:09:29 +00:00
# next we inject the navbar html stuff
2018-12-23 05:40:40 +00:00
sed -i '7r ./templates/navbar.html' $rootDir/index.html
2018-06-22 20:19:27 +00:00
}
2018-12-23 05:40:40 +00:00
# taking function names as param
2018-06-22 20:19:27 +00:00
"$@"
2018-12-17 21:45:43 +00:00
if [ -z $1 ]
then
echo './make.sh post file.md - make new post'
2018-12-23 05:40:40 +00:00
echo './make.sh updatestyle - update & sync style sheets'
2018-12-17 21:45:43 +00:00
echo './make.sh page file.md - make new page'
2018-12-23 05:40:40 +00:00
echo './make.sh index - update index'
2018-12-17 21:45:43 +00:00
fi