From 2f1843d10a5986be1a6310b5c60d1ca8b306bb45 Mon Sep 17 00:00:00 2001 From: Joe Mooring Date: Tue, 17 Dec 2024 12:04:41 -0800 Subject: [PATCH] Use .Page.GetPage in examples of an include shortcode --- content/en/methods/page/RenderShortcodes.md | 10 ++++++++-- content/en/render-hooks/_common/pageinner.md | 10 ++++++++-- 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/content/en/methods/page/RenderShortcodes.md b/content/en/methods/page/RenderShortcodes.md index e95e0683e6..48d8071f07 100644 --- a/content/en/methods/page/RenderShortcodes.md +++ b/content/en/methods/page/RenderShortcodes.md @@ -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 >}} diff --git a/content/en/render-hooks/_common/pageinner.md b/content/en/render-hooks/_common/pageinner.md index 1d467aeefe..3388bd9493 100644 --- a/content/en/render-hooks/_common/pageinner.md +++ b/content/en/render-hooks/_common/pageinner.md @@ -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 >}}