Skip to content

Commit

Permalink
revamp accordion identifier for resources and reformatted for better …
Browse files Browse the repository at this point in the history
…readability

- used crypto.MD5 instead of integer counter
- used better templating style instead of print
  • Loading branch information
AARandom committed Jul 22, 2024
1 parent 81ae07d commit abbcdfe
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions layouts/page/resources.html
Original file line number Diff line number Diff line change
Expand Up @@ -45,15 +45,16 @@ <h6 class="text-uppercase mb-0">
<div class="d-grid pb-2">
{{ range .subsection }}
<!-- Each category in a subject is a dropdown menu (accordion component) by itself -->
{{ $accordionID := crypto.MD5 (print $group_name .subsection_name) }}
<!-- Each dropdown must have unique id, even in different tabs -->
<div class="accordion accordion-flush">
<div class="accordion-item" id={{ $accordionCounter }}>
<h2 class="accordion-header" id={{ print "heading-" $accordionCounter }}>
<button class="accordion-button collapsed" type="button" data-bs-toggle="collapse" data-bs-target={{ print "#body-" $accordionCounter }} aria-expanded="true" aria-controls={{ print "body-" $accordionCounter }}>
<div class="accordion-item" id="resourcesAccordion-{{ $accordionID }}">
<h2 class="accordion-header" id="heading-{{ $accordionID }}">
<button class="accordion-button collapsed" type="button" data-bs-toggle="collapse" data-bs-target="#body-{{ $accordionID }}" aria-expanded="true" aria-controls="body-{{ $accordionID }}">
{{ .subsection_name }}
</button>
</h2>
<div id={{ print "body-" $accordionCounter }} class="accordion-collapse collapse" aria-labelledby={{ print "heading-" $accordionCounter }} data-bs-parent={{ print "#" $accordionCounter }}>
<div id="body-{{ $accordionID }}" class="accordion-collapse collapse" aria-labelledby="heading-{{ $accordionID }}" data-bs-parent="#faqAccordion-{{ $accordionID }}">
<div class="accordion-body">
<!-- Gallery component inside the accordion body -->
<div class="d-grid gap-2 gap-sm-4 pb-2 gallery-grid">
Expand Down Expand Up @@ -83,7 +84,6 @@ <h2 class="accordion-header" id={{ print "heading-" $accordionCounter }}>
</div>
</div>
</div>
{{ $accordionCounter = add $accordionCounter 1 }}
</div>
{{ end }}
</div>
Expand Down

0 comments on commit abbcdfe

Please sign in to comment.