only display adjacent works in NovelNav

This commit is contained in:
perennial
2024-10-08 15:15:32 +11:00
parent e8be694bbe
commit 09652440b8
2 changed files with 37 additions and 18 deletions
+29 -16
View File
@@ -1,22 +1,35 @@
{{- block NovelNav(baseURL, paths, names, activeState="") }}
<div class="row nav nav-underline justify-content-center bg-charcoal-surface2 rounded py-4 mx-4">
<!-- NOTE: Border or no border? cant decide -->
<div class="row nav nav-underline justify-content-center border border-1 rounded py-4 mx-4">
{{- activeIndex := -1 }}
{{- range i, k := paths }}
<div class="col-12 col-lg-3">
{{ if k == activeState }}
<span class="nav-link text-center
{{ activeState == k ? "active border-bottom border-4 border-custom-color fw-bold" : "text-body-secondary fw-semibold" }}"
{{ activeState == k ? `aria-current="page"` : "" }}
>
{{ names[i] }}
</span>
{{- else }}
<a class="nav-link text-center
{{ activeState == k ? "active border-bottom border-4 border-custom-color fw-bold" : "text-body-secondary fw-semibold" }}"
{{ activeState == k ? `aria-current="page"` : "" }}
href="{{ baseURL }}{{k}}">
{{ names[i] }}
</a>
{{- if k == activeState }}
{{- activeIndex = i }}
{{- end }}
{{- end }}
{{- if activeIndex > 0 }}
<div class="col-12 col-lg-3">
<a class="nav-link text-center text-body-secondary fw-semibold"
href="{{ baseURL }}{{paths[activeIndex-1]}}">
{{ names[activeIndex-1] }}
</a>
</div>
{{- end }}
<div class="col-12 col-lg-3">
<span class="nav-link text-center active border-bottom border-4 border-custom-color fw-bold"
aria-current="page">
{{ names[activeIndex] }}
</span>
</div>
{{- if activeIndex < len(paths) - 1 }}
<div class="col-12 col-lg-3">
<a class="nav-link text-center text-body-secondary fw-semibold"
href="{{ baseURL }}{{paths[activeIndex+1]}}">
{{ names[activeIndex+1] }}
</a>
</div>
{{- end }}
</div>
+8 -2
View File
@@ -210,7 +210,7 @@
</div>
<!-- Series navigation, if present -->
<!-- NOTE: col element unconditionally for spacing -->
<!-- NOTE: col element rendered unconditionally for spacing -->
<div class="col-12 my-4">
{{- if .Novel.SeriesNavData }}
<h2 class="text-center mb-2">
@@ -219,8 +219,14 @@
</a>
</h2>
<h3 class="text-body-secondary text-center mb-4">
<!-- NOTE: the logic below is necessary because some series consist of only a single work, and "1 works" would be incorrect -->
<a href="/novel/series/{{ .Novel.SeriesNavData.SeriesID }}" class="text-body-secondary text-decoration-none">
<i class="bi bi-stack me-2"></i>{{ len(.NovelSeriesContentTitles) }} works in this series
<i class="bi bi-stack me-2"></i>{{ len(.NovelSeriesContentTitles) }}
{{- if len(.NovelSeriesContentTitles) == 1 }}
work in this series
{{- else }}
works in this series
{{- end }}
</a>
</h3>