aboutsummaryrefslogtreecommitdiff
path: root/export.sh
diff options
context:
space:
mode:
authorChristian Cleberg <hello@cleberg.net>2025-06-04 12:19:43 -0500
committerChristian Cleberg <hello@cleberg.net>2025-06-04 12:19:43 -0500
commit2dbea8e72f3c6c31e0426b59b943df44052dcc9f (patch)
tree08bc65cc13a4e7f699349450bad3d03f185eea4c /export.sh
parent99e4a3d8adcb5fad1d8eb77b9c519a979079eb31 (diff)
downloadorg-templates-2dbea8e72f3c6c31e0426b59b943df44052dcc9f.tar.gz
org-templates-2dbea8e72f3c6c31e0426b59b943df44052dcc9f.tar.bz2
org-templates-2dbea8e72f3c6c31e0426b59b943df44052dcc9f.zip
feat: add build process
Diffstat (limited to 'export.sh')
-rwxr-xr-xexport.sh36
1 files changed, 36 insertions, 0 deletions
diff --git a/export.sh b/export.sh
new file mode 100755
index 0000000..f5756a8
--- /dev/null
+++ b/export.sh
@@ -0,0 +1,36 @@
+#!/bin/bash
+
+set -e
+
+SRC_ROOT="${1:-$(pwd)/templates}"
+DEST_ROOT="$(pwd)/.build"
+CSS_SRC="$(pwd)/assets/styles.css"
+CSS_DEST="$DEST_ROOT/assets/styles.css"
+
+# Clean and recreate build directory
+rm -rf "$DEST_ROOT"
+mkdir -p "$DEST_ROOT/assets"
+cp "$CSS_SRC" "$CSS_DEST"
+
+# Export and relocate
+find "$SRC_ROOT" -name "*.org" | while read -r org_file; do
+ # Relative path from templates root
+ rel_path="${org_file#$SRC_ROOT/}"
+ rel_dir=$(dirname "$rel_path")
+ base_name=$(basename "$org_file" .org)
+
+ # Temporary output will go next to source
+ echo "Exporting: $rel_path"
+
+ emacs "$org_file" \
+ --batch \
+ --eval '(require '\''ox-html)' \
+ --eval "(setq org-html-head \"<link rel=\\\"stylesheet\\\" type=\\\"text/css\\\" href=\\\"../assets/styles.css\\\" />\")" \
+ --eval '(org-html-export-to-html)'
+
+ # Move output file to .build
+ mkdir -p "$DEST_ROOT/$rel_dir"
+ mv "$(dirname "$org_file")/${base_name}.html" "$DEST_ROOT/$rel_dir/"
+done
+
+echo "Export complete. Output is in .build/" \ No newline at end of file