mirror of
https://github.com/hyzendust/hyzendust.github.io.git
synced 2026-06-30 23:12:16 +02:00
Fix: breadcrumb
This commit is contained in:
@@ -1,13 +1,18 @@
|
||||
{{ define "main" }}
|
||||
|
||||
<nav class="uninotes-breadcrumbs breadcrumbs">
|
||||
<a href="/blog/">Blog</a>
|
||||
› <span>{{ .Title }}</span>
|
||||
<a href="/blog/">Blog</a>
|
||||
› <span>{{ .Title }}</span>
|
||||
</nav>
|
||||
|
||||
<h1>{{ .Title }}</h1>
|
||||
{{ partial "page/author.html" . }} {{ partial "main/dates.html" . }} {{ partial
|
||||
"page/translation_list.html" . }} {{ partial "page/toc.html" . }} {{ .Content }} {{ partial
|
||||
"page/terms.html" (dict "taxonomy" "tags" "page" .) }} {{ partial "page/terms.html" (dict "taxonomy"
|
||||
"categories" "page" .) }} {{ partial "page/page_nav.html" . }} {{ partial "page/page-end.html" . }}
|
||||
{{ partial "page/author.html" . }}
|
||||
{{ partial "main/dates.html" . }}
|
||||
{{ partial "page/translation_list.html" . }}
|
||||
{{ partial "page/toc.html" . }}
|
||||
{{ .Content }}
|
||||
{{ partial "page/terms.html" (dict "taxonomy" "tags" "page" .) }}
|
||||
{{ partial "page/terms.html" (dict "taxonomy" "categories" "page" .) }}
|
||||
{{ partial "page/page_nav.html" . }}
|
||||
{{ partial "page/page-end.html" . }}
|
||||
{{ end }}
|
||||
|
||||
@@ -1,33 +1,39 @@
|
||||
{{ define "main" }} {{ $sectionPagerSize := or site.Params.sectionPagerSize 10 }} {{ $paginator :=
|
||||
.Paginate .Pages.ByDate.Reverse $sectionPagerSize }}
|
||||
{{ define "main" }}
|
||||
|
||||
{{ $sectionPagerSize := or site.Params.sectionPagerSize 10 }}
|
||||
{{ $paginator := .Paginate .Pages.ByDate.Reverse $sectionPagerSize }}
|
||||
|
||||
<nav class="uninotes-breadcrumbs breadcrumbs">
|
||||
<a href="/blog/">Blog</a>
|
||||
› <a href="/categories/">Categories</a> › <span>{{ .Title }}</span> {{ if gt
|
||||
$paginator.TotalPages 1 }} ›
|
||||
<span>Page {{ $paginator.PageNumber }} of {{ $paginator.TotalPages }}</span>
|
||||
{{ end }}
|
||||
<a href="/blog/">Blog</a>
|
||||
› <a href="/categories/">Categories</a>
|
||||
› <span>{{ .Title }}</span>
|
||||
{{ if gt $paginator.TotalPages 1 }}
|
||||
› <span>Page {{ $paginator.PageNumber }} of {{ $paginator.TotalPages }}</span>
|
||||
{{ end }}
|
||||
</nav>
|
||||
|
||||
{{ .Content }}
|
||||
|
||||
<h1>
|
||||
<a href="/blog/" style="text-decoration: none; color: var(--accent-color)">All Posts</a> |
|
||||
<a href="/categories/" style="text-decoration: none; color: var(--accent-color)">Categories</a>
|
||||
<a href="/blog/" style="text-decoration: none; color: var(--accent-color);">All Posts</a> |
|
||||
<a href="/categories/" style="text-decoration: none; color: var(--accent-color);">Categories</a>
|
||||
</h1>
|
||||
|
||||
<h2>{{ .Title }}</h2>
|
||||
|
||||
<div style="margin-bottom: 2rem"></div>
|
||||
<div style="margin-bottom: 2rem;"></div>
|
||||
|
||||
<section class="posts-list">
|
||||
{{ range $paginator.Pages }} {{ partial "main/dates.html" . }}
|
||||
<h2 class="term-post-title">
|
||||
<a href="{{ .RelPermalink }}">{{ .LinkTitle }}</a>
|
||||
</h2>
|
||||
{{ end }}
|
||||
{{ range $paginator.Pages }}
|
||||
{{ partial "main/dates.html" . }}
|
||||
<h2 class="term-post-title">
|
||||
<a href="{{ .RelPermalink }}">{{ .LinkTitle }}</a>
|
||||
</h2>
|
||||
{{ end }}
|
||||
</section>
|
||||
|
||||
<nav class="paginator">{{- partial "pagination.html" . }}</nav>
|
||||
<nav class="paginator">
|
||||
{{- partial "pagination.html" . }}
|
||||
</nav>
|
||||
|
||||
{{ end }}
|
||||
|
||||
@@ -1,23 +1,29 @@
|
||||
{{ define "main" }} {{ $pages := .Pages }} {{ $sectionPagerSize := or site.Params.sectionPagerSize
|
||||
10 }} {{ $paginator := .Paginate $pages $sectionPagerSize }}
|
||||
{{ define "main" }}
|
||||
{{ $pages := .Pages }}
|
||||
{{ $sectionPagerSize := or site.Params.sectionPagerSize 10 }}
|
||||
{{ $paginator := .Paginate $pages $sectionPagerSize }}
|
||||
|
||||
<nav class="uninotes-breadcrumbs breadcrumbs">
|
||||
<a href="/blog/">Blog</a>
|
||||
{{ if gt $paginator.TotalPages 1 }} ›
|
||||
<span>Page {{ $paginator.PageNumber }} of {{ $paginator.TotalPages }}</span>
|
||||
{{ end }}
|
||||
<a href="/blog/">Blog</a>
|
||||
{{ if gt $paginator.TotalPages 1 }}
|
||||
› <span>Page {{ $paginator.PageNumber }} of {{ $paginator.TotalPages }}</span>
|
||||
{{ end }}
|
||||
</nav>
|
||||
|
||||
{{ .Content }}
|
||||
<h1>
|
||||
All Posts |
|
||||
<a href="/categories/" style="text-decoration: none; color: var(--accent-color)">Categories</a>
|
||||
</h1>
|
||||
{{ range $paginator.Pages }}
|
||||
<h2 class="home-post-title"><a href="{{ .RelPermalink }}">{{ .LinkTitle }}</a></h2>
|
||||
{{ partial "main/dates.html" . }} {{ with .Summary }} {{- /* Create deterministic summary output for
|
||||
styling. See https://github.com/gohugoio/hugo/issues/8910 */ -}}
|
||||
<p class="summary">{{ . | plainify | htmlUnescape | chomp | truncate 150 }}</p>
|
||||
{{- end }} {{ end }}
|
||||
<nav class="paginator">{{- partial "pagination.html" . }} {{/* embedded template */}}</nav>
|
||||
{{ .Content }}
|
||||
<h1>All Posts | <a href="/categories/" style="text-decoration: none; color: var(--accent-color);">Categories</a></h1>
|
||||
{{ range $paginator.Pages }}
|
||||
<h2 class="home-post-title"><a href="{{ .RelPermalink }}">{{ .LinkTitle }}</a></h2>
|
||||
{{ partial "main/dates.html" . }}
|
||||
{{ with .Summary }}
|
||||
{{- /*
|
||||
Create deterministic summary output for styling.
|
||||
See https://github.com/gohugoio/hugo/issues/8910
|
||||
*/ -}}
|
||||
<p class="summary">{{ . | plainify | htmlUnescape | chomp | truncate 150 }}</p>
|
||||
{{- end }}
|
||||
{{ end }}
|
||||
<nav class="paginator">
|
||||
{{- partial "pagination.html" . }} {{/* embedded template */}}
|
||||
</nav>
|
||||
{{ end }}
|
||||
|
||||
@@ -1,49 +1,60 @@
|
||||
{{ define "main" }} {{ $semesterName := .Title }}
|
||||
{{ define "main" }}
|
||||
|
||||
{{ $semesterName := .Title }}
|
||||
|
||||
<nav class="uninotes-breadcrumbs breadcrumbs">
|
||||
<a href="/uninotes/">UniNotes</a>
|
||||
› <span>{{ $semesterName }}</span>
|
||||
<a href="/uninotes/">UniNotes</a>
|
||||
› <span>{{ $semesterName }}</span>
|
||||
</nav>
|
||||
|
||||
<h1>{{ $semesterName }}</h1>
|
||||
|
||||
{{/* Collect unique subject codes from posts in this semester */}} {{ $subjectCodes := slice }} {{
|
||||
range .Pages }} {{ $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 }}
|
||||
{{/* Collect unique subject codes from posts in this semester */}}
|
||||
{{ $subjectCodes := slice }}
|
||||
{{ range .Pages }}
|
||||
{{ $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 }}
|
||||
|
||||
<ol class="uninotes-list uninotes-list--subjects">
|
||||
{{ range $subjectCodes }} {{ $tp := site.GetPage (printf "/subjectcode/%s" (. | urlize)) }}
|
||||
<li class="uninotes-list__item">
|
||||
{{ if $tp }}
|
||||
<a class="uninotes-list__link" href="{{ $tp.RelPermalink }}">{{ . }}</a>
|
||||
{{ else }}
|
||||
<span class="uninotes-list__link">{{ . }}</span>
|
||||
{{ end }}
|
||||
</li>
|
||||
{{ end }}
|
||||
{{ range $subjectCodes }}
|
||||
{{ $tp := site.GetPage (printf "/subjectcode/%s" (. | urlize)) }}
|
||||
<li class="uninotes-list__item">
|
||||
{{ if $tp }}
|
||||
<a class="uninotes-list__link" href="{{ $tp.RelPermalink }}">{{ . }}</a>
|
||||
{{ else }}
|
||||
<span class="uninotes-list__link">{{ . }}</span>
|
||||
{{ end }}
|
||||
</li>
|
||||
{{ end }}
|
||||
</ol>
|
||||
|
||||
{{/* Semester prev/next */}} {{ $allSemesters := site.Taxonomies.semester.Alphabetical }} {{ if gt
|
||||
(len $allSemesters) 1 }} {{ $currentIdx := 0 }} {{ range $i, $s := $allSemesters }} {{ if eq
|
||||
$s.Page.Title $semesterName }}{{ $currentIdx = $i }}{{ end }} {{ end }}
|
||||
<nav class="page-nav">
|
||||
{{ if gt $currentIdx 0 }} {{ $prev := index $allSemesters (sub $currentIdx 1) }}
|
||||
<a class="page-nav__previous-link" href="{{ $prev.Page.RelPermalink }}"
|
||||
>← {{ $prev.Page.Title }}</a
|
||||
>
|
||||
{{ end }} {{ if lt $currentIdx (sub (len $allSemesters) 1) }} {{ $next := index $allSemesters
|
||||
(add $currentIdx 1) }}
|
||||
<a class="page-nav__next-link" href="{{ $next.Page.RelPermalink }}">{{ $next.Page.Title }} →</a>
|
||||
{{ end }}
|
||||
</nav>
|
||||
<script>
|
||||
(function () {
|
||||
if (localStorage.getItem('f4_username') !== 'hyzen') {
|
||||
window.location.replace('/login/?next=' + encodeURIComponent(window.location.pathname));
|
||||
}
|
||||
})();
|
||||
</script>
|
||||
{{/* Semester prev/next */}}
|
||||
{{ $allSemesters := site.Taxonomies.semester.Alphabetical }}
|
||||
{{ if gt (len $allSemesters) 1 }}
|
||||
{{ $currentIdx := 0 }}
|
||||
{{ range $i, $s := $allSemesters }}
|
||||
{{ if eq $s.Page.Title $semesterName }}{{ $currentIdx = $i }}{{ end }}
|
||||
{{ end }}
|
||||
<nav class="page-nav">
|
||||
{{ if gt $currentIdx 0 }}
|
||||
{{ $prev := index $allSemesters (sub $currentIdx 1) }}
|
||||
<a class="page-nav__previous-link" href="{{ $prev.Page.RelPermalink }}">← {{ $prev.Page.Title }}</a>
|
||||
{{ end }}
|
||||
{{ if lt $currentIdx (sub (len $allSemesters) 1) }}
|
||||
{{ $next := index $allSemesters (add $currentIdx 1) }}
|
||||
<a class="page-nav__next-link" href="{{ $next.Page.RelPermalink }}">{{ $next.Page.Title }} →</a>
|
||||
{{ end }}
|
||||
</nav>
|
||||
{{ end }}
|
||||
|
||||
{{ end }} {{ end }}
|
||||
{{ end }}
|
||||
|
||||
@@ -1,17 +1,17 @@
|
||||
{{ define "main" }}
|
||||
|
||||
<nav class="uninotes-breadcrumbs breadcrumbs">
|
||||
<a href="/services/">Services</a>
|
||||
<a href="/services/">Services</a>
|
||||
</nav>
|
||||
|
||||
<h1>Services</h1>
|
||||
|
||||
<ol class="uninotes-list uninotes-list--subjects">
|
||||
{{ range .Pages.ByTitle }}
|
||||
<li class="uninotes-list__item">
|
||||
<a class="uninotes-list__link" href="{{ .RelPermalink }}">{{ .LinkTitle }}</a>
|
||||
</li>
|
||||
{{ end }}
|
||||
{{ range .Pages.ByTitle }}
|
||||
<li class="uninotes-list__item">
|
||||
<a class="uninotes-list__link" href="{{ .RelPermalink }}">{{ .LinkTitle }}</a>
|
||||
</li>
|
||||
{{ end }}
|
||||
</ol>
|
||||
|
||||
{{ end }}
|
||||
|
||||
@@ -1,22 +1,33 @@
|
||||
{{ define "main" }}
|
||||
|
||||
<nav class="uninotes-breadcrumbs breadcrumbs">
|
||||
<a href="/services/">Services</a>
|
||||
› <span>{{ .Title }}</span>
|
||||
<a href="/services/">Services</a>
|
||||
› <span>{{ .Title }}</span>
|
||||
</nav>
|
||||
|
||||
<h1>{{ .Title }}</h1>
|
||||
|
||||
{{ .Content }} {{/* Prev/next among sibling services */}} {{ $allPages :=
|
||||
.CurrentSection.Pages.ByTitle }} {{ $currentTitle := .Title }} {{ $currentIdx := 0 }} {{ range $i,
|
||||
$p := $allPages }} {{ if eq $p.Title $currentTitle }}{{ $currentIdx = $i }}{{ end }} {{ end }} {{ if
|
||||
gt (len $allPages) 1 }}
|
||||
{{ .Content }}
|
||||
|
||||
{{/* Prev/next among sibling services */}}
|
||||
{{ $allPages := .CurrentSection.Pages.ByTitle }}
|
||||
{{ $currentTitle := .Title }}
|
||||
{{ $currentIdx := 0 }}
|
||||
{{ range $i, $p := $allPages }}
|
||||
{{ if eq $p.Title $currentTitle }}{{ $currentIdx = $i }}{{ end }}
|
||||
{{ end }}
|
||||
|
||||
{{ if gt (len $allPages) 1 }}
|
||||
<nav class="page-nav">
|
||||
{{ if gt $currentIdx 0 }} {{ $prev := index $allPages (sub $currentIdx 1) }}
|
||||
<a class="page-nav__previous-link" href="{{ $prev.RelPermalink }}">← {{ $prev.LinkTitle }}</a>
|
||||
{{ end }} {{ if lt $currentIdx (sub (len $allPages) 1) }} {{ $next := index $allPages (add
|
||||
$currentIdx 1) }}
|
||||
<a class="page-nav__next-link" href="{{ $next.RelPermalink }}">{{ $next.LinkTitle }} →</a>
|
||||
{{ end }}
|
||||
{{ if gt $currentIdx 0 }}
|
||||
{{ $prev := index $allPages (sub $currentIdx 1) }}
|
||||
<a class="page-nav__previous-link" href="{{ $prev.RelPermalink }}">← {{ $prev.LinkTitle }}</a>
|
||||
{{ end }}
|
||||
{{ if lt $currentIdx (sub (len $allPages) 1) }}
|
||||
{{ $next := index $allPages (add $currentIdx 1) }}
|
||||
<a class="page-nav__next-link" href="{{ $next.RelPermalink }}">{{ $next.LinkTitle }} →</a>
|
||||
{{ end }}
|
||||
</nav>
|
||||
{{ end }} {{ end }}
|
||||
{{ end }}
|
||||
|
||||
{{ end }}
|
||||
|
||||
@@ -1,65 +1,120 @@
|
||||
{{ define "main" }} {{ $subjectCode := .Title }} {{/* Get semester from first post */}} {{ $semester
|
||||
:= "" }} {{ range .Pages }} {{ if eq $semester "" }} {{ $raw := .Params.semester }} {{ if
|
||||
reflect.IsSlice $raw }} {{ $semester = index $raw 0 }} {{ else }} {{ $semester = $raw }} {{ end }}
|
||||
{{ end }} {{ end }}
|
||||
{{ define "main" }}
|
||||
|
||||
{{ $subjectCode := .Title }}
|
||||
|
||||
{{/* Get semester from first post */}}
|
||||
{{ $semester := "" }}
|
||||
{{ range .Pages }}
|
||||
{{ if eq $semester "" }}
|
||||
{{ $raw := .Params.semester }}
|
||||
{{ if reflect.IsSlice $raw }}
|
||||
{{ $semester = index $raw 0 }}
|
||||
{{ else }}
|
||||
{{ $semester = $raw }}
|
||||
{{ end }}
|
||||
{{ 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
|
||||
}} › <span>{{ $subjectCode }}</span>
|
||||
<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 }}
|
||||
› <span>{{ $subjectCode }}</span>
|
||||
</nav>
|
||||
|
||||
<h1>{{ $subjectCode }}</h1>
|
||||
|
||||
{{/* Collect unique unit labels and sort numerically */}} {{ $seenUnits := slice }} {{ $unitDicts :=
|
||||
slice }} {{ range .Pages }} {{ $unitLabel := (.Params.unit | default .Title) }} {{ if not (in
|
||||
$seenUnits $unitLabel) }} {{ $seenUnits = $seenUnits | append $unitLabel }} {{/* Extract unit number
|
||||
for numeric sort, e.g. "Unit 11" → 11 */}} {{ $uParts := split $unitLabel " " }} {{ $uLast := index
|
||||
$uParts (sub (len $uParts) 1) }} {{ $uNumStr := "" }} {{ range (split $uLast "") }} {{ if ge . "0"
|
||||
}}{{ if le . "9" }}{{ $uNumStr = printf "%s%s" $uNumStr . }}{{ end }}{{ end }} {{ end }} {{ $uNum :=
|
||||
int ($uNumStr | default "0") }} {{ $unitDicts = $unitDicts | append (dict "label" $unitLabel "page"
|
||||
. "num" $uNum) }} {{ end }} {{ end }} {{ $sortedUnitDicts := sort $unitDicts "num" }}
|
||||
{{/* Collect unique unit labels and sort numerically */}}
|
||||
{{ $seenUnits := slice }}
|
||||
{{ $unitDicts := slice }}
|
||||
{{ range .Pages }}
|
||||
{{ $unitLabel := (.Params.unit | default .Title) }}
|
||||
{{ if not (in $seenUnits $unitLabel) }}
|
||||
{{ $seenUnits = $seenUnits | append $unitLabel }}
|
||||
{{/* Extract unit number for numeric sort, e.g. "Unit 11" → 11 */}}
|
||||
{{ $uParts := split $unitLabel " " }}
|
||||
{{ $uLast := index $uParts (sub (len $uParts) 1) }}
|
||||
{{ $uNumStr := "" }}
|
||||
{{ range (split $uLast "") }}
|
||||
{{ if ge . "0" }}{{ if le . "9" }}{{ $uNumStr = printf "%s%s" $uNumStr . }}{{ end }}{{ end }}
|
||||
{{ end }}
|
||||
{{ $uNum := int ($uNumStr | default "0") }}
|
||||
{{ $unitDicts = $unitDicts | append (dict "label" $unitLabel "page" . "num" $uNum) }}
|
||||
{{ end }}
|
||||
{{ end }}
|
||||
{{ $sortedUnitDicts := sort $unitDicts "num" }}
|
||||
|
||||
<ul class="uninotes-list uninotes-list--units">
|
||||
{{ range $sortedUnitDicts }}
|
||||
<li class="uninotes-list__item">
|
||||
<a class="uninotes-list__link" href="{{ .page.Params.uniturl }}"> {{ .label }} </a>
|
||||
</li>
|
||||
{{ end }}
|
||||
{{ range $sortedUnitDicts }}
|
||||
<li class="uninotes-list__item">
|
||||
<a class="uninotes-list__link" href="{{ .page.Params.uniturl }}">
|
||||
{{ .label }}
|
||||
</a>
|
||||
</li>
|
||||
{{ end }}
|
||||
</ul>
|
||||
|
||||
{{/* Subject prev/next — siblings in same semester, sorted numerically by code number */}} {{ if
|
||||
$semester }} {{ $semPage := site.GetPage (printf "/semester/%s" ($semester | urlize)) }} {{ if
|
||||
$semPage }} {{/* Collect unique subject codes */}} {{ $siblingCodes := slice }} {{ range
|
||||
$semPage.Pages }} {{ $raw := .Params.subjectcode }} {{ $code := "" }} {{ if reflect.IsSlice $raw }}
|
||||
{{ $code = index $raw 0 }} {{ else }} {{ $code = $raw }} {{ end }} {{ if and $code (not (in
|
||||
$siblingCodes $code)) }} {{ $siblingCodes = $siblingCodes | append $code }} {{ end }} {{ end }} {{/*
|
||||
Sort subject codes numerically by extracting the number (e.g. "BO DCM1109" → 1109) */}} {{
|
||||
$codeDicts := slice }} {{ range $siblingCodes }} {{ $code := . }} {{ $parts := split $code " " }} {{
|
||||
$lastPart := index $parts (sub (len $parts) 1) }} {{ $numStr := "" }} {{ range (split $lastPart "")
|
||||
}} {{ if ge . "0" }}{{ if le . "9" }}{{ $numStr = printf "%s%s" $numStr . }}{{ end }}{{ end }} {{
|
||||
end }} {{ $num := int ($numStr | default "0") }} {{ $codeDicts = $codeDicts | append (dict "code"
|
||||
$code "num" $num) }} {{ end }} {{ $sortedCodeDicts := sort $codeDicts "num" }} {{ if gt (len
|
||||
$sortedCodeDicts) 1 }} {{ $currentIdx := 0 }} {{ range $i, $d := $sortedCodeDicts }} {{ if eq
|
||||
$d.code $subjectCode }}{{ $currentIdx = $i }}{{ end }} {{ end }}
|
||||
<nav class="page-nav">
|
||||
{{ if gt $currentIdx 0 }} {{ $prevCode := (index $sortedCodeDicts (sub $currentIdx 1)).code }}
|
||||
{{ $prevPage := site.GetPage (printf "/subjectcode/%s" ($prevCode | urlize)) }} {{ if $prevPage
|
||||
}}
|
||||
<a class="page-nav__previous-link" href="{{ $prevPage.RelPermalink }}">← {{ $prevCode }}</a>
|
||||
{{ end }} {{ end }} {{ if lt $currentIdx (sub (len $sortedCodeDicts) 1) }} {{ $nextCode :=
|
||||
(index $sortedCodeDicts (add $currentIdx 1)).code }} {{ $nextPage := site.GetPage (printf
|
||||
"/subjectcode/%s" ($nextCode | urlize)) }} {{ if $nextPage }}
|
||||
<a class="page-nav__next-link" href="{{ $nextPage.RelPermalink }}">{{ $nextCode }} →</a>
|
||||
{{ end }} {{ end }}
|
||||
</nav>
|
||||
<script>
|
||||
(function () {
|
||||
if (localStorage.getItem('f4_username') !== 'hyzen') {
|
||||
window.location.replace('/login/?next=' + encodeURIComponent(window.location.pathname));
|
||||
}
|
||||
})();
|
||||
</script>
|
||||
{{/* Subject prev/next — siblings in same semester, sorted numerically by code number */}}
|
||||
{{ if $semester }}
|
||||
{{ $semPage := site.GetPage (printf "/semester/%s" ($semester | urlize)) }}
|
||||
{{ if $semPage }}
|
||||
{{/* Collect unique subject codes */}}
|
||||
{{ $siblingCodes := slice }}
|
||||
{{ range $semPage.Pages }}
|
||||
{{ $raw := .Params.subjectcode }}
|
||||
{{ $code := "" }}
|
||||
{{ if reflect.IsSlice $raw }}
|
||||
{{ $code = index $raw 0 }}
|
||||
{{ else }}
|
||||
{{ $code = $raw }}
|
||||
{{ end }}
|
||||
{{ if and $code (not (in $siblingCodes $code)) }}
|
||||
{{ $siblingCodes = $siblingCodes | append $code }}
|
||||
{{ end }}
|
||||
{{ end }}
|
||||
|
||||
{{ end }} {{ end }} {{ end }} {{ end }}
|
||||
{{/* Sort subject codes numerically by extracting the number (e.g. "BO DCM1109" → 1109) */}}
|
||||
{{ $codeDicts := slice }}
|
||||
{{ range $siblingCodes }}
|
||||
{{ $code := . }}
|
||||
{{ $parts := split $code " " }}
|
||||
{{ $lastPart := index $parts (sub (len $parts) 1) }}
|
||||
{{ $numStr := "" }}
|
||||
{{ range (split $lastPart "") }}
|
||||
{{ if ge . "0" }}{{ if le . "9" }}{{ $numStr = printf "%s%s" $numStr . }}{{ end }}{{ end }}
|
||||
{{ end }}
|
||||
{{ $num := int ($numStr | default "0") }}
|
||||
{{ $codeDicts = $codeDicts | append (dict "code" $code "num" $num) }}
|
||||
{{ end }}
|
||||
{{ $sortedCodeDicts := sort $codeDicts "num" }}
|
||||
|
||||
{{ if gt (len $sortedCodeDicts) 1 }}
|
||||
{{ $currentIdx := 0 }}
|
||||
{{ range $i, $d := $sortedCodeDicts }}
|
||||
{{ if eq $d.code $subjectCode }}{{ $currentIdx = $i }}{{ end }}
|
||||
{{ end }}
|
||||
<nav class="page-nav">
|
||||
{{ if gt $currentIdx 0 }}
|
||||
{{ $prevCode := (index $sortedCodeDicts (sub $currentIdx 1)).code }}
|
||||
{{ $prevPage := site.GetPage (printf "/subjectcode/%s" ($prevCode | urlize)) }}
|
||||
{{ if $prevPage }}
|
||||
<a class="page-nav__previous-link" href="{{ $prevPage.RelPermalink }}">← {{ $prevCode }}</a>
|
||||
{{ end }}
|
||||
{{ end }}
|
||||
{{ if lt $currentIdx (sub (len $sortedCodeDicts) 1) }}
|
||||
{{ $nextCode := (index $sortedCodeDicts (add $currentIdx 1)).code }}
|
||||
{{ $nextPage := site.GetPage (printf "/subjectcode/%s" ($nextCode | urlize)) }}
|
||||
{{ if $nextPage }}
|
||||
<a class="page-nav__next-link" href="{{ $nextPage.RelPermalink }}">{{ $nextCode }} →</a>
|
||||
{{ end }}
|
||||
{{ end }}
|
||||
</nav>
|
||||
{{ end }}
|
||||
{{ end }}
|
||||
{{ end }}
|
||||
|
||||
{{ end }}
|
||||
|
||||
@@ -1,23 +1,20 @@
|
||||
{{ define "main" }}
|
||||
|
||||
<nav class="uninotes-breadcrumbs breadcrumbs">
|
||||
<a href="/blog/">Blog</a>
|
||||
› <span>Categories</span>
|
||||
<a href="/blog/">Blog</a>
|
||||
› <span>Categories</span>
|
||||
</nav>
|
||||
|
||||
<h1>
|
||||
<a href="/blog/" style="text-decoration: none; color: var(--accent-color)">All Posts</a> |
|
||||
Categories
|
||||
</h1>
|
||||
<h1><a href="/blog/" style="text-decoration: none; color: var(--accent-color);">All Posts</a> | Categories</h1>
|
||||
|
||||
<section class="term-list">
|
||||
{{ range .Data.Terms.Alphabetical }}
|
||||
<h2 class="term-list__item">
|
||||
<a class="term-list__link" href="{{ .Page.RelPermalink }}">
|
||||
{{ .Page.Title }} ({{ .Count }})
|
||||
</a>
|
||||
</h2>
|
||||
{{ end }}
|
||||
{{ range .Data.Terms.Alphabetical }}
|
||||
<h2 class="term-list__item">
|
||||
<a class="term-list__link" href="{{ .Page.RelPermalink }}">
|
||||
{{ .Page.Title }} ({{ .Count }})
|
||||
</a>
|
||||
</h2>
|
||||
{{ end }}
|
||||
</section>
|
||||
|
||||
{{ end }}
|
||||
|
||||
@@ -126,12 +126,4 @@
|
||||
{{ end }}
|
||||
</div>
|
||||
|
||||
<script>
|
||||
(function () {
|
||||
if (localStorage.getItem('f4_username') !== 'hyzen') {
|
||||
window.location.replace('/login/?next=' + encodeURIComponent(window.location.pathname));
|
||||
}
|
||||
})();
|
||||
</script>
|
||||
|
||||
{{ end }}
|
||||
|
||||
@@ -1,60 +1,99 @@
|
||||
{{ 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 }}
|
||||
{{ 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>
|
||||
<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 }}
|
||||
{{ 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 — sorted numerically */}} {{ if $subjectcode }} {{
|
||||
$subPage := site.GetPage (printf "/subjectcode/%s" ($subjectcode | urlize)) }} {{ if $subPage }}
|
||||
{{/* Build deduplicated unit list with numeric sort key */}} {{ $seenUnits := slice }} {{ $unitDicts
|
||||
:= slice }} {{ range $subPage.Pages }} {{ $unitLabel := (.Params.unit | default .Title) }} {{ if not
|
||||
(in $seenUnits $unitLabel) }} {{ $seenUnits = $seenUnits | append $unitLabel }} {{/* Extract unit
|
||||
number for numeric sort, e.g. "Unit 11" → 11 */}} {{ $uParts := split $unitLabel " " }} {{ $uLast :=
|
||||
index $uParts (sub (len $uParts) 1) }} {{ $uNumStr := "" }} {{ range (split $uLast "") }} {{ if ge .
|
||||
"0" }}{{ if le . "9" }}{{ $uNumStr = printf "%s%s" $uNumStr . }}{{ end }}{{ end }} {{ end }} {{
|
||||
$uNum := int ($uNumStr | default "0") }} {{ $unitDicts = $unitDicts | append (dict "label"
|
||||
$unitLabel "page" . "num" $uNum) }} {{ end }} {{ end }} {{ $sortedUnitDicts := sort $unitDicts "num"
|
||||
}} {{ $currentUnit := (.Params.unit | default .Title) }} {{ $currentIdx := 0 }} {{ range $i, $d :=
|
||||
$sortedUnitDicts }} {{ if eq $d.label $currentUnit }}{{ $currentIdx = $i }}{{ end }} {{ end }} {{ if
|
||||
gt (len $sortedUnitDicts) 1 }}
|
||||
<nav class="page-nav">
|
||||
{{ if gt $currentIdx 0 }} {{ $prev := (index $sortedUnitDicts (sub $currentIdx 1)) }}
|
||||
<a class="page-nav__previous-link" href="{{ $prev.page.Params.uniturl }}"
|
||||
>← {{ $prev.label }}</a
|
||||
>
|
||||
{{ end }} {{ if lt $currentIdx (sub (len $sortedUnitDicts) 1) }} {{ $next := (index
|
||||
$sortedUnitDicts (add $currentIdx 1)) }}
|
||||
<a class="page-nav__next-link" href="{{ $next.page.Params.uniturl }}">{{ $next.label }} →</a>
|
||||
{{ end }}
|
||||
</nav>
|
||||
{{ end }} {{ end }} {{ end }} {{ partial "page/page-end.html" . }}
|
||||
<script>
|
||||
(function () {
|
||||
if (localStorage.getItem('f4_username') !== 'hyzen') {
|
||||
window.location.replace('/login/?next=' + encodeURIComponent(window.location.pathname));
|
||||
}
|
||||
})();
|
||||
</script>
|
||||
{{ 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 — sorted numerically */}}
|
||||
{{ if $subjectcode }}
|
||||
{{ $subPage := site.GetPage (printf "/subjectcode/%s" ($subjectcode | urlize)) }}
|
||||
{{ if $subPage }}
|
||||
{{/* Build deduplicated unit list with numeric sort key */}}
|
||||
{{ $seenUnits := slice }}
|
||||
{{ $unitDicts := slice }}
|
||||
{{ range $subPage.Pages }}
|
||||
{{ $unitLabel := (.Params.unit | default .Title) }}
|
||||
{{ if not (in $seenUnits $unitLabel) }}
|
||||
{{ $seenUnits = $seenUnits | append $unitLabel }}
|
||||
{{/* Extract unit number for numeric sort, e.g. "Unit 11" → 11 */}}
|
||||
{{ $uParts := split $unitLabel " " }}
|
||||
{{ $uLast := index $uParts (sub (len $uParts) 1) }}
|
||||
{{ $uNumStr := "" }}
|
||||
{{ range (split $uLast "") }}
|
||||
{{ if ge . "0" }}{{ if le . "9" }}{{ $uNumStr = printf "%s%s" $uNumStr . }}{{ end }}{{ end }}
|
||||
{{ end }}
|
||||
{{ $uNum := int ($uNumStr | default "0") }}
|
||||
{{ $unitDicts = $unitDicts | append (dict "label" $unitLabel "page" . "num" $uNum) }}
|
||||
{{ end }}
|
||||
{{ end }}
|
||||
{{ $sortedUnitDicts := sort $unitDicts "num" }}
|
||||
|
||||
{{ $currentUnit := (.Params.unit | default .Title) }}
|
||||
{{ $currentIdx := 0 }}
|
||||
{{ range $i, $d := $sortedUnitDicts }}
|
||||
{{ if eq $d.label $currentUnit }}{{ $currentIdx = $i }}{{ end }}
|
||||
{{ end }}
|
||||
|
||||
{{ if gt (len $sortedUnitDicts) 1 }}
|
||||
<nav class="page-nav">
|
||||
{{ if gt $currentIdx 0 }}
|
||||
{{ $prev := (index $sortedUnitDicts (sub $currentIdx 1)) }}
|
||||
<a class="page-nav__previous-link" href="{{ $prev.page.Params.uniturl }}">← {{ $prev.label }}</a>
|
||||
{{ end }}
|
||||
{{ if lt $currentIdx (sub (len $sortedUnitDicts) 1) }}
|
||||
{{ $next := (index $sortedUnitDicts (add $currentIdx 1)) }}
|
||||
<a class="page-nav__next-link" href="{{ $next.page.Params.uniturl }}">{{ $next.label }} →</a>
|
||||
{{ end }}
|
||||
</nav>
|
||||
{{ end }}
|
||||
{{ end }}
|
||||
{{ end }}
|
||||
|
||||
{{ partial "page/page-end.html" . }}
|
||||
{{ end }}
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
{{ define "main" }}
|
||||
|
||||
{{/* Get semester and subjectcode from child pages since _index.md doesn't carry taxonomy params */}}
|
||||
{{ $semester := "" }}
|
||||
{{ $subjectcode := "" }}
|
||||
@@ -13,7 +12,6 @@
|
||||
{{ $subjectcode = cond (reflect.IsSlice $raw) (index $raw 0) $raw }}
|
||||
{{ end }}
|
||||
{{ end }}
|
||||
|
||||
<nav class="uninotes-breadcrumbs breadcrumbs">
|
||||
<a href="/uninotes/">UniNotes</a>
|
||||
{{ if $semester }}
|
||||
@@ -30,32 +28,36 @@
|
||||
{{ 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 */}}
|
||||
{{/* Check if self/live pages exist */}}
|
||||
{{ $hasSelf := false }}
|
||||
{{ $hasLive := false }}
|
||||
{{ range .Pages }}
|
||||
{{ if eq (lower .Params.notecategory) "self" }}{{ $hasSelf = true }}{{ end }}
|
||||
{{ if eq (lower .Params.notecategory) "live" }}{{ $hasLive = true }}{{ end }}
|
||||
{{ end }}
|
||||
|
||||
<div class="unit-choice__options">
|
||||
{{ if $hasSelf }}
|
||||
<a class="unit-choice__card unit-choice__card--self" href="{{ .RelPermalink }}self/">
|
||||
{{ else }}
|
||||
<div class="unit-choice__card unit-choice__card--self 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="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>
|
||||
<div class="unit-choice__desc">
|
||||
{{ if $hasSelf }}Self-study notes
|
||||
{{ else }}Not available{{ end }}
|
||||
</div>
|
||||
{{ if $hasSelf }}</a>{{ else }}</div>{{ end }}
|
||||
|
||||
{{ if $hasLive }}
|
||||
<a class="unit-choice__card unit-choice__card--live" href="{{ .RelPermalink }}live/">
|
||||
@@ -74,13 +76,4 @@
|
||||
</div>
|
||||
{{ if $hasLive }}</a>{{ else }}</div>{{ end }}
|
||||
</div>
|
||||
|
||||
<script>
|
||||
(function () {
|
||||
if (localStorage.getItem('f4_username') !== 'hyzen') {
|
||||
window.location.replace('/login/?next=' + encodeURIComponent(window.location.pathname));
|
||||
}
|
||||
})();
|
||||
</script>
|
||||
|
||||
{{ end }}
|
||||
|
||||
Reference in New Issue
Block a user