Skip to content

Commit

Permalink
Use .Page.GetPage in examples of an include shortcode
Browse files Browse the repository at this point in the history
  • Loading branch information
jmooring authored Dec 17, 2024
1 parent 9e1c85b commit 2f1843d
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 4 deletions.
10 changes: 8 additions & 2 deletions content/en/methods/page/RenderShortcodes.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 >}}

Expand Down
10 changes: 8 additions & 2 deletions content/en/render-hooks/_common/pageinner.md
Original file line number Diff line number Diff line change
Expand Up @@ -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) }}
{{ .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 >}}

Expand Down

0 comments on commit 2f1843d

Please sign in to comment.