From 4631bf9fee31289d30d211d59b77b579303d55f6 Mon Sep 17 00:00:00 2001 From: Volpeon Date: Mon, 28 Dec 2020 09:57:02 +0100 Subject: Various small fixes, exclude raw ASCII fox from output --- scripts/build_content.sh | 25 ++++++++++++++++++++----- 1 file changed, 20 insertions(+), 5 deletions(-) (limited to 'scripts') diff --git a/scripts/build_content.sh b/scripts/build_content.sh index 298291d..e3b97ea 100755 --- a/scripts/build_content.sh +++ b/scripts/build_content.sh @@ -25,8 +25,7 @@ target_url_rel () { } target_url_abs () { - url=$(target_url_rel "$CONTENT_DIR" "$1") - echo "/$url" + echo "/$(target_url_rel "$CONTENT_DIR" "$1")" } get_section() { @@ -69,7 +68,10 @@ get_subpages() { if [ ${#child_pages[@]} -ne 0 ]; then #echo -e "\033[0;90m[////////]\033[0m Child pages:" - collected_metadata="[]" + collected_metadata=$(echo "{ + \"all\": [], + \"by_year\": {} + }" | jq .) for file in "${child_pages[@]}"; do #echo -e "\033[0;90m[////////]\033[0m - $file" @@ -84,10 +86,22 @@ get_subpages() { metadata=$(echo "$metadata" | jq ". + { url_rel: \"$url_rel\", url_abs: \"$url_abs\" }") - collected_metadata=$(echo "$collected_metadata" | jq ". + [ $metadata ]") + collected_metadata=$(echo "$collected_metadata" | jq ".all += [ $metadata ]") + + date=$(echo "$metadata" | jq -r .date) + + if [ "$date" != "" ]; then + date_year=$(date -d "$date" +%Y) + #date_month=$(date -d "$date" +%m) + #date_day=$(date -d "$date" +%d) + + collected_metadata=$(echo "$collected_metadata" | jq ".by_year.\"$date_year\" += [ $metadata ]") + fi done - collected_metadata=$(echo "$collected_metadata" | jq "sort_by(.date) | reverse") + collected_metadata=$(echo "$collected_metadata" \ + | jq ".all |= (sort_by(.date) | reverse)" \ + | jq ".by_year[] |= (sort_by(.date) | reverse)") echo "{ \"pages\": $collected_metadata }" | jq . fi @@ -110,6 +124,7 @@ handle () { subpages_meta_file=$(mktemp) + # echo "$(get_subpages "$1")" echo "$(get_subpages "$1")" > "$subpages_meta_file" pandoc "$1" \ -- cgit v1.2.3-70-g09d2