docs/templates/partials/sidebar.html (1725B)
1 {# 섹션 트리. site.sections는 현재 언어의 것만 담겨 있으므로 미번역 페이지는
2 애초에 여기 없다 — 죽은 링크가 생길 수 없다.
3
4 접기는 <details>가 한다. JS가 필요 없고, 키보드와 스크린리더가 그냥 동작하며,
5 무엇보다 **현재 페이지가 든 갈래만 서버가 열어 두므로** 첫 페인트부터 상태가
6 맞다. JS로 열면 펼쳐지는 순간이 눈에 보인다. #}
7 {% macro nav(sections, current, open_url) %}
8 <ul class="nav-tree">
9 {%- for s in sections %}
10 <li>
11 {%- if s.pages or s.subsections %}
12 {#- 갈래에 속하지 않은 페이지(홈, 404)에서는 첫 갈래를 열어 둔다. 다섯 개가
13 전부 닫혀 있으면 처음 온 사람은 안에 뭐가 있는지 알 수가 없다. #}
14 <details class="nav-group"{% if s.url == open_url or s.url == current or (not open_url and loop.first) %} open{% endif %}>
15 <summary>{{ s.title }}</summary>
16 <ul>
17 {#- summary는 링크가 될 수 없다(누르면 접힌다). 섹션 인덱스로 가는 길을
18 첫 항목으로 따로 낸다. #}
19 <li><a href="{{ s.url }}"{% if s.url == current %} aria-current="page"{% endif %}>{{ t("overview") }}</a></li>
20 {%- for p in s.pages %}
21 <li><a href="{{ p.url }}"{% if p.url == current %} aria-current="page"{% endif %}>{{ p.title }}</a></li>
22 {%- endfor %}
23 {%- if s.subsections %}{{ nav(s.subsections, current, open_url) }}{% endif %}
24 </ul>
25 </details>
26 {%- else %}
27 <a class="nav-leaf" href="{{ s.url }}"{% if s.url == current %} aria-current="page"{% endif %}>{{ s.title }}</a>
28 {%- endif %}
29 </li>
30 {%- endfor %}
31 </ul>
32 {% endmacro %}