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