summaryrefslogtreecommitdiffstats
path: root/docs/layouts/shortcodes
diff options
context:
space:
mode:
authorBjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>2021-06-08 18:47:53 +0200
committerBjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>2021-06-08 18:47:53 +0200
commit162f41d0efdd4a5e12e489cf8ecf8490b45884da (patch)
treea7e2337c45a581e150d35b3be97afb52b1e4de27 /docs/layouts/shortcodes
parent552cef5c576ae4dbf4626f77f3c8b15b42a9e7f3 (diff)
parent32ba623541d74ee0b7ae4efb1b8326dc49af28b8 (diff)
Diffstat (limited to 'docs/layouts/shortcodes')
-rw-r--r--docs/layouts/shortcodes/getcontent.html21
1 files changed, 21 insertions, 0 deletions
diff --git a/docs/layouts/shortcodes/getcontent.html b/docs/layouts/shortcodes/getcontent.html
new file mode 100644
index 000000000..6ae35dd6d
--- /dev/null
+++ b/docs/layouts/shortcodes/getcontent.html
@@ -0,0 +1,21 @@
+<!-- {{/*
+Insert `.Content` from a (headless) bundle. You can insert `.Content` from multiple page resources of the same bundle by specifying `glob`.
+
+Usage: {{< getcontent path="PATH/TO/FILE" >}}
+ {{< getcontent path="PATH/TO/BUNDLE/" glob="*_PATTERN.md" >}}
+*/}} -->
+{{- $path := .Get "path" -}}
+{{ $glob := .Get "glob" -}}
+
+{{ $resources := slice -}}
+{{ with $glob -}}
+ {{ $bundle := site.GetPage $path -}}
+ {{ $resources = $bundle.Resources.Match $glob -}}
+{{ else -}}
+ {{ $bundle := site.GetPage (path.Dir $path) -}}
+ {{ $resources = $bundle.Resources.Match (path.Base $path) -}}
+{{ end -}}
+
+{{ range $resources -}}
+ {{ .Content }}
+{{ end -}}