make script more flexible now

This commit is contained in:
Medium Fries 2019-04-25 14:45:19 -07:00
parent 23b18fb97f
commit b63a2515e0

22
make.sh
View File

@ -1,6 +1,6 @@
#!/bin/bash
# compiles new post into target directory
rootDir='./_dank/'
rootDir='./tmp/'
mdRoot='./prebild/'
mPostDir='./prebuild/post/'
@ -12,9 +12,14 @@ mPostDir='./prebuild/post/'
post() {
# First get the body of the document
body=$(pandoc $1)
cat 'templates/post-header.html' && echo $body && cat 'templates/post-footer.html'
# inject some page specific things like the title and favicon
tmp=".swap"
base=$(basename $1)
cat 'templates/post-header.html' > $tmp
pandoc $1 >> $tmp
cat 'templates/post-footer.html' >> $tmp
sed -i "3i <title>${base%.*}</title>" $tmp
# finally move this post to its proper location in the _rootDir
mv $tmp "$rootDir/post/${base%.*}.html"
}
# Options:
@ -24,15 +29,10 @@ post() {
target=""
stylesheet=""
while getopts "f:s:h" opt; do
while getopts "f:h" opt; do
case $opt in
h)
echo '-h shows this prompt'
echo '-s specifiy a custom stylesheet'
;;
s)
stylesheet=$2
echo "Stylesheet: $2"
;;
f)
target=$2
@ -43,4 +43,4 @@ done
# attempt to build the new post
[[ -z $target ]] && echo 'No target' && exit 0
post $target $stylesheet
post $target