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