diff options
| author | Volpeon <git@volpeon.ink> | 2020-12-23 09:10:31 +0100 |
|---|---|---|
| committer | Volpeon <git@volpeon.ink> | 2020-12-23 09:10:31 +0100 |
| commit | 3b15d49467a4ea81c3adf101b806d7236ba395bb (patch) | |
| tree | 66e1e924d535b9790730f76f3bdc148b5b774947 /scripts | |
| parent | Inlined simple scripts in the makefile (diff) | |
| download | volpeon.ink-3b15d49467a4ea81c3adf101b806d7236ba395bb.tar.gz volpeon.ink-3b15d49467a4ea81c3adf101b806d7236ba395bb.tar.bz2 volpeon.ink-3b15d49467a4ea81c3adf101b806d7236ba395bb.zip | |
Better build script, allow static files in content folder
Diffstat (limited to 'scripts')
| -rwxr-xr-x | scripts/build_content.sh | 36 | ||||
| -rwxr-xr-x | scripts/watch_content.sh | 3 | ||||
| -rwxr-xr-x | scripts/watch_sass.sh | 3 |
3 files changed, 25 insertions, 17 deletions
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 () { | |||
| 10 | fi | 10 | fi |
| 11 | } | 11 | } |
| 12 | 12 | ||
| 13 | compile () { | 13 | handle () { |
| 14 | TARGET=$(target "$1") | 14 | TARGET=$(target "$1") |
| 15 | mkdir -p $(dirname "$TARGET") | 15 | mkdir -p $(dirname "$TARGET") |
| 16 | pandoc "$1" \ | 16 | |
| 17 | -f markdown \ | 17 | if [ "${1#*.}" = "md" ]; then |
| 18 | -t html5 \ | 18 | echo "[COMPILE] $1 -> $TARGET" |
| 19 | --template templates/base.html \ | 19 | |
| 20 | -o "$TARGET" \ | 20 | pandoc "$1" \ |
| 21 | --metadata sitetitle="$SITE_TITLE" | 21 | -f markdown \ |
| 22 | -t html5 \ | ||
| 23 | --template templates/base.html \ | ||
| 24 | -o "$TARGET" \ | ||
| 25 | --metadata sitetitle="$SITE_TITLE" | ||
| 26 | else | ||
| 27 | echo "[COPY ] $1 -> $TARGET" | ||
| 28 | |||
| 29 | cp "$1" "$TARGET" | ||
| 30 | fi | ||
| 22 | } | 31 | } |
| 23 | 32 | ||
| 24 | if [ -z "$1" ]; then | 33 | if [ -z "$1" ]; then |
| 25 | find content/ \ | 34 | find content/ \ |
| 26 | -iname "*.md" \ | ||
| 27 | -type f \ | 35 | -type f \ |
| 28 | | while read FILE | 36 | | while read FILE |
| 29 | do | 37 | do |
| 30 | compile "$FILE" | 38 | handle "$FILE" |
| 31 | done | 39 | done |
| 32 | elif [ "$2" = "delete" ]; then | 40 | elif [ "$2" = "delete" ]; then |
| 33 | rm -rf $(target $1) | 41 | TARGET=$(target "$1") |
| 42 | echo "[DELETE] $1 -> $TARGET" | ||
| 43 | rm -rf $TARGET | ||
| 34 | else | 44 | else |
| 35 | compile "$1" | 45 | handle "$1" |
| 36 | fi | 46 | 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 @@ | |||
| 1 | #!/bin/bash | 1 | #!/bin/bash |
| 2 | 2 | ||
| 3 | inotifywait -rme create,close_write,delete,move --format "%w%f" content \ | 3 | inotifywait -qrme close_write,delete,move --format "%w%f" content \ |
| 4 | | while read FILENAME | 4 | | while read FILENAME |
| 5 | do | 5 | do |
| 6 | printf "Change detected: %s\n" "$FILENAME" | ||
| 7 | if [ -f "$FILENAME" ]; then | 6 | if [ -f "$FILENAME" ]; then |
| 8 | scripts/build_content.sh "$FILENAME" | 7 | scripts/build_content.sh "$FILENAME" |
| 9 | elif [ ! -d "$FILENAME" ]; then | 8 | 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 @@ | |||
| 1 | #!/bin/bash | 1 | #!/bin/bash |
| 2 | 2 | ||
| 3 | inotifywait -rme create,close_write,delete,move --format "%w%f" assets \ | 3 | inotifywait -qrme close_write,delete,move --format "%w%f" assets \ |
| 4 | | while read FILENAME | 4 | | while read FILENAME |
| 5 | do | 5 | do |
| 6 | printf "Change detected: %s\n" "$FILENAME" | ||
| 7 | scripts/build_sass.sh | 6 | scripts/build_sass.sh |
| 8 | done | 7 | done |
