Use .Page.GetPage in examples of an include shortcode

This commit is contained in:
Joe Mooring 2024-12-17 12:04:41 -08:00 committed by GitHub
parent 9e1c85bbdd
commit 2f1843d10a
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 16 additions and 4 deletions

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) }}
{{ 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

@ -9,8 +9,14 @@ _comment: Do not remove front matter.
The primary use case for `PageInner` is to resolve links and [page resources] relative to an included `Page`. For example, create an "include" shortcode to compose a page from multiple content files, while preserving a global context for footnotes and the table of contents:
{{< code file=layouts/shortcodes/include.html >}}
{{ with site.GetPage (.Get 0) }}
{{ 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 >}}