From 3b15d49467a4ea81c3adf101b806d7236ba395bb Mon Sep 17 00:00:00 2001 From: Volpeon Date: Wed, 23 Dec 2020 09:10:31 +0100 Subject: Better build script, allow static files in content folder --- scripts/build_content.sh | 36 +++++++++++++++++++++++------------- scripts/watch_content.sh | 3 +-- scripts/watch_sass.sh | 3 +-- 3 files changed, 25 insertions(+), 17 deletions(-) (limited to 'scripts') diff --git a/scripts/build_content.sh b/scripts/build_content.sh index bd35694..460a3fe 100755 --- a/scripts/build_content.sh +++ b/scripts/build_content.sh @@ -10,27 +10,37 @@ target () { fi } -compile () { - TARGET=$(target "$1") - mkdir -p $(dirname "$TARGET") - pandoc "$1" \ - -f markdown \ - -t html5 \ - --template templates/base.html \ - -o "$TARGET" \ - --metadata sitetitle="$SITE_TITLE" +handle () { + TARGET=$(target "$1") + mkdir -p $(dirname "$TARGET") + + if [ "${1#*.}" = "md" ]; then + echo "[COMPILE] $1 -> $TARGET" + + pandoc "$1" \ + -f markdown \ + -t html5 \ + --template templates/base.html \ + -o "$TARGET" \ + --metadata sitetitle="$SITE_TITLE" + else + echo "[COPY ] $1 -> $TARGET" + + cp "$1" "$TARGET" + fi } if [ -z "$1" ]; then find content/ \ - -iname "*.md" \ -type f \ | while read FILE do - compile "$FILE" + handle "$FILE" done elif [ "$2" = "delete" ]; then - rm -rf $(target $1) + TARGET=$(target "$1") + echo "[DELETE] $1 -> $TARGET" + rm -rf $TARGET else - compile "$1" + handle "$1" fi diff --git a/scripts/watch_content.sh b/scripts/watch_content.sh index 60f7b07..c4f55fb 100755 --- a/scripts/watch_content.sh +++ b/scripts/watch_content.sh @@ -1,9 +1,8 @@ #!/bin/bash -inotifywait -rme create,close_write,delete,move --format "%w%f" content \ +inotifywait -qrme close_write,delete,move --format "%w%f" content \ | while read FILENAME do - printf "Change detected: %s\n" "$FILENAME" if [ -f "$FILENAME" ]; then scripts/build_content.sh "$FILENAME" elif [ ! -d "$FILENAME" ]; then diff --git a/scripts/watch_sass.sh b/scripts/watch_sass.sh index 97fd207..a5649e7 100755 --- a/scripts/watch_sass.sh +++ b/scripts/watch_sass.sh @@ -1,8 +1,7 @@ #!/bin/bash -inotifywait -rme create,close_write,delete,move --format "%w%f" assets \ +inotifywait -qrme close_write,delete,move --format "%w%f" assets \ | while read FILENAME do - printf "Change detected: %s\n" "$FILENAME" scripts/build_sass.sh done -- cgit v1.2.3-70-g09d2