This commit is contained in:
Bjørn Erik Pedersen 2025-01-06 18:11:07 +01:00
commit 0fc86783ee
No known key found for this signature in database
33 changed files with 608 additions and 443 deletions

View file

@ -9,9 +9,9 @@ action:
signatures: [MENUENTRY.Name]
---
If you define the menu entry [automatically], the `Name` method returns the pages [`LinkTitle`], falling back to its [`Title`].
If you define the menu entry [automatically], the `Name` method returns the page's [`LinkTitle`], falling back to its [`Title`].
If you define the menu entry [in front matter] or [in site configuration], the `Name` method returns the `name` property, falling back to the pages `LinkTitle`, then to its `Title`.
If you define the menu entry [in front matter] or [in site configuration], the `Name` method returns the `name` property of the given menu entry. If the `name` is not defined, and the menu entry resolves to a page, the `Name` returns the page [`LinkTitle`], falling back to its [`Title`].
[`LinkTitle`]: /methods/page/linktitle/
[`Title`]: /methods/page/title/

View file

@ -9,20 +9,14 @@ action:
signatures: [MENUENTRY.Title]
---
If you define the menu entry [automatically], the `Title` method returns the pages [`LinkTitle`], falling back to its [`Title`].
The `Title` method returns the `title` property of the given menu entry. If the `title` is not defined, and the menu entry resolves to a page, the `Title` returns the page [`Title`].
If you define the menu entry [in front matter] or [in site configuration], the `Title` method returns the `title` property, falling back to the pages `LinkTitle`, then to its `Title`.
[`LinkTitle`]: /methods/page/linktitle/
[`Title`]: /methods/page/title/
[automatically]: /content-management/menus/#define-automatically
[in front matter]: /content-management/menus/#define-in-front-matter
[in site configuration]: /content-management/menus/#define-in-site-configuration
```go-html-template
<ul>
{{ range .Site.Menus.main }}
<li><a href="{{ .URL }}">{{ .Title }}</a></li>
<li><a href="{{ .URL }}" title="{{ .Title }}>{{ .Name }}</a></li>
{{ end }}
</ul>
```

View file

@ -28,14 +28,15 @@ Use the `Fragments` method on a `Page` object to create a table of contents with
## Methods
Headings
: (`map`) A nested map of all headings on the page. Each map contains the following keys: `ID`, `Level`, `Title` and `Headings`. To inspect the data structure:
: (`slice`) A slice of maps of all headings on the page, with first-level keys for each heading. Each map contains the following keys: `ID`, `Level`, `Title` and `Headings`. To inspect the data structure:
```go-html-template
<pre>{{ debug.Dump .Fragments.Headings }}</pre>
```
HeadingsMap
: (`slice`) A slice of maps of all headings on the page, with first-level keys for each heading. Each map contains the following keys: `ID`, `Level`, `Title` and `Headings`. To inspect the data structure:
: (`map`) A nested map of all headings on the page. Each map contains the following keys: `ID`, `Level`, `Title` and `Headings`. To inspect the data structure:
```go-html-template
<pre>{{ debug.Dump .Fragments.HeadingsMap }}</pre>

View file

@ -24,8 +24,14 @@ Use this method in shortcode templates to compose a page from multiple content f
For example:
{{< code file=layouts/shortcodes/include.html >}}
{{ with site.GetPage (.Get 0) }}
{{ .RenderShortcodes }}
{{ with .Get 0 }}
{{ with $.Page.GetPage . }}
{{- .RenderShortcodes }}
{{ else }}
{{ errorf "The %q shortcode was unable to find %q. See %s" $.Name . $.Position }}
{{ end }}
{{ else }}
{{ errorf "The %q shortcode requires a positional parameter indicating the logical path of the file to include. See %s" .Name .Position }}
{{ end }}
{{< /code >}}

View file

@ -69,6 +69,20 @@ When working with global resources instead of page resources, use the [`resource
When working with global resources instead of page resources, use the [`resources.Match`] function.
###### Mount
{{< new-in "0.140.0" >}}
(`ResourceGetter`) Mounts the given resources from the two arguments base (`string`) to the given target path (`string`) and returns an object that implements [Get](#get). Note that leading slashes in target marks an absolute path. Relative target paths allows you to mount resources relative to another set, e.g. a [Page bundle](/content-management/page-bundles/):
```go-html-template
{{ $common := resources.Match "/js/headlessui/*.*" }}
{{ $importContext := (slice $.Page ($common.Mount "/js/headlessui" ".")) }}
```
This method is currently only useful in [js.Batch](/functions/js/batch/#import-context).
## Pattern matching
With the `GetMatch` and `Match` methods, Hugo determines a match using a case-insensitive [glob pattern].

View file

@ -6,7 +6,7 @@ keywords: []
action:
related:
- functions/images/Filter
returnType: resources.resourceAdapter
returnType: images.ImageResource
signatures: [RESOURCE.Filter FILTER...]
toc: true
---