mirror of
https://github.com/gohugoio/hugo.git
synced 2026-08-25 07:48:52 +00:00
d61a580103
This is an improvement over the `readfiles` shortcode in that it allows to insert content files that contain shortcodes themselves. This new shortcode is used to fix a regression introduced in https://github.com/gohugoio/hugoDocs/pull/1442 (`new-in` shortcode was not rendered as intended).
22 lines
747 B
HTML
22 lines
747 B
HTML
<!-- {{/*
|
|
Insert page `.Content` from a (headless) bundle; you can insert `.Content` from multiple page resources of the same bundle by specifying `glob`
|
|
|
|
Usage: {{< insertpages path="PATH/TO/MD_FILE" >}}
|
|
{{< insertpages path="PATH/TO/BUNDLE" glob="*_PATTERN.md" >}}
|
|
*/}} -->
|
|
{{ $path := .Get "path" -}}
|
|
{{ $glob := .Get "glob" -}}
|
|
|
|
{{ $scratch := newScratch -}}
|
|
{{ with $glob -}}
|
|
{{ $bundle := site.GetPage (path.Join $path "index.md") -}}
|
|
{{ $scratch.Set "pages" ($bundle.Resources.Match $glob) -}}
|
|
{{ else -}}
|
|
{{ $bundle := site.GetPage (path.Join (path.Dir $path) "index.md") -}}
|
|
{{ $scratch.Set "pages" ($bundle.Resources.Match (path.Base $path)) -}}
|
|
{{ end -}}
|
|
|
|
{{ range ($scratch.Get "pages") -}}
|
|
{{ .Content }}
|
|
{{ end -}}
|