Skip to content

Commit 3c2510c

Browse files
committed
refactor: use single-line comparison for entry_active variable as suggested by reviewer
1 parent 4bf85f7 commit 3c2510c

2 files changed

Lines changed: 6 additions & 8 deletions

File tree

www/_includes/toc_recursive_dropdown.html

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
11
{% for entry in include.entries %}
2-
{% assign normalized_my_entry = include.my_entry | remove: '/' %}
3-
{% assign normalized_entry_url = entry.url | remove: '/' %}
2+
{% assign entry_active = include.my_entry | remove: '/' == entry.url | remove: '/' %}
43

54
{% if entry.url != null %}
65
<li>
7-
<a class="{% if normalized_my_entry == normalized_entry_url %}this-page{% endif %}" href="{{ include.path_to_root }}{{ entry.url }}">
6+
<a class="{% if entry_active %}this-page{% endif %}" href="{{ include.path_to_root }}{{ entry.url }}">
87
{{ entry.name }}
98
</a>
109
</li>

www/_includes/toc_recursive_main.html

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,18 @@
11
<ul class="site-toc">
22
{% for entry in include.entries %}
33

4-
{% assign normalized_my_entry = include.my_entry | remove: '/' %}
5-
{% assign normalized_entry_url = entry.url | remove: '/' %}
4+
{% assign entry_active = include.my_entry | remove: '/' == entry.url | remove: '/' %}
65

76
<li>
87
{% if entry.children %}
98
<span class="toc-section-heading">
109
{{ entry.name }}
1110
</span>
1211
{% else %}
13-
<a class="{% if normalized_my_entry == normalized_entry_url %}this-page{% endif %}" href="{{ include.path_to_root }}{{ entry.url }}">
12+
<a class="{% if entry_active %}this-page{% endif %}" href="{{ include.path_to_root }}{{ entry.url }}">
1413
{{ entry.name }}
1514
</a>
16-
{% if normalized_my_entry == normalized_entry_url %}
15+
{% if entry_active %}
1716
<span class="entry-highlight"></span>
1817
{% endif %}
1918
{% endif %}
@@ -22,7 +21,7 @@
2221
{% comment %}
2322
Insert page-specific ToC here if this is the entry for this page
2423
{% endcomment %}
25-
{% if normalized_my_entry == normalized_entry_url %}<div id="page-toc" class="page-toc"></div>{% endif %}
24+
{% if entry_active %}<div id="page-toc" class="page-toc"></div>{% endif %}
2625

2726

2827
{% if entry.children %}

0 commit comments

Comments
 (0)