Skip to content

Commit

Permalink
Sort subdirectories
Browse files Browse the repository at this point in the history
  • Loading branch information
moisseev committed Apr 15, 2024
1 parent e071afe commit e737e93
Showing 1 changed file with 23 additions and 2 deletions.
25 changes: 23 additions & 2 deletions _includes/directory-tree.html
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@
{%- assign dir_strong = "<strong>" -%}
{%- assign dir_strong_closing = "</strong>" -%}
{%- endif -%}
{%- assign prev_page_dir = include.dir -%}
{%- assign filtered_pages = "" | split: "," -%}
{%- for pg in site.pages -%}
{%- comment -%}
Expand All @@ -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=<pre>{{ prev_page_dir | inspect }}</pre>
{%- if pg.dir == prev_page_dir -%}
{%- assign subdir_pages = subdir_pages | push: pg -%}
subdir_pages=<pre>{{ subdir_pages | inspect }}</pre>
{%- 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=<pre>{{ sorted_pages | inspect }}</pre>
{%- 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: "/" -%}
Expand Down

0 comments on commit e737e93

Please sign in to comment.