children: use LinkTitle instead of Title #939

This commit is contained in:
Sören Weber 2024-10-25 00:10:32 +02:00
parent 41a1e95d1e
commit 8da8ed8614
No known key found for this signature in database
GPG key ID: BEC6D55545451B6D
5 changed files with 13 additions and 9 deletions

View file

@ -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. 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 ### 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. - {{% 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.

View file

@ -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. | | **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/). | | **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`. | | **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.<br><br>- `auto` defaults to `ordersectionsby` of the page's {{% badge style="green" icon="fa-fw fab fa-markdown" title=" " %}}Front Matter{{% /badge %}}<br>&nbsp;&nbsp;&nbsp;&nbsp;or to `ordersectionsby` of the configuration {{% badge style="cyan" icon="gears" title=" " %}}Option{{% /badge %}}<br>&nbsp;&nbsp;&nbsp;&nbsp;or to `weight`<br>- `weight`<br>- `title`<br>- `linktitle`<br>- `modifieddate`<br>- `expirydate`<br>- `publishdate`<br>- `date`<br>- `length`<br>- `default` adhering to Hugo's default sort criteria| | **sort** | `auto` | The sort criteria of the displayed list.<br><br>- `auto` defaults to `ordersectionsby` of the page's {{% badge style="green" icon="fa-fw fab fa-markdown" title=" " %}}Front Matter{{% /badge %}}<br>&nbsp;&nbsp;&nbsp;&nbsp;or to `ordersectionsby` of the configuration {{% badge style="cyan" icon="gears" title=" " %}}Option{{% /badge %}}<br>&nbsp;&nbsp;&nbsp;&nbsp;or to `weight`<br>- `weight`<br>- `title`<br>- `modifieddate`<br>- `expirydate`<br>- `publishdate`<br>- `date`<br>- `length`<br>- `default` adhering to Hugo's default sort criteria|
## Examples ## Examples

View file

@ -10,9 +10,7 @@
{{- if eq $by "weight" }} {{- if eq $by "weight" }}
{{- $pages = $page.Pages.ByWeight }} {{- $pages = $page.Pages.ByWeight }}
{{- else if or (eq $by "name") (eq $by "title") }} {{- else if or (eq $by "name") (eq $by "title") (eq $by "linktitle") }}
{{- $pages = $page.Pages.ByTitle }}
{{- else if eq $by "linktitle" }}
{{- $pages = $page.Pages.ByLinkTitle }} {{- $pages = $page.Pages.ByLinkTitle }}
{{- else if eq $by "modifieddate" }} {{- else if eq $by "modifieddate" }}
{{- $pages = $page.Pages.Lastmod }} {{- $pages = $page.Pages.Lastmod }}

View file

@ -35,12 +35,12 @@
{{- if hasPrefix $.style "h" }} {{- if hasPrefix $.style "h" }}
{{- $num := sub ( int (trim $.style "h") ) 1 }} {{- $num := sub ( int (trim $.style "h") ) 1 }}
{{- $numn := add $num $.count }} {{- $numn := add $num $.count }}
{{ (printf " <h%d>" $numn)|safeHTML }}{{ if .RelPermalink }}<a href="{{ partial "permalink.gotmpl" (dict "to" .) }}">{{ .Title }}</a>{{ else }}<span>{{ .Title }}</span>{{ end }}{{ (printf "</h%d>" $numn)|safeHTML }} {{ (printf " <h%d>" $numn)|safeHTML }}{{ if .RelPermalink }}<a href="{{ partial "permalink.gotmpl" (dict "to" .) }}">{{ .LinkTitle }}</a>{{ else }}<span>{{ .LinkTitle }}</span>{{ end }}{{ (printf "</h%d>" $numn)|safeHTML }}
{{- else if eq $.style "li" }} {{- else if eq $.style "li" }}
{{ (printf " <%s>" $.style)|safeHTML }}{{ if .RelPermalink }}<a href="{{ partial "permalink.gotmpl" (dict "to" .) }}">{{ .Title }}</a>{{ else }}<span>{{ .Title }}</span>{{ end }} {{ (printf " <%s>" $.style)|safeHTML }}{{ if .RelPermalink }}<a href="{{ partial "permalink.gotmpl" (dict "to" .) }}">{{ .LinkTitle }}</a>{{ else }}<span>{{ .LinkTitle }}</span>{{ end }}
{{- else }} {{- else }}
{{ (printf " <%s>" $.style)|safeHTML }}{{ if .RelPermalink }}<a href="{{ partial "permalink.gotmpl" (dict "to" .) }}">{{ .Title }}</a>{{ else }}<span>{{ .Title }}</span>{{ end }}{{ (printf "</%s>" $.style)|safeHTML }} {{ (printf " <%s>" $.style)|safeHTML }}{{ if .RelPermalink }}<a href="{{ partial "permalink.gotmpl" (dict "to" .) }}">{{ .LinkTitle }}</a>{{ else }}<span>{{ .LinkTitle }}</span>{{ end }}{{ (printf "</%s>" $.style)|safeHTML }}
{{- end }} .LinkTitle{{- end }}
{{- if $.description }} {{- if $.description }}
{{- with or .Description .Summary -}} {{- with or .Description .Summary -}}
<p>{{ . }}</p> <p>{{ . }}</p>

View file

@ -1 +1 @@
7.0.1+10fb679d67466ad0b5f5563c6892220a7a95eb21 7.0.1+41a1e95d1eb3169d1238a078b0f2f0cf2f6246d6