summaryrefslogtreecommitdiff
path: root/bin
diff options
context:
space:
mode:
Diffstat (limited to 'bin')
-rwxr-xr-xbin/wag44
1 files changed, 44 insertions, 0 deletions
diff --git a/bin/wag b/bin/wag
index 4e0c802..a1542b6 100755
--- a/bin/wag
+++ b/bin/wag
@@ -1,6 +1,8 @@
#!/bin/sh
## wag is a tool to generate static web sites
+##
+## Commands:
unset CDPATH
export LC_ALL=C IFS='
@@ -8,6 +10,48 @@ export LC_ALL=C IFS='
cmd=$(command -v "$0")
+dest=./public
+
+footer() {
+ :
+}
+
+# front parses front matter
+front() {
+ {
+ read a b && [ "$a" = "---" ] && [ "$b" = "" ] || return
+ while read a b; do
+ [ "$a" = "---" ] && [ "$b" = "" ] && break
+ eval "front_${a%:}=\"$b\""
+ done
+ } < "$1"
+}
+
+## gen generates site content from source files
+gen() {
+ [ -d "$dest" ] || mkdir -p "$dest"
+ for f in *.md; do
+ [ "$f" = "*.md" ] && continue
+ g="$dest/${f%.md}.html"
+ [ "$f" -ot "$g" ] && continue
+ echo "f: $f $g"
+ front "$f"
+ {
+ header
+ md2html "$f"
+ footer
+ } > "$g"
+ done
+}
+
+header() {
+ cat <<- EOT
+ <title>$front_title</title>
+ <meta charset="utf-8">
+ <style>body {max-width: 52em; margin: 1em auto; padding: 1em}</style>
+ EOT
+}
+
## help prints this program documentation
help() { awk '/^## / {print substr($0, 4)}' "$cmd"; }