Skip to content

Commit

Permalink
children: use LinkTitle instead of Title #939
Browse files Browse the repository at this point in the history
  • Loading branch information
McShelby committed Oct 24, 2024
1 parent 41a1e95 commit 8da8ed8
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 9 deletions.
6 changes: 6 additions & 0 deletions exampleSite/content/introduction/releasenotes/7/1.en.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
2 changes: 1 addition & 1 deletion exampleSite/content/shortcodes/children/_index.en.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.<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

Expand Down
4 changes: 1 addition & 3 deletions layouts/partials/_relearn/pages.gotmpl
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}
Expand Down
8 changes: 4 additions & 4 deletions layouts/partials/shortcodes/children.html
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,12 @@
{{- if hasPrefix $.style "h" }}
{{- $num := sub ( int (trim $.style "h") ) 1 }}
{{- $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" }}
{{ (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 }}
{{ (printf " <%s>" $.style)|safeHTML }}{{ if .RelPermalink }}<a href="{{ partial "permalink.gotmpl" (dict "to" .) }}">{{ .Title }}</a>{{ else }}<span>{{ .Title }}</span>{{ end }}{{ (printf "</%s>" $.style)|safeHTML }}
{{- end }}
{{ (printf " <%s>" $.style)|safeHTML }}{{ if .RelPermalink }}<a href="{{ partial "permalink.gotmpl" (dict "to" .) }}">{{ .LinkTitle }}</a>{{ else }}<span>{{ .LinkTitle }}</span>{{ end }}{{ (printf "</%s>" $.style)|safeHTML }}
.LinkTitle{{- end }}
{{- if $.description }}
{{- with or .Description .Summary -}}
<p>{{ . }}</p>
Expand Down
2 changes: 1 addition & 1 deletion layouts/partials/version.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
7.0.1+10fb679d67466ad0b5f5563c6892220a7a95eb21
7.0.1+41a1e95d1eb3169d1238a078b0f2f0cf2f6246d6

0 comments on commit 8da8ed8

Please sign in to comment.