From 19a1a45f992bfb01f44a39dee554552b0b6102d1 Mon Sep 17 00:00:00 2001 From: Volpeon Date: Thu, 31 Dec 2020 16:56:33 +0100 Subject: Build script: More efficient way to find subpages --- scripts/build_content.sh | 27 ++++++++++++++++----------- 1 file changed, 16 insertions(+), 11 deletions(-) diff --git a/scripts/build_content.sh b/scripts/build_content.sh index 26c936d..a57feed 100755 --- a/scripts/build_content.sh +++ b/scripts/build_content.sh @@ -57,6 +57,12 @@ get_metadata() { --template scripts/metadata_tpl.json } +get_content() { + pandoc "$1" \ + -f markdown \ + -t plain +} + get_section() { filename=$1 filename=${filename#"$CONTENT_DIR"} @@ -79,20 +85,12 @@ get_subpages_meta() { child_pages=() if [ -d "$basedir" ]; then - mapfile -d $'\0' child_pages_1 < <(find $basedir/ \ + mapfile -d $'\0' child_pages < <(find $basedir/ \ -type f \ - -name "*.md" ! -name "index.md" \ - -maxdepth 1 \ - -print0) - - mapfile -d $'\0' child_pages_2 < <(find $basedir/ \ - -type f \ - -name "index.md" \ - -mindepth 2 \ + -name "*.md" \ + ! -wholename "$basedir/index.md" \ -maxdepth 2 \ -print0) - - child_pages=("${child_pages_1[@]}" "${child_pages_2[@]}") fi pages=$(echo "{}" | jq ". + { \ @@ -109,6 +107,7 @@ get_subpages_meta() { #echo -e "\033[0;90m[////////]\033[0m - $file" metadata=$(get_metadata "$file") + # content=$(get_content "$file") section=$(get_section "$file") @@ -130,6 +129,12 @@ get_subpages_meta() { category_name=$(echo "$CATEGORIES" | jq -r .$section.$category) fi + # metadata=$(echo "$metadata" | jq ". + { \ + # content: { \ + # plain: \"$(echo "$content" | sed -z 's/\\/\\\\/g;s/\n/\\n/g;s/"/\"/g')\", \ + # }, \ + # }") + metadata=$(echo "$metadata" | jq ". + { \ date: { \ yyyy_mm_dd: \"$date\", \ -- cgit v1.2.3-70-g09d2