mirror of
https://github.com/hyzendust/hyzendust.github.io.git
synced 2026-04-16 13:48:32 +02:00
89 lines
3.2 KiB
HTML
89 lines
3.2 KiB
HTML
{{ define "main" }}
|
||
|
||
{{ $semesterRaw := .Params.semester }}
|
||
{{ $subjectcodeRaw := .Params.subjectcode }}
|
||
{{ $semester := "" }}
|
||
{{ if reflect.IsSlice $semesterRaw }}
|
||
{{ $semester = index $semesterRaw 0 }}
|
||
{{ else }}
|
||
{{ $semester = $semesterRaw }}
|
||
{{ end }}
|
||
{{ $subjectcode := "" }}
|
||
{{ if reflect.IsSlice $subjectcodeRaw }}
|
||
{{ $subjectcode = index $subjectcodeRaw 0 }}
|
||
{{ else }}
|
||
{{ $subjectcode = $subjectcodeRaw }}
|
||
{{ end }}
|
||
|
||
<nav class="uninotes-breadcrumbs breadcrumbs">
|
||
<a href="/uninotes/">UniNotes</a>
|
||
{{ if $semester }}
|
||
{{ $semPage := site.GetPage (printf "/semester/%s" ($semester | urlize)) }}
|
||
{{ if $semPage }}
|
||
› <a href="{{ $semPage.RelPermalink }}">{{ $semester }}</a>
|
||
{{ end }}
|
||
{{ end }}
|
||
{{ if $subjectcode }}
|
||
{{ $subPage := site.GetPage (printf "/subjectcode/%s" ($subjectcode | urlize)) }}
|
||
{{ if $subPage }}
|
||
› <a href="{{ $subPage.RelPermalink }}">{{ $subjectcode }}</a>
|
||
{{ end }}
|
||
{{ end }}
|
||
› <a href="{{ .Params.uniturl }}">{{ .Params.unit | default .Title }}</a>
|
||
› <span>{{ .Params.notecategory | default "Notes" }}</span>
|
||
</nav>
|
||
|
||
<div class="uninotes-meta">
|
||
{{ with $semester }}<span class="uninotes-meta__pill">{{ . }}</span>{{ end }}
|
||
{{ with $subjectcode }}<span class="uninotes-meta__pill">{{ . }}</span>{{ end }}
|
||
{{ with .Params.notecategory }}
|
||
<span class="uninotes-meta__pill uninotes-meta__pill--{{ . | lower }}">{{ . }}</span>
|
||
{{ end }}
|
||
</div>
|
||
|
||
<h1>{{ .Params.unit | default .Title }}</h1>
|
||
|
||
{{ partial "page/toc.html" . }}
|
||
|
||
{{ .Content }}
|
||
|
||
{{ partial "page/terms.html" (dict "taxonomy" "tags" "page" .) }}
|
||
{{ partial "page/terms.html" (dict "taxonomy" "categories" "page" .) }}
|
||
|
||
{{/* Next/prev among sibling UNITS in the same subjectcode — deduplicated by unit label */}}
|
||
{{ if $subjectcode }}
|
||
{{ $subPage := site.GetPage (printf "/subjectcode/%s" ($subjectcode | urlize)) }}
|
||
{{ if $subPage }}
|
||
{{/* Build a deduplicated list of units: one entry per unit label, using the Self page as representative */}}
|
||
{{ $unitMap := slice }}
|
||
{{ $seenUnits := slice }}
|
||
{{ range $subPage.Pages.ByWeight }}
|
||
{{ $unitLabel := (.Params.unit | default .Title) }}
|
||
{{ if not (in $seenUnits $unitLabel) }}
|
||
{{ $seenUnits = $seenUnits | append $unitLabel }}
|
||
{{ $unitMap = $unitMap | append . }}
|
||
{{ end }}
|
||
{{ end }}
|
||
{{ $currentUnit := (.Params.unit | default .Title) }}
|
||
{{ $currentIdx := 0 }}
|
||
{{ range $i, $p := $unitMap }}
|
||
{{ if eq ($p.Params.unit | default $p.Title) $currentUnit }}{{ $currentIdx = $i }}{{ end }}
|
||
{{ end }}
|
||
{{ if gt (len $unitMap) 1 }}
|
||
<nav class="page-nav">
|
||
{{ if gt $currentIdx 0 }}
|
||
{{ $prev := index $unitMap (sub $currentIdx 1) }}
|
||
<a class="page-nav__previous-link" href="{{ $prev.Params.uniturl }}">← {{ $prev.Params.unit | default $prev.Title }}</a>
|
||
{{ end }}
|
||
{{ if lt $currentIdx (sub (len $unitMap) 1) }}
|
||
{{ $next := index $unitMap (add $currentIdx 1) }}
|
||
<a class="page-nav__next-link" href="{{ $next.Params.uniturl }}">{{ $next.Params.unit | default $next.Title }} →</a>
|
||
{{ end }}
|
||
</nav>
|
||
{{ end }}
|
||
{{ end }}
|
||
{{ end }}
|
||
|
||
{{ partial "page/page-end.html" . }}
|
||
{{ end }}
|