Skip to content

Commit

Permalink
perf(terms): avoid generating custom pages collection
Browse files Browse the repository at this point in the history
  • Loading branch information
razonyang committed Jun 2, 2024
1 parent a0d058d commit eee6fe9
Showing 1 changed file with 5 additions and 11 deletions.
16 changes: 5 additions & 11 deletions layouts/_default/terms.html
Original file line number Diff line number Diff line change
@@ -1,28 +1,22 @@
{{- define "main" }}
{{- $pages := slice }}
{{- range .Data.Pages }}
{{- if gt (len .RegularPages) 0 }}
{{- $pages = $pages | append . }}
{{- end }}
{{- end }}
<div class="row align-items-center flex-grow-1 hb-module">
<div class="col-6 offset-3">
<h1 class="mb-4 pb-3 text-center border-bottom">
{{- .Title -}}
<small class="ms-1 text-secondary">({{- len $pages -}})</small>
<small class="ms-1 text-secondary">({{- len .Data.Terms -}})</small>
</h1>
<ul
class="hb-terms-cloud list-unstyled ps-0 d-flex flex-wrap align-items-center justify-content-center">
{{- range $i, $page := $pages }}
{{- $totalPages := len .RegularPages }}
{{- range $i, $term := .Data.Terms }}
{{- $totalPages := len .Pages }}
{{- $fontSize := div $totalPages 3 }}
{{- $fontSize = math.Min $fontSize 12 }}
<li class="mx-1 my-2">
<a
data-total-pages="{{ $totalPages }}"
href="{{ .RelPermalink }}"
href="{{ .Page.RelPermalink }}"
style="--size: {{ $fontSize }};">
{{- .Title -}}
{{- .Page.Title -}}
<span class="ms-1">({{- $totalPages -}})</span>
</a>
</li>
Expand Down

0 comments on commit eee6fe9

Please sign in to comment.