Files
hyzendust.github.io/layouts/uninotes/single.html
2026-04-11 19:24:18 +05:30

89 lines
3.2 KiB
HTML
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
{{ 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 }}