fakestache-ssg

[Archived] A static site generator in Bash 4.
Log | Files | Refs | Submodules | README

commit 43b65b2ae1fa708e2df8bef2a9d8c353f7b651b7
parent 8e42610d01af21abbcc4f4a63d7e80395ae18202
Author: Hugo Soucy <hugo.soucy@savoirfairelinux.com>
Date:   Tue,  1 Nov 2016 15:38:25 -0400

Simplify the process:

* The date folders are automatically created anymore.
* The user should create the folders when he creates the content files.

Diffstat:
Mfunctions/create-html-pages | 58+++++++++++++++++++---------------------------------------
1 file changed, 19 insertions(+), 39 deletions(-)

diff --git a/functions/create-html-pages b/functions/create-html-pages @@ -14,62 +14,42 @@ create_html_pages () { true) find_noindex_markdown=$(find "$CONTENT_PATH/" -mindepth 2 -type f -name \*.md) rm -R "$PUBLICHTML_PATH/"* + rm -R "$TMP_PATH/"* ;; false) find_noindex_markdown=$(find "$CONTENT_PATH/" -mindepth 2 -type f -name \*.md -mtime -1) - ;; - esac + ;; + esac # Then create others for markdown in $find_noindex_markdown; do - # Parent folder name without path - page_section=$(basename "$(dirname "$markdown")") - # Markdown files names without path outputname=$(basename "$markdown") # Parse the YAML block of the markdown eval "$(parse_yaml "$markdown" "config_")" - if [[ "$config_date" != "null" ]]; then - # Get year and month - year=${config_date:0:4} - month=${config_date:5:2} + # Get the value of the template config + templatename=$config_template - # First create year and month folders - mkdir -p "$(dirname "$markdown")"/"$year"/"$month" - fi - - page_path="$year"/"$month"/"${outputname%.*}" + # page_path="$year"/"$month"/"${outputname%.*}" + # Get the relative path of the markdown file + page_path="$(realpath --relative-to=$CONTENT_PATH $markdown)" # Check if a section have a specific template or use the default template - if [[ " ${templates[*]} " == *" $page_section "* ]]; then - # Check if the date property value is not "null" - if [[ "$config_date" != "null" ]]; then - - pandoc -s "$markdown" \ - --template="$TPL_PANDOC_PATH/${page_section}.html" \ - --variable=modified:"$(date -r "$markdown" +%Y-%m-%dT%H:%M:%S)" \ - --variable=permalink:"$BASE_URL/$page_section/$page_path.html" \ - -o "$(dirname "$markdown")/$page_path.html" - else - pandoc -s "$markdown" \ - --template="$TPL_PANDOC_PATH/${page_section}.html" \ - -o "$(dirname "$markdown")/${outputname%.*}.html" - fi + if [[ " ${templates[*]} " == *" $templatename "* ]]; then + pandoc -s "$markdown" \ + --template="$TPL_PANDOC_PATH/${templatename}.html" \ + --variable=modified:"$(date -r "$markdown" +%Y-%m-%dT%H:%M:%S)" \ + --variable=permalink:"$BASE_URL/${page_path%.*}" \ + -o "$(dirname "$markdown")/${outputname%.*}.html" else - if [[ "$config_date" != "null" ]]; then - pandoc -s "$markdown" \ - --template="$TPL_PANDOC_PATH/default.html" \ - --variable=modified:"$(date -r "$markdown" +%Y-%m-%dT%H:%M:%S)" \ - --variable=permalink:"$BASE_URL/$page_section/$page_path.html" \ - -o "$(dirname "$markdown")/$page_path.html" - else - pandoc -s "$markdown" \ - --template="$TPL_PANDOC_PATH/default.html" \ - -o "$(dirname "$markdown")/${outputname%.*}.html" - fi + pandoc -s "$markdown" \ + --template="$TPL_PANDOC_PATH/default.html" \ + --variable=modified:"$(date -r "$markdown" +%Y-%m-%dT%H:%M:%S)" \ + --variable=permalink:"$BASE_URL/${page_path%.*}" \ + -o "$(dirname "$markdown")/${outputname%.*}.html" fi done