getcontent.html (659B)
1 <!-- {{/* 2 Insert `.Content` from a (headless) bundle. You can insert `.Content` from multiple page resources of the same bundle by specifying `glob`. 3 4 Usage: {{< getcontent path="PATH/TO/FILE" >}} 5 {{< getcontent path="PATH/TO/BUNDLE/" glob="*_PATTERN.md" >}} 6 */}} --> 7 {{- $path := .Get "path" -}} 8 {{ $glob := .Get "glob" -}} 9 10 {{ $resources := slice -}} 11 {{ with $glob -}} 12 {{ $bundle := site.GetPage $path -}} 13 {{ $resources = $bundle.Resources.Match $glob -}} 14 {{ else -}} 15 {{ $bundle := site.GetPage (path.Dir $path) -}} 16 {{ $resources = $bundle.Resources.Match (path.Base $path) -}} 17 {{ end -}} 18 19 {{ range $resources -}} 20 {{ .Content }} 21 {{ end -}}