From 5f41b65ecbf5000181e19ee6a1097eee9d3db5d3 Mon Sep 17 00:00:00 2001 From: Tekki Date: Fri, 10 Mar 2023 18:42:49 +0100 Subject: [PATCH 1/4] Correct series entries in example site. Resolves #430. Signed-off-by: Tekki --- exampleSite/content/post/bundle/index.md | 3 +-- exampleSite/content/post/markdown-syntax.md | 2 +- exampleSite/content/post/markdown-syntax.pt.md | 2 +- 3 files changed, 3 insertions(+), 4 deletions(-) diff --git a/exampleSite/content/post/bundle/index.md b/exampleSite/content/post/bundle/index.md index 6b1ab1ad..04cc4981 100644 --- a/exampleSite/content/post/bundle/index.md +++ b/exampleSite/content/post/bundle/index.md @@ -18,8 +18,7 @@ categories: - syntax tags: - Hugo -series: - - Themes Guide +series: Themes Guide --- [Page bundles](https://gohugo.io/content-management/page-bundles/) are an optional way to [organize page resources](https://gohugo.io/content-management/page-resources/) within Hugo. diff --git a/exampleSite/content/post/markdown-syntax.md b/exampleSite/content/post/markdown-syntax.md index c9b80628..30e9e0be 100644 --- a/exampleSite/content/post/markdown-syntax.md +++ b/exampleSite/content/post/markdown-syntax.md @@ -15,7 +15,7 @@ categories = [ "themes", "syntax", ] -series = ["Themes Guide"] +series = "Themes Guide" aliases = ["migrate-from-jekyl"] thumbnail = "images/building.png" +++ diff --git a/exampleSite/content/post/markdown-syntax.pt.md b/exampleSite/content/post/markdown-syntax.pt.md index 695235a1..0cce0e8f 100644 --- a/exampleSite/content/post/markdown-syntax.pt.md +++ b/exampleSite/content/post/markdown-syntax.pt.md @@ -15,7 +15,7 @@ categories = [ "temas", "sintaxe", ] -series = ["Guia de Temas"] +series = "Guia de Temas" aliases = ["migrar-de-jekyl"] thumbnail = "images/building.png" +++ From f74f442051e2f9141b146a8ff3583909c5062f91 Mon Sep 17 00:00:00 2001 From: Tekki Date: Sat, 11 Mar 2023 06:30:46 +0100 Subject: [PATCH 2/4] Improve code for list of related posts. Signed-off-by: Tekki --- exampleSite/config/_default/params.toml | 3 ++- exampleSite/content/post/bundle/index.md | 3 +++ layouts/_default/single.html | 8 ++++---- layouts/partials/related.html | 12 +++++------- layouts/partials/sidebar.html | 14 ++++++++------ 5 files changed, 22 insertions(+), 18 deletions(-) diff --git a/exampleSite/config/_default/params.toml b/exampleSite/config/_default/params.toml index 87043757..0dfc15db 100644 --- a/exampleSite/config/_default/params.toml +++ b/exampleSite/config/_default/params.toml @@ -128,7 +128,8 @@ languageMenuName = "🌐" # notice of the footer. # since = 2016 -# Show related content at the end of an article based on the 'series' taxonomy. Can be set in post front matter. +# Show related content at the end of an article or in the sidebar, based on the 'series' taxonomy. +# Both parameters can be overridden in the post's front matter. # showRelatedInArticle = false # showRelatedInSidebar = false diff --git a/exampleSite/content/post/bundle/index.md b/exampleSite/content/post/bundle/index.md index 04cc4981..84c9e496 100644 --- a/exampleSite/content/post/bundle/index.md +++ b/exampleSite/content/post/bundle/index.md @@ -19,6 +19,9 @@ categories: tags: - Hugo series: Themes Guide +# the following overrides the settings from params.toml: +showRelatedInArticle: true +showRelatedInSidebar: true --- [Page bundles](https://gohugo.io/content-management/page-bundles/) are an optional way to [organize page resources](https://gohugo.io/content-management/page-resources/) within Hugo. diff --git a/layouts/_default/single.html b/layouts/_default/single.html index e0299b29..22c42670 100644 --- a/layouts/_default/single.html +++ b/layouts/_default/single.html @@ -29,13 +29,13 @@

{{ T "overview" }}

{{- .Content }} - {{- $showRelatedInArticle := true }} - {{- if eq $s.showRelatedInArticle false }} - {{- $showRelatedInArticle = false }} + {{- $showRelatedInArticle := $s.showRelatedInArticle }} + {{- if eq $p.showRelatedInArticle true }} + {{- $showRelatedInArticle = true }} {{- else if eq $p.showRelatedInArticle false }} {{- $showRelatedInArticle = false }} {{- end }} - {{- if ne $showRelatedInArticle false }} + {{- if (and ($showRelatedInArticle) (isset $p "series")) }} {{- partial "related" . }} {{- end }} diff --git a/layouts/partials/related.html b/layouts/partials/related.html index 757bcb54..26243c29 100644 --- a/layouts/partials/related.html +++ b/layouts/partials/related.html @@ -1,9 +1,7 @@ -{{ if isset .Params "series" }} {{$related := where .Site.RegularPages ".Params.series" "eq" .Params.series }} -

Posts in this Series

- +

{{ T "series_posts" }}

+ diff --git a/layouts/partials/sidebar.html b/layouts/partials/sidebar.html index 17b18b24..07627f4e 100644 --- a/layouts/partials/sidebar.html +++ b/layouts/partials/sidebar.html @@ -40,13 +40,15 @@

Disclaimer

{{ end }} - {{- $relatedInSidebar := true }} - {{- if eq $s.showRelatedInSidebar false }} - {{ $relatedInSidebar = false }} + {{- $showRelatedInSidebar := $s.showRelatedInSidebar }} + {{- if eq .Params.showRelatedInSidebar true }} + {{- $showRelatedInSidebar = true }} + {{- else if eq .Params.showRelatedInSidebar false }} + {{- $showRelatedInSidebar = false }} {{- end }} - {{ if (and ($relatedInSidebar) (isset .Params "series") ) }} + {{- if (and ($showRelatedInSidebar) (isset .Params "series")) }} {{$related := where .Site.RegularPages ".Params.series" "eq" .Params.series }} -

{{ T "series_posts" }}

+

{{ T "series_posts" }}

    {{ range $related }}
  • @@ -54,7 +56,7 @@

    {{ T "series_posts" }}

  • {{ end }}
- {{ end }} + {{- end }} {{- $posts := where .Site.RegularPages "Type" "in" $s.mainSections }} {{- $featured := default 8 $s.numberOfFeaturedPosts }} From 9cf95f3fe756658d0fca3b39fd6cbb23c3521e10 Mon Sep 17 00:00:00 2001 From: Tekki Date: Sat, 11 Mar 2023 07:53:15 +0100 Subject: [PATCH 3/4] Sort posts in series by date ascending. Signed-off-by: Tekki --- layouts/partials/related.html | 2 +- layouts/partials/sidebar.html | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/layouts/partials/related.html b/layouts/partials/related.html index 26243c29..41057a0b 100644 --- a/layouts/partials/related.html +++ b/layouts/partials/related.html @@ -1,7 +1,7 @@ {{$related := where .Site.RegularPages ".Params.series" "eq" .Params.series }}

{{ T "series_posts" }}

    -{{ range $related }} +{{ range sort $related "Date" }}
  • {{ .Title }}
  • {{ end }}
diff --git a/layouts/partials/sidebar.html b/layouts/partials/sidebar.html index 07627f4e..eb757802 100644 --- a/layouts/partials/sidebar.html +++ b/layouts/partials/sidebar.html @@ -50,7 +50,7 @@

Disclaimer

{{$related := where .Site.RegularPages ".Params.series" "eq" .Params.series }}

{{ T "series_posts" }}

    - {{ range $related }} + {{ range sort $related "Date" }}
  • {{ .Title | markdownify }}
  • From 12fba47a2dd773a710850b2141f925f97f8d7381 Mon Sep 17 00:00:00 2001 From: Tekki Date: Tue, 24 Sep 2024 07:53:07 +0200 Subject: [PATCH 4/4] Correct related.html. Signed-off-by: Tekki --- layouts/partials/related.html | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/layouts/partials/related.html b/layouts/partials/related.html index 26487ea9..b847bcdb 100644 --- a/layouts/partials/related.html +++ b/layouts/partials/related.html @@ -1,9 +1,9 @@ +{{ if isset .Params "series" }} {{$related := where .Site.RegularPages ".Params.series" "eq" .Params.series }} -

    {{ T "series_posts" }}

    -
      - {{ range sort $related "Date" }} -
    • {{ .Title }}
    • - {{ end }} -
    +

    {{ T "series_posts" }}

    +
      + {{ range sort $related "Date" }} +
    • {{ .Title }}
    • + {{ end }} +
    {{ end }} -