Skip to content

Commit 4e53b62

Browse files
committed
fix: auto-hide missing scholarships menu links
if any section, e.g. Individual Giving #angel-fund, is missing remove it from the secondary nav this eliminates the need to keep commenting out entries in the nav frontmatter to stay current with what sections are shown
1 parent ee2848a commit 4e53b62

File tree

1 file changed

+17
-10
lines changed

1 file changed

+17
-10
lines changed

general-info/scholarships.html

Lines changed: 17 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44
nav: general-info
55
active: Scholarships
66
subnav:
7-
# - name: 'Additional Funding'
8-
# url: '#additional-funding'
7+
- name: 'Additional Funding'
8+
url: '#additional-funding'
99
- name: Recipients
1010
url: '#recipients'
1111
- name: 'Eligibility, Criteria, & Requirements'
@@ -99,9 +99,6 @@ <h2 id="recipients">{{year}} Code4Lib Scholarship Recipients</h2>
9999
{% endif %}
100100
{% endfor %}
101101
</dl>
102-
{% else %}
103-
{% comment %} remove from secondary nav (jQuery not yet on page) {% endcomment %}
104-
<script>document.querySelector('.secondarynav a[href="#recipients"]').parentElement.remove()</script>
105102
{% endif %}
106103
</div>
107104
</div>
@@ -147,8 +144,7 @@ <h2 id="sponsors">Made possible by the generosity of our sponsors and community<
147144
<div class="container-fluid">
148145
<div class="row">
149146
<div class="col-12">
150-
<a name="criteria"></a>
151-
<h2>Eligibility, Criteria, And Requirements</h2>
147+
<h2 id="criteria">Eligibility, Criteria, And Requirements</h2>
152148
{% if site.data.conf.criteria.show %}
153149
<h3>Eligibility Criteria</h3>
154150
<p>
@@ -179,8 +175,7 @@ <h2>Registration Details</h2>
179175
<div class="container-fluid">
180176
<div class="row">
181177
<div class="col-12">
182-
<a name="how-to-apply"></a>
183-
<h2>How to Apply</h2>
178+
<h2 id="how-to-apply">How to Apply</h2>
184179
{% if site.data.conf.diversity-scholarship-applications.show %}
185180
<p>
186181
Submit your application materials via the Code4Lib online form: <a href="{{ site.data.conf.diversity-scholarship-applications.apply-url }}">{{ site.data.conf.diversity-scholarship-applications.apply-url }}</a>
@@ -208,7 +203,9 @@ <h2>How to Apply</h2>
208203
</div>
209204
</div>
210205

211-
{% include_relative angel-fund.html %}
206+
{% if site.data.conf.angel-fund.show %}
207+
{% include_relative angel-fund.html %}
208+
{% endif %}
212209

213210
<h2>Testimonials by Previous Awardees</h2>
214211
<p>
@@ -217,3 +214,13 @@ <h2>Testimonials by Previous Awardees</h2>
217214
"With the support of the Code4Lib Diversity Scholarship, I attended the Code4Lib 2022 Conference. This is the first in-person conference I have attended since the Pandemic. It is indeed exciting to regain the opportunity to meet colleagues in library technology related areas physically from other institutions in the US and other countries. I enjoyed the presentations and discussions and sensed the passion of the Code4Lib community. Through this conference, I also got the chance to know the City of Buffalo and its surrounding attractions. It is a wonderful experience to be part of the Code4Lib 2022." <b>-Grace Liu</b>
218215
</p>
219216
</section>
217+
218+
<script>
219+
// for each entry in the secondary nav, remove it if no matching section exists
220+
document.querySelectorAll('.secondarynav ul a').forEach(element => {
221+
const sectionId = element.getAttribute('href')
222+
if (sectionId && !document.querySelector(sectionId)) {
223+
element.parentElement.remove()
224+
}
225+
})
226+
</script>

0 commit comments

Comments
 (0)