aboutsummaryrefslogtreecommitdiff
path: root/layouts/notes/list.html
blob: 2bd8c67a37cb9a48ffaf8971480ad81d67ba6404 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
{{ define "main" }}
  {{- $isNotesRoot := .Parent.IsHome -}}
  <article lang="{{ default "en" .Params.lang }}">
    <header class="document-header">
      <h1>{{ .Title }}</h1>
      {{ partial "document-view.html" . }}
    </header>
    {{ .Content }}
    {{- if $isNotesRoot }}
      <p><a href="{{ "notes/rss.xml" | relURL }}">Subscribe to notes updates</a></p>
      {{- with .RegularPages.ByTitle }}
        <section aria-labelledby="standalone-title">
          <h2 id="standalone-title">STANDALONE NOTES</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 .Sections.ByWeight }}
        <section aria-labelledby="series-title">
          <h2 id="series-title">SERIES</h2>
          <ul class="document-list">
            {{- range . }}
              <li><a href="{{ .RelPermalink }}" lang="{{ .Params.lang }}">{{ .LinkTitle }}</a>{{ with .Params.description }} — {{ . }}{{ end }}</li>
            {{- end }}
          </ul>
        </section>
      {{- end }}
    {{- else }}
      {{/*
        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>
                <span class="chapter-number">{{ printf "%02d" (add $index 1) }}</span>
                <a href="{{ $page.RelPermalink }}" lang="{{ $page.Params.lang }}">{{ $page.LinkTitle }}</a>
                <span class="list-updated">updated {{ time.Format "2006-01-02" $page.Params.updated }}</span>
              </li>
            {{- end }}
          </ol>
        </section>
      {{- end }}
      {{- with .Sections.ByWeight }}
        <section aria-labelledby="subseries-title">
          <h2 id="subseries-title">SUBSERIES</h2>
          <ul class="document-list">
            {{- range . }}
              <li><a href="{{ .RelPermalink }}" lang="{{ .Params.lang }}">{{ .LinkTitle }}/</a>{{ with .Params.description }} — {{ . }}{{ end }}</li>
            {{- end }}
          </ul>
        </section>
      {{- end }}
    {{- end }}
  </article>
{{ end }}