Skip to content

Commit

Permalink
fixup! templates: render static pages using templ
Browse files Browse the repository at this point in the history
Signed-off-by: Sumner Evans <me@sumnerevans.com>
  • Loading branch information
sumnerevans committed May 25, 2024
1 parent ca3fa52 commit 599d2c8
Show file tree
Hide file tree
Showing 2 changed files with 64 additions and 59 deletions.
122 changes: 63 additions & 59 deletions internal/templates/archive.templ
Original file line number Diff line number Diff line change
Expand Up @@ -73,69 +73,73 @@ templ Archive(years []YearInfo) {
</div>
</div>
<div class="container page-content archive pb-5">
for _, year := range years {
<div class="row mb-4 pt-4">
<div class="col-lg-5 mt-4 mx-4">
<h2>{ strconv.Itoa(year.Year) }</h2>
for _, p := range year.RecapParagraphs {
<p>{ p }</p>
}
</div>
<div class="col mt-5">
<div class="accordion">
for _, r := range year.Results {
<div class="accordion-item">
<h2 class="accordion-header" id={ accordionHeadingID(year.Year, r.Shortname) }>
<button
class="accordion-button collapsed"
type="button"
data-bs-toggle="collapse"
data-bs-target={ accordionCollapseCSSID(year.Year, r.Shortname) }
aria-expanded="true"
aria-controls={ accordionCollapseID(year.Year, r.Shortname) }
>
<strong>{ r.Name } Competition Winners</strong>
</button>
</h2>
</div>
<div
id={ accordionCollapseID(year.Year, r.Shortname) }
class="accordion-collapse collapse"
aria-labelledby={ accordionHeadingID(year.Year, r.Shortname) }
for _, y := range years {
@year(y)
}
</div>
}

templ year(y YearInfo) {
<div class="row mb-4 pt-4">
<div class="col-lg-5 mt-4 mx-4">
<h2>{ strconv.Itoa(y.Year) }</h2>
for _, p := range y.RecapParagraphs {
<p>{ p }</p>
}
</div>
<div class="col mt-5">
<div class="accordion">
for _, r := range y.Results {
<div class="accordion-item">
<h2 class="accordion-header" id={ accordionHeadingID(y.Year, r.Shortname) }>
<button
class="accordion-button collapsed"
type="button"
data-bs-toggle="collapse"
data-bs-target={ accordionCollapseCSSID(y.Year, r.Shortname) }
aria-expanded="true"
aria-controls={ accordionCollapseID(y.Year, r.Shortname) }
>
<div class="accordion-body">
for i, t := range r.Teams {
<li class="list-group-item">
<span class="badge bg-primary rounded-pill">
<i
class={ "fa" , "fa-trophy" , trophyColorStyle(i) }
role="img"
aria-label="Trophy"
></i>
{ t.Place }
</span>
<strong>{ t.Name }</strong>
<p class="mb-1 text-secondary">
{ t.School } &bull; { t.Location }
</p>
</li>
}
</div>
</div>
}
<strong>{ r.Name } Competition Winners</strong>
</button>
</h2>
</div>
</div>
<div class="row">
<div class="col mx-4">
for i, link := range year.Links {
if i > 0 {
&nbsp;&bull;
<div
id={ accordionCollapseID(y.Year, r.Shortname) }
class="accordion-collapse collapse"
aria-labelledby={ accordionHeadingID(y.Year, r.Shortname) }
>
<div class="accordion-body">
for i, t := range r.Teams {
@winningTeam(i, t)
}
<a href={ link.URL } target="_blank">{ link.Title }</a>
}
</div>
</div>
</div>
}
</div>
}
</div>
<div class="row">
<div class="col mx-4">
for i, link := range y.Links {
if i > 0 {
&nbsp;&bull;
}
<a href={ link.URL } target="_blank">{ link.Title }</a>
}
</div>
</div>
</div>
}

templ winningTeam(i int, team WinningTeam) {
<li class="list-group-item">
<span class="badge bg-primary rounded-pill">
<i class={ "fa" , "fa-trophy" , trophyColorStyle(i) } role="img" aria-label="Trophy"></i>
{ team.Place }
</span>
<strong>{ team.Name }</strong>
<p class="mb-1 text-secondary">
{ team.School } &bull; { team.Location }
</p>
</li>
}
1 change: 1 addition & 0 deletions internal/templates/partials/pagenames.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package partials

// TODO consider moving this somewhere else
type PageName string

const (
Expand Down

0 comments on commit 599d2c8

Please sign in to comment.