Rename and refactor shortcode

This commit is contained in:
Salim B
2021-05-01 19:34:04 +02:00
committed by Bjørn Erik Pedersen
parent e9953751ec
commit 4230f8fa54
3 changed files with 6 additions and 6 deletions
+1 -1
View File
@@ -204,7 +204,7 @@ aliased form `.Pages`.
### `.Pages` compared to `.Site.Pages`
{{< insertpages path="readfiles/pages-vs-site-pages.md" >}}
{{< getcontent path="readfiles/pages-vs-site-pages.md" >}}
## Page-level Params
+1 -1
View File
@@ -127,7 +127,7 @@ You can use `.Site.Params` in a [partial template](/templates/partials/) to call
### `.Site.Pages` compared to `.Pages`
{{< insertpages path="readfiles/pages-vs-site-pages.md" >}}
{{< getcontent path="readfiles/pages-vs-site-pages.md" >}}
@@ -1,18 +1,18 @@
<!-- {{/*
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" >}}
Usage: {{< insertpages path="PATH/TO/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") -}}
{{ $bundle := site.GetPage $path -}}
{{ $scratch.Set "pages" ($bundle.Resources.Match $glob) -}}
{{ else -}}
{{ $bundle := site.GetPage (path.Join (path.Dir $path) "index.md") -}}
{{ $bundle := site.GetPage (path.Dir $path) -}}
{{ $scratch.Set "pages" ($bundle.Resources.Match (path.Base $path)) -}}
{{ end -}}