@@ -42,130 +42,111 @@ <h2 class="c-sidebar__title">{{ site.title }}</h2>
42
42
{%- endfor %}
43
43
{% if chapter.external == true %}{% assign chapter_title = chapter.title %}{% endif %}
44
44
45
- {% comment %}
46
- If the entry is the current page, assign a CSS class to highlight it.
47
- {% endcomment %}
48
- {% if page.url contains chapter.url %}
49
- {% assign active_class = "c-sidebar__entry--active" %}
50
- {% else %}
51
- {% assign active_class = "" %}
52
- {% endif %}
53
-
54
45
{% assign topUrl = chapter.url | relative_url %}
55
46
{% unless chapter.external == true %}
56
47
{% assign topUrl = topUrl | append: '.html' %}
57
48
{% endunless %}
58
- < li class ="c-sidebar__chapter ">
59
- < a class ="c-sidebar__entry {{ active_class }} "
49
+ < li class ="c-sidebar__chapter " data-url =" {{ chapter.url }} " >
50
+ < a class ="c-sidebar__entry "
60
51
href ="{{ topUrl }} "
61
52
>
62
53
{% unless chapter.not_numbered or site.number_toc_chapters != true %}
63
54
{{ chapter_num }}.
64
55
{% endunless %}
65
56
{{ chapter_title }}
66
57
</ a >
58
+ </ li >
59
+
60
+ {% comment %}
61
+ Flags for whether we hide all inactive sections or sub-sections
62
+ {% endcomment %}
63
+ {% if site.collapse_inactive_chapters == true %}
64
+ {% assign sectionsHideClass = " u-hidden-visually" %}
65
+ {% else %}
66
+ {% assign sectionsHideClass = "" %}
67
+ {% endif %}
68
+
69
+ {% if site.collapse_inactive_sections == true %}
70
+ {% assign subSectionsHideClass = " u-hidden-visually" %}
71
+ {% else %}
72
+ {% assign subSectionsHideClass = "" %}
73
+ {% endif %}
67
74
68
- {% if chapter.sections %}
75
+ {% comment %}Per-chapter overrides from TOC data{% endcomment %}
76
+ {% if chapter.expand_sections == true %}
77
+ {% assign sectionsHideClass = "" %}
78
+ {% endif %}
79
+
80
+ {% if chapter.sections %}
81
+ {% comment %}
82
+ By default, all sections are hidden. We show a chapter's sections
83
+ if the chapter or any of its sections are the current page.
84
+ {% endcomment %}
69
85
70
- {% comment %}
71
- By default, all sections are hidden. We show a chapter's sections
72
- if the chapter or any of its sections are the current page.
73
- {% endcomment %}
74
- {% assign any_section_active = 0 %}
86
+ {% assign section_num = 1 %}
87
+
88
+ < ul class ="c-sidebar__sections{{ sectionsHideClass }} ">
75
89
{% for section in chapter.sections %}
76
- {% if page.url contains section.url or chapter.expand_sections %}
77
- {% assign any_section_active = 1 %}
78
- {% elsif section.subsections %}
90
+ {% comment %}Per-section overrides from TOC data{% endcomment %}
91
+ {% if section.expand_subsections == true %}
92
+ {% assign subSectionsHideClass = "" %}
93
+ {% endif %}
94
+
95
+ {% comment %}
96
+ Find the title for this chapter
97
+ {% endcomment %}
98
+ {% assign section_url_html = section.url | append: '.html' %}
99
+ {% for build_page in site.build %}
100
+ {% if build_page.url == section_url_html %}
101
+ {% assign section_title = build_page.title %}
102
+ {% endif %}
103
+ {%- endfor %}
104
+ {% if section.external == true %}{% assign section_title = section.title %}{% endif %}
105
+
106
+ < li class ="c-sidebar__section " data-url ="{{ section.url }} ">
107
+ < a class ="c-sidebar__entry "
108
+ href ="{{ section.url | relative_url | append: '.html'}} "
109
+ >
110
+ {% unless chapter.not_numbered or section.not_numbered or site.number_toc_chapters != true %}
111
+ {{ chapter_num }}.{{ section_num }}
112
+ {% endunless %}
113
+ {{ section_title }}
114
+ </ a >
115
+ </ li >
116
+ {% if section.subsections %}
117
+ {% assign subsection_num = 1 %}
118
+ < ul class ='c-sidebar__subsections{{ subSectionsHideClass }} '>
79
119
{% for subsection in section.subsections %}
80
- {% if page.url contains subsection.url %}
81
- {% assign any_section_active = 1 %}
82
- {% endif %}
120
+ {% comment %}
121
+ Find the title for this sub-section
122
+ {% endcomment %}
123
+ {% assign subsection_url_html = subsection.url | append: '.html' %}
124
+ {% for build_page in site.build %}
125
+ {% if build_page.url == subsection_url_html %}
126
+ {% assign subsection_title = build_page.title %}
127
+ {% endif %}
128
+ {%- endfor %}
129
+ {% if subsection.external == true %}{% assign subsection_title = subsection.title %}{% endif %}
130
+ < li class ="c-sidebar__subsection " data-url ="{{ subsection.url }} ">
131
+ < a class ="c-sidebar__entry "
132
+ href ="{{ subsection.url | relative_url | append: '.html'}} "
133
+ >
134
+ {% unless chapter.not_numbered or section.not_numbered or subsection.not_numbered or site.number_toc_chapters != true %}
135
+ {{ chapter_num }}.{{ section_num }}.{{ subsection_num }}
136
+ {% assign subsection_num = subsection_num | plus: 1 %}
137
+ {% endunless %}
138
+ {{ subsection_title }}
139
+ </ a >
140
+ </ li >
83
141
{% endfor %}
84
- {% elsif page.url contains chapter.url %}
85
- {% assign any_section_active = 1 %}
142
+ </ ul >
86
143
{% endif %}
144
+ {% unless chapter.not_numbered or section.not_numbered %}
145
+ {% assign section_num = section_num | plus: 1 %}
146
+ {% endunless %}
87
147
{% endfor %}
88
- {% if any_section_active > 0 or site.collapse_inactive_chapters == false %}
89
- {% assign hide_section_class = "" %}
90
- {% else %}
91
- {% assign hide_section_class = "u-hidden-visually" %}
92
- {% endif %}
93
-
94
- {% assign section_num = 1 %}
95
-
96
- < ul class ="c-sidebar__sections {{ hide_section_class }} ">
97
- {% for section in chapter.sections %}
98
- {% comment %}
99
- If the entry is the current page, assign a CSS class to highlight
100
- it.
101
- {% endcomment %}
102
- {% if page.url contains section.url %}
103
- {% assign active_class = "c-sidebar__entry--active" %}
104
- {% else %}
105
- {% assign active_class = "" %}
106
- {% endif %}
107
-
108
- {% comment %}
109
- Find the title for this section
110
- {% endcomment %}
111
- {% assign section_url_html = section.url | append: '.html' %}
112
- {% for build_page in site.build %}
113
- {% if build_page.url == section_url_html %}
114
- {% assign section_title = build_page.title %}
115
- {% endif %}
116
- {%- endfor %}
117
- {% if section.external == true %}{% assign section_title = section.title %}{% endif %}
118
- < li class ="c-sidebar__section ">
119
- < a class ="c-sidebar__entry {{ active_class }} "
120
- href ="{{ section.url | relative_url | append: '.html'}} "
121
- >
122
- {% unless chapter.not_numbered or section.not_numbered or site.number_toc_chapters != true %}
123
- {{ chapter_num }}.{{ section_num }}
124
- {% endunless %}
125
- {{ section_title }}
126
- </ a >
127
-
128
- {% assign subsection_num = 1 %}
129
- {% for subsection in section.subsections %}
130
- {% comment %}
131
- Now add sub-sections. These will always be shown if they exist.
132
- {% endcomment %}
133
- {% if page.url contains subsection.url %}
134
- {% assign active_class = "c-sidebar__entry--active" %}
135
- {% else %}
136
- {% assign active_class = "" %}
137
- {% endif %}
138
-
139
- {% comment %}
140
- Find the title for this sub-section
141
- {% endcomment %}
142
- {% assign subsection_url_html = subsection.url | append: '.html' %}
143
- {% for build_page in site.build %}
144
- {% if build_page.url == subsection_url_html %}
145
- {% assign subsection_title = build_page.title %}
146
- {% endif %}
147
- {%- endfor %}
148
- {% if subsection.external == true %}{% assign subsection_title = subsection.title %}{% endif %}
149
- < li class ="c-sidebar__subsection ">
150
- < a class ="c-sidebar__entry {{ active_class }} "
151
- href ="{{ subsection.url | relative_url | append: '.html'}} "
152
- >
153
- {% unless chapter.not_numbered or section.not_numbered or subsection.not_numbered or site.number_toc_chapters != true %}
154
- {{ chapter_num }}.{{ section_num }}.{{ subsection_num }}
155
- {% assign subsection_num = subsection_num | plus: 1 %}
156
- {% endunless %}
157
- {{ subsection_title }}
158
- </ a >
159
- {% endfor %}
160
-
161
- </ li >
162
- {% unless chapter.not_numbered or section.not_numbered %}
163
- {% assign section_num = section_num | plus: 1 %}
164
- {% endunless %}
165
- {% endfor %}
166
- </ ul >
167
- {% endif %}
168
- </ li >
148
+ </ ul >
149
+ {% endif %}
169
150
170
151
{% unless chapter.not_numbered %}
171
152
{% assign chapter_num = chapter_num | plus: 1 %}
0 commit comments