Skip to content

Commit

Permalink
Reuse code with capture
Browse files Browse the repository at this point in the history
  • Loading branch information
moisseev committed Apr 15, 2024
1 parent 9a0c810 commit 8956dc7
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions _includes/directory-tree.html
Original file line number Diff line number Diff line change
Expand Up @@ -56,22 +56,22 @@
{%- assign sorted_by_dir = filtered_pages | sort_natural: "dir" -%}
{%- assign subdir_pages = "" | split: "," -%}
{%- assign sorted_pages = "" | split: "," -%}
{-% capture concat_subdir -%}
{%- if subdir_pages.size > 0 -%}
{%- assign sorted_subdir_pages = subdir_pages | sort_natural: "title" -%}
{%- assign sorted_pages = sorted_pages | concat: sorted_subdir_pages -%}
{%- endif -%}
{-% endcapture -%}
{%- for pg in sorted_by_dir -%}
{%- if pg.dir == prev_page_dir -%}
{%- assign subdir_pages = subdir_pages | push: pg -%}
{%- else -%}
{%- if subdir_pages.size > 0 -%}
{%- assign sorted_subdir_pages = subdir_pages | sort_natural: "title" -%}
{%- assign sorted_pages = sorted_pages | concat: sorted_subdir_pages -%}
{%- endif -%}
{{ concat_subdir }}
{%- assign subdir_pages = "" | split: "," | push: pg -%}
{%- assign prev_page_dir = pg.dir -%}
{%- endif -%}
{%- endfor -%}
{%- if subdir_pages.size > 0 -%}
{%- assign sorted_subdir_pages = subdir_pages | sort_natural: "title" -%}
{%- assign sorted_pages = sorted_pages | concat: sorted_subdir_pages -%}
{%- endif -%}
{{ concat_subdir }}
{%- assign prev_page_dir = include.dir -%}
{%- for pg in sorted_pages -%}
{% unless pg.dir == prev_page_dir -%}
Expand Down

0 comments on commit 8956dc7

Please sign in to comment.