From e3a86169d6aaca14e96ecf7c349ec6f7c59b3ad3 Mon Sep 17 00:00:00 2001 From: Volpeon Date: Sun, 27 Dec 2020 22:46:46 +0100 Subject: Completed automatic metadata generation --- content/blog/test1.md | 2 ++ content/blog/test2/index.md | 2 ++ metadata/metadata.yaml | 2 +- scripts/build_content.sh | 24 ++++++++++-------------- templates/base.html | 18 +++++++++++++++--- templates/pageHeaderSm.html | 2 +- 6 files changed, 31 insertions(+), 19 deletions(-) diff --git a/content/blog/test1.md b/content/blog/test1.md index ec31808..8e2b0b9 100644 --- a/content/blog/test1.md +++ b/content/blog/test1.md @@ -2,3 +2,5 @@ date: 2020-12-25 title: Test Page 1 --- + +# Test Page 1 diff --git a/content/blog/test2/index.md b/content/blog/test2/index.md index 156909e..c23538b 100644 --- a/content/blog/test2/index.md +++ b/content/blog/test2/index.md @@ -2,3 +2,5 @@ date: 2020-12-27 title: Test Page 2 --- + +# Test Page 2 diff --git a/metadata/metadata.yaml b/metadata/metadata.yaml index 773f155..eb0f054 100644 --- a/metadata/metadata.yaml +++ b/metadata/metadata.yaml @@ -4,7 +4,7 @@ site: menus: main: - - id: home + - id: index label: Home url: / - id: blog diff --git a/scripts/build_content.sh b/scripts/build_content.sh index 5b4bb85..298291d 100755 --- a/scripts/build_content.sh +++ b/scripts/build_content.sh @@ -34,9 +34,6 @@ get_section() { filename=${filename#"$CONTENT_DIR"} filename=${filename%.md} filename=$(echo "$filename" | cut -f1 -d /) - if [ "$filename" = "index.md" ]; then - filename="home" - fi echo "$filename" } @@ -70,12 +67,12 @@ get_subpages() { fi if [ ${#child_pages[@]} -ne 0 ]; then - echo -e "\033[0;90m[////////]\033[0m Child pages:" + #echo -e "\033[0;90m[////////]\033[0m Child pages:" collected_metadata="[]" for file in "${child_pages[@]}"; do - echo -e "\033[0;90m[////////]\033[0m - $file" + #echo -e "\033[0;90m[////////]\033[0m - $file" url_rel=$(target_url_rel "$basedir" "$file") url_abs=$(target_url_abs "$file") @@ -90,9 +87,9 @@ get_subpages() { collected_metadata=$(echo "$collected_metadata" | jq ". + [ $metadata ]") done - collected_metadata=$(echo "$collected_metadata" | jq "sort_by(.date)") + collected_metadata=$(echo "$collected_metadata" | jq "sort_by(.date) | reverse") - echo "$collected_metadata" + echo "{ \"pages\": $collected_metadata }" | jq . fi } @@ -111,23 +108,22 @@ handle () { is_home=true fi - subpages_meta=$(mktemp) - - # $(get_subpages "$1") > "$subpages_meta" + subpages_meta_file=$(mktemp) - get_subpages "$1" + echo "$(get_subpages "$1")" > "$subpages_meta_file" pandoc "$1" \ -f markdown \ -t html5 \ --template "${TEMPLATES_DIR}base.html" \ -o "$target" \ - --metadata isHome=$is_home \ + --metadata "ishome"=$is_home \ --metadata section=$section \ + --metadata "is$section" \ --metadata-file metadata/metadata.yaml \ - --metadata-file "$subpages_meta" + --metadata-file "$subpages_meta_file" - rm "$subpages_meta" + rm "$subpages_meta_file" else echo -e "\033[0;32m[COPY ]\033[0m $1 -> $target" diff --git a/templates/base.html b/templates/base.html index de584ac..21ea9a4 100644 --- a/templates/base.html +++ b/templates/base.html @@ -15,7 +15,7 @@ $if(keywords)$ $endif$ - $if(isHome)$$else$$title$ – $endif$$site.title$ + $if(ishome)$$else$$title$ – $endif$$site.title$ $if(section)$