From 000d2655efb7839a6b626fae82bf310bd4b4ab74 Mon Sep 17 00:00:00 2001 From: Ngô Ngọc Đức Huy Date: Mon, 31 Jul 2023 08:43:42 +0700 Subject: Add book section recursion --- layouts/_default/list.html | 38 +++----------------------------------- layouts/partials/feed.html | 13 +++++++++++++ layouts/partials/generic-list.html | 12 ++++++++++++ layouts/partials/toc.html | 15 +++++++++++++++ 4 files changed, 43 insertions(+), 35 deletions(-) create mode 100644 layouts/partials/feed.html create mode 100644 layouts/partials/generic-list.html create mode 100644 layouts/partials/toc.html (limited to 'layouts') 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 }} {{ if in .Params.categories "book" }} - {{ $chapters := .Page.Pages }} - {{ range .Page.Translations }} - {{ $chapters = $chapters | lang.Merge .Pages }} - {{ end}}
-
    - {{ range sort $chapters "Weight" }} -
  1. - {{ trim .Title " " }} - {{ partial "post-info.html" . }} -
  2. - {{ end }} -
      + {{ partial "toc.html" . }}
{{ else if in .Params.categories "blog" }} -
-
    - {{ range sort .Pages "Date" "desc" }} -
  1. - : - {{ trim .Title " " }} - {{ partial "post-language-switcher.html" . }} - {{ partial "post-info.html" . }} -
  2. - {{ end }} -
      -
+ {{ partial "feed.html" . }} {{ else }} -
-
+ {{ 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 @@ +
+
    + {{ range sort .Pages "Date" "desc" }} +
  1. + : + {{ trim .Title " " }} + {{ partial "post-language-switcher.html" . }} + {{ partial "post-info.html" . }} +
  2. + {{ end }} +
      +
+ 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 @@ +
+
+ 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}} +
    + {{ range sort $chapters "Weight" }} +
  1. + {{ trim .Title " " }} + {{ partial "post-info.html" . }} + {{ if .IsSection}} + {{ partial "toc.html" . }} + {{ end }} +
  2. + {{ end }} +
-- cgit 1.4.1