{{ define "main" }}

UniNotes

Contents

{{/* Build full tree: semester → subjectcode → units → self/live */}} {{ $semesters := site.Taxonomies.semester.Alphabetical }}
{{ range $semesters }} {{ $semName := .Page.Title }} {{ $semPages := .Pages }} {{/* Collect unique subject codes for this semester */}} {{ $subjectCodes := slice }} {{ range $semPages }} {{ $raw := .Params.subjectcode }} {{ $code := "" }} {{ if reflect.IsSlice $raw }}{{ $code = index $raw 0 }}{{ else }}{{ $code = $raw }}{{ end }} {{ if and $code (not (in $subjectCodes $code)) }} {{ $subjectCodes = $subjectCodes | append $code }} {{ end }} {{ end }} {{ $subjectCodes = sort $subjectCodes }} {{ if $subjectCodes }}
{{ $semName }} {{ range $subjectCodes }} {{ $code := . }} {{ $subPage := site.GetPage (printf "/subjectcode/%s" ($code | urlize)) }} {{/* Collect one representative page per unit for this subject */}} {{ $units := slice }} {{ $seenUnits := slice }} {{ range $semPages.ByWeight }} {{ $raw := .Params.subjectcode }} {{ $sc := "" }} {{ if reflect.IsSlice $raw }}{{ $sc = index $raw 0 }}{{ else }}{{ $sc = $raw }}{{ end }} {{ if eq $sc $code }} {{ $unitLabel := (.Params.unit | default .Title) }} {{ if not (in $seenUnits $unitLabel) }} {{ $seenUnits = $seenUnits | append $unitLabel }} {{ $units = $units | append . }} {{ end }} {{ end }} {{ end }}
{{ if $subPage }} {{ $code }} {{ else }} {{ $code }} {{ end }}
    {{ range $units }} {{ $unitLabel := (.Params.unit | default .Title) }} {{ $unitUrl := .Params.uniturl }} {{/* Find Self and Live URLs for this unit */}} {{ $selfUrl := "" }} {{ $liveUrl := "" }} {{ range $semPages }} {{ $raw := .Params.subjectcode }} {{ $sc := "" }} {{ if reflect.IsSlice $raw }}{{ $sc = index $raw 0 }}{{ else }}{{ $sc = $raw }}{{ end }} {{ $ul := (.Params.unit | default .Title) }} {{ if and (eq $sc $code) (eq $ul $unitLabel) }} {{ $cat := lower .Params.notecategory }} {{ if eq $cat "self" }}{{ $selfUrl = .RelPermalink }}{{ end }} {{ if eq $cat "live" }}{{ $liveUrl = .RelPermalink }}{{ end }} {{ end }} {{ end }}
  • {{ $unitLabel }} {{ if $selfUrl }} Self {{ else }} Self {{ end }} {{ if $liveUrl }} Live {{ else }} Live {{ end }}
  • {{ end }}
{{ end }}
{{ end }} {{ end }}
{{ end }}