Skip to content

Commit

Permalink
Use offset
Browse files Browse the repository at this point in the history
  • Loading branch information
moisseev committed Apr 3, 2024
1 parent c8acf72 commit 8f39103
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions sitemap1.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,26 @@ title: Site map
{% unless page.dir == prev_page_dir %}
{% assign path = page.dir | split: "/" %}
{% assign prev_path = prev_page_dir | split: "/" %}

{% assign levels_back = nil %}
{% assign levels_match = nil %}

{% for dir in prev_path %}
{% unless dir == nil or dir == path[forloop.index0] %}
{% assign levels_match = forloop.index %}
{% assign levels_back = forloop.rindex %}
{% break %}
{% endunless %}
{% endfor %}
back:{{ levels_back }}, match:{{ levels_match }}

{% for dir in path %}
{% unless dir == nil or dir == prev_path[forloop.index0] %}
{% assign levels_match = forloop.index0 %}
{% break %}
{% endunless %}
{% endfor %}

{{ page.dir }} back:{{ levels_back }}, match:{{ levels_match }}
{% for dir in path offset:levels_match %}
{{ dir }}{% unless forloop.last %} / {% endunless %}
{% endfor %}
{% assign prev_page_dir = page.dir %}
Expand Down

0 comments on commit 8f39103

Please sign in to comment.