diff options
| author | Richard Qin <richard.qin.x@gmail.com> | 2026-09-14 01:56:42 +0800 |
|---|---|---|
| committer | Richard Qin <richard.qin.x@gmail.com> | 2026-09-14 01:56:42 +0800 |
| commit | 879ec47668c2b2e995818cbc88c3ce248d5df62a (patch) | |
| tree | d7b129e8863b07702eb5ccb78b81b63dfe4e8fc5 /layouts/notes/list.html | |
| parent | 1405c44501260b553776cbb2e28a450547139bc5 (diff) | |
| download | rhomepage-879ec47668c2b2e995818cbc88c3ce248d5df62a.tar.gz rhomepage-879ec47668c2b2e995818cbc88c3ce248d5df62a.tar.xz | |
Support loose notes and nested series
Diffstat (limited to 'layouts/notes/list.html')
| -rw-r--r-- | layouts/notes/list.html | 46 |
1 files changed, 36 insertions, 10 deletions
diff --git a/layouts/notes/list.html b/layouts/notes/list.html index e45a039..a8411e1 100644 --- a/layouts/notes/list.html +++ b/layouts/notes/list.html @@ -28,9 +28,38 @@ </section> {{- end }} {{- else }} - {{- with .RegularPages.ByWeight }} - <section aria-labelledby="series-articles-title"> - <h2 id="series-articles-title">ARTICLES</h2> + {{/* + A section is a container by default. A direct page becomes an + ordered chapter only when it declares `series`; all other direct + pages remain ordinary, unnumbered articles. Child sections are + listed as subseries and are rendered by this same template, so the + hierarchy can be nested to any depth. + */}} + {{- $articles := slice -}} + {{- $chapters := slice -}} + {{- range .RegularPages.ByTitle }} + {{- if not .Params.series }} + {{- $articles = $articles | append . -}} + {{- end }} + {{- end }} + {{- range .RegularPages.ByWeight }} + {{- if .Params.series }} + {{- $chapters = $chapters | append . -}} + {{- end }} + {{- end }} + {{- with $articles }} + <section aria-labelledby="articles-title"> + <h2 id="articles-title">ARTICLES</h2> + <ul class="document-list"> + {{- range . }} + <li><time datetime="{{ time.Format "2006-01-02" .Params.updated }}">{{ time.Format "2006-01-02" .Params.updated }}</time> <a href="{{ .RelPermalink }}" lang="{{ .Params.lang }}">{{ .LinkTitle }}</a></li> + {{- end }} + </ul> + </section> + {{- end }} + {{- with $chapters }} + <section aria-labelledby="chapters-title"> + <h2 id="chapters-title">CHAPTERS</h2> <ol class="document-list series-chapter-list"> {{- range $index, $page := . }} <li> @@ -45,14 +74,11 @@ {{- with .Sections.ByWeight }} <section aria-labelledby="subseries-title"> <h2 id="subseries-title">SUBSERIES</h2> - <ol class="document-list series-chapter-list"> - {{- range $index, $series := . }} - <li> - <span class="chapter-number">{{ printf "%02d" (add $index 1) }}</span> - <a href="{{ $series.RelPermalink }}" lang="{{ $series.Params.lang }}">{{ $series.LinkTitle }}/</a>{{ with $series.Params.description }} — {{ . }}{{ end }} - </li> + <ul class="document-list"> + {{- range . }} + <li><a href="{{ .RelPermalink }}" lang="{{ .Params.lang }}">{{ .LinkTitle }}/</a>{{ with .Params.description }} — {{ . }}{{ end }}</li> {{- end }} - </ol> + </ul> </section> {{- end }} {{- end }} |
