First pass at site compiler

Takes vimwiki notes and throws them into HTML.

Still need to:
- Fix links on output
- Add header/footer
- Password-protect private dir
This commit is contained in:
Trevor Vallender 2023-05-26 11:20:55 +01:00
parent 4a4d524eb4
commit 30e37785ed
1 changed files with 38 additions and 0 deletions

38
make_site.bash Executable file
View File

@ -0,0 +1,38 @@
#!/usr/bin/env bash
# Best practice options
set -o errexit
set -o nounset
set -o pipefail
if [[ "${TRACE-0}" == "1" ]]; then set -o xtrace; fi
if [[ "${1-}" =~ ^-*h(elp)?$ ]]; then
echo 'Usage:
'
exit
fi
INPUT_DIR=~/notes
OUTPUT_DIR=~/public_html
pushd ~
traverse_dir() {
local dir=$1
for d in $dir; do
OUTPUT=$OUTPUT_DIR${d##$INPUT_DIR}
if [ -d "$d" ]; then
mkdir -p $OUTPUT
traverse_dir "$d/*"
elif [[ $d == *.md ]]; then
OUTPUT=${OUTPUT%.md}.html
OUTPUT=${OUTPUT// /_}
echo $OUTPUT
pandoc -f markdown -t html -o $OUTPUT "$d"
fi
done
}
traverse_dir $INPUT_DIR/\*
popd