From 8da8ed8614e684d8de620de64d9d8fd8dc268dd2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=B6ren=20Weber?= Date: Fri, 25 Oct 2024 00:10:32 +0200 Subject: [PATCH] children: use LinkTitle instead of Title #939 --- exampleSite/content/introduction/releasenotes/7/1.en.md | 6 ++++++ exampleSite/content/shortcodes/children/_index.en.md | 2 +- layouts/partials/_relearn/pages.gotmpl | 4 +--- layouts/partials/shortcodes/children.html | 8 ++++---- layouts/partials/version.txt | 2 +- 5 files changed, 13 insertions(+), 9 deletions(-) diff --git a/exampleSite/content/introduction/releasenotes/7/1.en.md b/exampleSite/content/introduction/releasenotes/7/1.en.md index 3e54ac4e20..ce631aef7e 100644 --- a/exampleSite/content/introduction/releasenotes/7/1.en.md +++ b/exampleSite/content/introduction/releasenotes/7/1.en.md @@ -24,6 +24,12 @@ weight = -1 You don't need to change anything in your existing installation as the old configuration is used as a default. +- {{% badge style="note" title=" " %}}Change{{% /badge %}} The [`children` shortcode](shortcodes/children) was changed to output a page's _LinkTitle_ instead of previously using the _Title_. + + As the shortcode always outputs subpages in context of the parent page, it functions similar to the sidebar menu. The sidebar menu itself uses the _LinkTitle_ for naming the menu entries and so should the shortcode do. + + The parameter value `sort=linktitle` was deprecated for the easier `sort=title`. You can still use the old value but both behave the same way in sorting by _LinkTitle_. + ### New - {{% badge style="info" icon="plus-circle" title=" " %}}New{{% /badge %}} Menus created by your page structure are now able to [contain arbitrary links](configuration/sidebar/menus#displaying-arbitrary-links-in-a-page-menu) inserted into the structure using the `menuUrl` or `menuPageRef` front matter. diff --git a/exampleSite/content/shortcodes/children/_index.en.md b/exampleSite/content/shortcodes/children/_index.en.md index bc96f1dcc6..443e1c7fef 100644 --- a/exampleSite/content/shortcodes/children/_index.en.md +++ b/exampleSite/content/shortcodes/children/_index.en.md @@ -42,7 +42,7 @@ The `children` shortcode lists the child pages of the current page and its desce | **showhidden** | `false` | When `true`, child pages hidden from the menu will be displayed as well. | | **description** | `false` | When `true` shows a short text under each page in the list. When no description or summary exists for the page, the first 70 words of the content is taken - [read more info about summaries on gohugo.io](https://gohugo.io/content/summaries/). | | **depth** | `1` | The depth of descendants to display. For example, if the value is `2`, the shortcode will display two levels of child pages. To get all descendants, set this value to a high number eg. `999`. | -| **sort** | `auto` | The sort criteria of the displayed list.

- `auto` defaults to `ordersectionsby` of the page's {{% badge style="green" icon="fa-fw fab fa-markdown" title=" " %}}Front Matter{{% /badge %}}
    or to `ordersectionsby` of the configuration {{% badge style="cyan" icon="gears" title=" " %}}Option{{% /badge %}}
    or to `weight`
- `weight`
- `title`
- `linktitle`
- `modifieddate`
- `expirydate`
- `publishdate`
- `date`
- `length`
- `default` adhering to Hugo's default sort criteria| +| **sort** | `auto` | The sort criteria of the displayed list.

- `auto` defaults to `ordersectionsby` of the page's {{% badge style="green" icon="fa-fw fab fa-markdown" title=" " %}}Front Matter{{% /badge %}}
    or to `ordersectionsby` of the configuration {{% badge style="cyan" icon="gears" title=" " %}}Option{{% /badge %}}
    or to `weight`
- `weight`
- `title`
- `modifieddate`
- `expirydate`
- `publishdate`
- `date`
- `length`
- `default` adhering to Hugo's default sort criteria| ## Examples diff --git a/layouts/partials/_relearn/pages.gotmpl b/layouts/partials/_relearn/pages.gotmpl index fb50069baa..f364678678 100644 --- a/layouts/partials/_relearn/pages.gotmpl +++ b/layouts/partials/_relearn/pages.gotmpl @@ -10,9 +10,7 @@ {{- if eq $by "weight" }} {{- $pages = $page.Pages.ByWeight }} -{{- else if or (eq $by "name") (eq $by "title") }} - {{- $pages = $page.Pages.ByTitle }} -{{- else if eq $by "linktitle" }} +{{- else if or (eq $by "name") (eq $by "title") (eq $by "linktitle") }} {{- $pages = $page.Pages.ByLinkTitle }} {{- else if eq $by "modifieddate" }} {{- $pages = $page.Pages.Lastmod }} diff --git a/layouts/partials/shortcodes/children.html b/layouts/partials/shortcodes/children.html index 279616ac60..ac11f5c112 100644 --- a/layouts/partials/shortcodes/children.html +++ b/layouts/partials/shortcodes/children.html @@ -35,12 +35,12 @@ {{- if hasPrefix $.style "h" }} {{- $num := sub ( int (trim $.style "h") ) 1 }} {{- $numn := add $num $.count }} -{{ (printf " " $numn)|safeHTML }}{{ if .RelPermalink }}{{ .Title }}{{ else }}{{ .Title }}{{ end }}{{ (printf "" $numn)|safeHTML }} +{{ (printf " " $numn)|safeHTML }}{{ if .RelPermalink }}{{ .LinkTitle }}{{ else }}{{ .LinkTitle }}{{ end }}{{ (printf "" $numn)|safeHTML }} {{- else if eq $.style "li" }} -{{ (printf " <%s>" $.style)|safeHTML }}{{ if .RelPermalink }}{{ .Title }}{{ else }}{{ .Title }}{{ end }} +{{ (printf " <%s>" $.style)|safeHTML }}{{ if .RelPermalink }}{{ .LinkTitle }}{{ else }}{{ .LinkTitle }}{{ end }} {{- else }} -{{ (printf " <%s>" $.style)|safeHTML }}{{ if .RelPermalink }}{{ .Title }}{{ else }}{{ .Title }}{{ end }}{{ (printf "" $.style)|safeHTML }} - {{- end }} +{{ (printf " <%s>" $.style)|safeHTML }}{{ if .RelPermalink }}{{ .LinkTitle }}{{ else }}{{ .LinkTitle }}{{ end }}{{ (printf "" $.style)|safeHTML }} +.LinkTitle{{- end }} {{- if $.description }} {{- with or .Description .Summary -}}

{{ . }}

diff --git a/layouts/partials/version.txt b/layouts/partials/version.txt index 736ea62c81..56785c8305 100644 --- a/layouts/partials/version.txt +++ b/layouts/partials/version.txt @@ -1 +1 @@ -7.0.1+10fb679d67466ad0b5f5563c6892220a7a95eb21 \ No newline at end of file +7.0.1+41a1e95d1eb3169d1238a078b0f2f0cf2f6246d6 \ No newline at end of file