From 8132f5172d286ef73f5d0f2cfbd95da713870484 Mon Sep 17 00:00:00 2001 From: Volpeon Date: Wed, 30 Dec 2020 09:55:37 +0100 Subject: Fixed finding subpages in some cases, use multiple sorted arrays for categories --- scripts/build_content.sh | 5 +++-- templates/base.html | 6 ++---- templates/categoriesByCount.html | 7 +++++++ templates/categoriesById.html | 7 +++++++ templates/categoryRef.html | 7 ------- 5 files changed, 19 insertions(+), 13 deletions(-) create mode 100644 templates/categoriesByCount.html create mode 100644 templates/categoriesById.html delete mode 100644 templates/categoryRef.html diff --git a/scripts/build_content.sh b/scripts/build_content.sh index fc5ddea..78857b5 100755 --- a/scripts/build_content.sh +++ b/scripts/build_content.sh @@ -67,7 +67,8 @@ get_section() { get_subpages_basedir() { filename=$1 - if [ "${filename##*/}" = "index.md" ]; then + filename=${filename%.md} + if [ "${filename##*/}" = "index" ]; then filename=$(dirname "$filename") fi echo "$filename" @@ -165,7 +166,7 @@ get_subpages_meta() { | .by_year |= (to_entries | sort_by(.key) | reverse \ | .[].value |= (sort_by(.date) | reverse))") - categories=$(echo "$categories" | jq ". | to_entries | sort_by(.key)") + categories=$(echo "$categories" | jq ". | to_entries | { by_id: (. | sort_by(.key)), by_count: (. | sort_by(.value.count) | reverse) }") echo "{}" | jq ". + { \ pages: $pages, \ diff --git a/templates/base.html b/templates/base.html index 4b8ea1e..48d7c72 100644 --- a/templates/base.html +++ b/templates/base.html @@ -52,10 +52,8 @@ ${pageHeader()} $body$ $if(section.is_blog)$ - $if(pages.not_empty)$ - ${categoryRef()} - ${pagelistByYear()} - $endif$ + ${categoriesById()} + ${pagelistByYear()} $endif$ diff --git a/templates/categoriesByCount.html b/templates/categoriesByCount.html new file mode 100644 index 0000000..871e3db --- /dev/null +++ b/templates/categoriesByCount.html @@ -0,0 +1,7 @@ +$if(categories.by_count)$ + +$endif$ diff --git a/templates/categoriesById.html b/templates/categoriesById.html new file mode 100644 index 0000000..1f4f433 --- /dev/null +++ b/templates/categoriesById.html @@ -0,0 +1,7 @@ +$if(categories.by_id)$ + +$endif$ diff --git a/templates/categoryRef.html b/templates/categoryRef.html deleted file mode 100644 index 58dc5fe..0000000 --- a/templates/categoryRef.html +++ /dev/null @@ -1,7 +0,0 @@ -$if(categories)$ - -$endif$ -- cgit v1.2.3-54-g00ecf