mirror of
https://github.com/hyzendust/hyzendust.github.io.git
synced 2026-04-15 21:28:32 +02:00
Add: live notes
This commit is contained in:
@@ -29,12 +29,17 @@
|
||||
<h1>{{ $subjectCode }}</h1>
|
||||
|
||||
<ul class="uninotes-list uninotes-list--units">
|
||||
{{ $seenUnits := slice }}
|
||||
{{ range .Pages.ByWeight }}
|
||||
<li class="uninotes-list__item">
|
||||
<a class="uninotes-list__link" href="{{ .RelPermalink }}">
|
||||
{{ with .Params.unit }}{{ . }}{{ else }}{{ .Title }}{{ end }}
|
||||
</a>
|
||||
</li>
|
||||
{{ $unitLabel := (.Params.unit | default .Title) }}
|
||||
{{ if not (in $seenUnits $unitLabel) }}
|
||||
{{ $seenUnits = $seenUnits | append $unitLabel }}
|
||||
<li class="uninotes-list__item">
|
||||
<a class="uninotes-list__link" href="{{ .Params.uniturl }}">
|
||||
{{ $unitLabel }}
|
||||
</a>
|
||||
</li>
|
||||
{{ end }}
|
||||
{{ end }}
|
||||
</ul>
|
||||
|
||||
|
||||
@@ -29,12 +29,16 @@
|
||||
› <a href="{{ $subPage.RelPermalink }}">{{ $subjectcode }}</a>
|
||||
{{ end }}
|
||||
{{ end }}
|
||||
› <span>{{ .Params.unit | default .Title }}</span>
|
||||
› <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>
|
||||
@@ -46,25 +50,34 @@
|
||||
{{ 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 */}}
|
||||
{{/* 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 }}
|
||||
{{ $siblings := $subPage.Pages.ByWeight }}
|
||||
{{ $currentPermalink := .RelPermalink }}
|
||||
{{ $currentIdx := 0 }}
|
||||
{{ range $i, $p := $siblings }}
|
||||
{{ if eq $p.RelPermalink $currentPermalink }}{{ $currentIdx = $i }}{{ end }}
|
||||
{{/* 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 }}
|
||||
{{ if gt (len $siblings) 1 }}
|
||||
{{ $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 $siblings (sub $currentIdx 1) }}
|
||||
<a class="page-nav__previous-link" href="{{ $prev.RelPermalink }}">← {{ $prev.Params.unit | default $prev.Title }}</a>
|
||||
{{ $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 $siblings) 1) }}
|
||||
{{ $next := index $siblings (add $currentIdx 1) }}
|
||||
<a class="page-nav__next-link" href="{{ $next.RelPermalink }}">{{ $next.Params.unit | default $next.Title }} →</a>
|
||||
{{ 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 }}
|
||||
|
||||
78
layouts/uninotes/unit-choice.html
Normal file
78
layouts/uninotes/unit-choice.html
Normal file
@@ -0,0 +1,78 @@
|
||||
{{ define "main" }}
|
||||
|
||||
{{/* Get semester and subjectcode from child pages since _index.md doesn't carry taxonomy params */}}
|
||||
{{ $semester := "" }}
|
||||
{{ $subjectcode := "" }}
|
||||
{{ range .Pages }}
|
||||
{{ if eq $semester "" }}
|
||||
{{ $raw := .Params.semester }}
|
||||
{{ $semester = cond (reflect.IsSlice $raw) (index $raw 0) $raw }}
|
||||
{{ end }}
|
||||
{{ if eq $subjectcode "" }}
|
||||
{{ $raw := .Params.subjectcode }}
|
||||
{{ $subjectcode = cond (reflect.IsSlice $raw) (index $raw 0) $raw }}
|
||||
{{ end }}
|
||||
{{ 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 }}
|
||||
› <span>{{ .Params.unit | default .Title }}</span>
|
||||
</nav>
|
||||
|
||||
<div class="uninotes-meta">
|
||||
{{ with $semester }}<span class="uninotes-meta__pill">{{ . }}</span>{{ end }}
|
||||
{{ with $subjectcode }}<span class="uninotes-meta__pill">{{ . }}</span>{{ end }}
|
||||
</div>
|
||||
|
||||
<h1>{{ .Params.unit | default .Title }}</h1>
|
||||
|
||||
<p class="unit-choice__subtitle">Choose type:</p>
|
||||
|
||||
{{/* Check if a live page exists at the expected URL */}}
|
||||
{{ $hasLive := false }}
|
||||
{{ range .Pages }}
|
||||
{{ if eq (lower .Params.notecategory) "live" }}{{ $hasLive = true }}{{ end }}
|
||||
{{ end }}
|
||||
|
||||
<div class="unit-choice__options">
|
||||
<a class="unit-choice__card unit-choice__card--self" href="{{ .RelPermalink }}self/">
|
||||
<div class="unit-choice__icon">
|
||||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" width="32" height="32" fill="currentColor">
|
||||
<path d="M12 3L1 9l4 2.18v6L12 21l7-3.82v-6l2-1.09V17h2V9L12 3zm6.82 6L12 12.72 5.18 9 12 5.28 18.82 9zM17 15.99l-5 2.73-5-2.73v-3.72L12 15l5-2.73v3.72z"/>
|
||||
</svg>
|
||||
</div>
|
||||
<div class="unit-choice__label">Self</div>
|
||||
<div class="unit-choice__desc">Self-study notes</div>
|
||||
</a>
|
||||
|
||||
{{ if $hasLive }}
|
||||
<a class="unit-choice__card unit-choice__card--live" href="{{ .RelPermalink }}live/">
|
||||
{{ else }}
|
||||
<div class="unit-choice__card unit-choice__card--live unit-choice__card--unavailable">
|
||||
{{ end }}
|
||||
<div class="unit-choice__icon">
|
||||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" width="32" height="32" fill="currentColor">
|
||||
<path d="M17 10.5V7c0-.55-.45-1-1-1H4c-.55 0-1 .45-1 1v10c0 .55.45 1 1 1h12c.55 0 1-.45 1-1v-3.5l4 4v-11l-4 4z"/>
|
||||
</svg>
|
||||
</div>
|
||||
<div class="unit-choice__label">Live</div>
|
||||
<div class="unit-choice__desc">
|
||||
{{ if $hasLive }}Live class notes
|
||||
{{ else }}Coming soon{{ end }}
|
||||
</div>
|
||||
{{ if $hasLive }}</a>{{ else }}</div>{{ end }}
|
||||
</div>
|
||||
|
||||
{{ end }}
|
||||
Reference in New Issue
Block a user