mirror of
https://github.com/gohugoio/hugo.git
synced 2025-08-16 20:53:59 +02:00
Merge commit 'e9fbadacc3f09191e2e19f112a49777eeb8df06c'
This commit is contained in:
@@ -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>
|
||||
|
@@ -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 >}}
|
||||
|
||||
|
@@ -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].
|
||||
|
Reference in New Issue
Block a user