29 lines
742 B
Bash
Executable File
29 lines
742 B
Bash
Executable File
#!/bin/bash
|
|
set -euo pipefail
|
|
|
|
|
|
baseDir="$(realpath "$(dirname "${0}")")"
|
|
|
|
source "${baseDir}/website.conf"
|
|
|
|
|
|
for markdownFile in $(find -P "${markdownDir}/" | grep '\.md'); do
|
|
pageDir="${webroot}/$(cat "${markdownFile}" | grep -m1 '^page_dir: ' | head -1 | sed 's|page_dir: ||; s|^/||')"
|
|
template="${templateDir}/$(cat "${markdownFile}" | grep -m1 '^template: ' | head -1 | sed 's|template: ||').html"
|
|
|
|
if [[ ! -d "${pageDir}/" ]]; then
|
|
# Makes the folder the current page being (re)generated goes in if it does not already exist.
|
|
mkdir \
|
|
-p \
|
|
"${pageDir}/"
|
|
fi
|
|
|
|
# pandoc does its magic here
|
|
pandoc \
|
|
--from markdown \
|
|
--to html \
|
|
--template "${template}" \
|
|
--output "${pageDir}/index.html" \
|
|
"${markdownFile}"
|
|
done
|