diff options
-rw-r--r-- | layouts/_default/list.html | 38 | ||||
-rw-r--r-- | layouts/partials/feed.html | 13 | ||||
-rw-r--r-- | layouts/partials/generic-list.html | 12 | ||||
-rw-r--r-- | layouts/partials/toc.html | 15 |
4 files changed, 43 insertions, 35 deletions
diff --git a/layouts/_default/list.html b/layouts/_default/list.html index bdcd630..46310ad 100644 --- a/layouts/_default/list.html +++ b/layouts/_default/list.html @@ -9,44 +9,12 @@ SPDX-License-Identifier: MIT {{ .Content }} </section> {{ if in .Params.categories "book" }} - {{ $chapters := .Page.Pages }} - {{ range .Page.Translations }} - {{ $chapters = $chapters | lang.Merge .Pages }} - {{ end}} <section class="toc"> - <ol> - {{ range sort $chapters "Weight" }} - <li> - <a href="{{ .RelPermalink }}">{{ trim .Title " " }}</a> - {{ partial "post-info.html" . }} - </li> - {{ end }} - <ol> + {{ partial "toc.html" . }} </section> {{ else if in .Params.categories "blog" }} - <section class="feed"> - <ol reversed> - {{ range sort .Pages "Date" "desc" }} - <li> - <time datetime="{{ .Date }}">{{ .Date.Format "2006-01-02" }}</time>: - <a href="{{ .RelPermalink }}">{{ trim .Title " " }}</a> - {{ partial "post-language-switcher.html" . }} - {{ partial "post-info.html" . }} - </li> - {{ end }} - <ol> - </section> + {{ partial "feed.html" . }} {{ else }} - <section class="list"> - <ul> - {{ range sort .Pages "Date" }} - <li> - <a href="{{ .RelPermalink }}">{{ trim .Title " " }}</a> - {{ partial "post-language-switcher.html" . }} - {{ partial "post-info.html" . }} - </li> - {{ end }} - <ul> - </section> + {{ partial "generic-list.html" . }} {{ end }} {{ end }} diff --git a/layouts/partials/feed.html b/layouts/partials/feed.html new file mode 100644 index 0000000..42c7564 --- /dev/null +++ b/layouts/partials/feed.html @@ -0,0 +1,13 @@ +<section class="feed"> + <ol reversed> + {{ range sort .Pages "Date" "desc" }} + <li> + <time datetime="{{ .Date }}">{{ .Date.Format "2006-01-02" }}</time>: + <a href="{{ .RelPermalink }}">{{ trim .Title " " }}</a> + {{ partial "post-language-switcher.html" . }} + {{ partial "post-info.html" . }} + </li> + {{ end }} + <ol> +</section> + diff --git a/layouts/partials/generic-list.html b/layouts/partials/generic-list.html new file mode 100644 index 0000000..e8397c4 --- /dev/null +++ b/layouts/partials/generic-list.html @@ -0,0 +1,12 @@ + <section class="list"> + <ul> + {{ range sort .Pages "Date" }} + <li> + <a href="{{ .RelPermalink }}">{{ trim .Title " " }}</a> + {{ partial "post-language-switcher.html" . }} + {{ partial "post-info.html" . }} + </li> + {{ end }} + <ul> + </section> + diff --git a/layouts/partials/toc.html b/layouts/partials/toc.html new file mode 100644 index 0000000..f6af753 --- /dev/null +++ b/layouts/partials/toc.html @@ -0,0 +1,15 @@ +{{ $chapters := .Page.Pages }} +{{ range .Page.Translations }} +{{ $chapters = $chapters | lang.Merge .Pages }} +{{ end}} +<ol> + {{ range sort $chapters "Weight" }} + <li> + <a href="{{ .RelPermalink }}">{{ trim .Title " " }}</a> + {{ partial "post-info.html" . }} + {{ if .IsSection}} + {{ partial "toc.html" . }} + {{ end }} + </li> + {{ end }} +</ol> |