From e737e93d6e9b7fdc44046fb641ee02b6735dddfc Mon Sep 17 00:00:00 2001 From: moisseev Date: Mon, 15 Apr 2024 13:22:25 +0300 Subject: [PATCH] Sort subdirectories --- _includes/directory-tree.html | 25 +++++++++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-) diff --git a/_includes/directory-tree.html b/_includes/directory-tree.html index ad585e3d8..243a7677b 100644 --- a/_includes/directory-tree.html +++ b/_includes/directory-tree.html @@ -37,7 +37,6 @@ {%- assign dir_strong = "" -%} {%- assign dir_strong_closing = "" -%} {%- endif -%} - {%- assign prev_page_dir = include.dir -%} {%- assign filtered_pages = "" | split: "," -%} {%- for pg in site.pages -%} {%- comment -%} @@ -54,7 +53,29 @@ {%- endif -%} {%- assign filtered_pages = filtered_pages | push: pg -%} {%- endfor -%} - {%- assign sorted_pages = filtered_pages | sort: "dir" -%} + {%- assign sorted_by_dir = filtered_pages | sort: "dir" -%} + {%- assign subdir_pages = "" | split: "," -%} + {%- assign sorted_pages = "" | split: "," -%} + {%- for pg in sorted_by_dir -%} +prev_page_dir=
{{ prev_page_dir | inspect }}
+ {%- if pg.dir == prev_page_dir -%} + {%- assign subdir_pages = subdir_pages | push: pg -%} +subdir_pages=
{{ subdir_pages | inspect }}
+ {%- else -%} + {%- if subdir_pages.size > 0 -%} + {%- assign sorted_subdir_pages = subdir_pages | sort: "dir" -%} + {%- assign sorted_pages = sorted_pages | concat: sorted_subdir_pages -%} +sorted_pages=
{{ sorted_pages | inspect }}
+ {%- assign subdir_pages = "" | split: "," | push: pg -%} + {%- endif -%} + {%- assign prev_page_dir = pg.dir -%} + {%- endif -%} + {%- endfor -%} + {%- if subdir_pages.size > 0 -%} + {%- assign sorted_subdir_pages = subdir_pages | sort: "dir" -%} + {%- assign sorted_pages = sorted_pages | concat: sorted_subdir_pages -%} + {%- endif -%} + {%- assign prev_page_dir = include.dir -%} {%- for pg in sorted_pages -%} {% unless pg.dir == prev_page_dir -%} {%- assign path = pg.dir | split: "/" -%}