diff options
Diffstat (limited to 'scripts/build_content.sh')
| -rwxr-xr-x | scripts/build_content.sh | 33 |
1 files changed, 29 insertions, 4 deletions
diff --git a/scripts/build_content.sh b/scripts/build_content.sh index 4476d45..992414d 100755 --- a/scripts/build_content.sh +++ b/scripts/build_content.sh | |||
| @@ -2,7 +2,32 @@ | |||
| 2 | 2 | ||
| 3 | SITE_TITLE="Volpeon's Den" | 3 | SITE_TITLE="Volpeon's Den" |
| 4 | 4 | ||
| 5 | find content/ \ | 5 | target () { |
| 6 | -iname "*.md" \ | 6 | echo "dist/$(echo ${1%.md}.html | cut -sd / -f 2-)" |
| 7 | -type f \ | 7 | } |
| 8 | -exec sh -c 'TARGET=dist/$(echo ${0%.md}.html | cut -sd / -f 2-); mkdir -p $(dirname $TARGET) && pandoc "${0}" -t html5 --template templates/base.html -o "$TARGET" --metadata sitetitle="$1"' {} "$SITE_TITLE" \; | 8 | |
| 9 | compile () { | ||
| 10 | TARGET=$(target "$1") | ||
| 11 | mkdir -p $(dirname "$TARGET") | ||
| 12 | pandoc "$1" \ | ||
| 13 | -t html5 \ | ||
| 14 | --template templates/base.html \ | ||
| 15 | -o "$TARGET" \ | ||
| 16 | --metadata sitetitle="$SITE_TITLE" | ||
| 17 | } | ||
| 18 | |||
| 19 | if [ -z "$1" ]; then | ||
| 20 | find content/ \ | ||
| 21 | -iname "*.md" \ | ||
| 22 | -type f \ | ||
| 23 | | while read FILE | ||
| 24 | do | ||
| 25 | compile "$FILE" | ||
| 26 | done | ||
| 27 | else | ||
| 28 | if [ "$2" = "delete" ]; then | ||
| 29 | rm $(target $1) | ||
| 30 | else | ||
| 31 | compile "$1" | ||
| 32 | fi | ||
| 33 | fi | ||
