Skip to content

Commit 83ce52a

Browse files
authored
Merge pull request TheAlgorithms#1121 from ZakCodes/scroll-to-section
Scroll to the section of the page
2 parents ca3a1bf + ecfcbc3 commit 83ce52a

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

_includes/sidebar.html

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
<nav class="sidebar__nav">
1313
<div class="sidebar__nav-interior">
1414
{%- for section in sections -%}
15-
<h3 class="section__header">{{ section | capitalize }}</h3>
15+
<h3 class="section__header" id="{{ section }}">{{ section | capitalize }}</h3>
1616

1717
<ul class="section__links">
1818
{%- for item in site[section] -%}
@@ -23,5 +23,11 @@ <h3 class="section__header">{{ section | capitalize }}</h3>
2323
</ul>
2424
{%- endfor -%}
2525
</div>
26+
27+
{%- if sections contains page.collection -%}
28+
<script type="text/javascript">
29+
document.getElementById("{{ page.collection }}").scrollIntoView();
30+
</script>
31+
{%- endif -%}
2632
</nav>
2733
</div>

0 commit comments

Comments
 (0)