diff --git a/exampleSite/config/_default/config.toml b/exampleSite/config/_default/config.toml index efaa673f131..c4e6833ad09 100644 --- a/exampleSite/config/_default/config.toml +++ b/exampleSite/config/_default/config.toml @@ -231,3 +231,5 @@ title = "Hugo Relearn Documentation" # security reasons mermaidInitialize = "{ \"securityLevel\": \"loose\" }" mermaidZoom = true + [params.siteparam.test] + text = "A **nested** parameter with formatting" diff --git a/exampleSite/content/basics/migration/_index.en.md b/exampleSite/content/basics/migration/_index.en.md index 5c5dfcaa8ae..c4969923ffe 100644 --- a/exampleSite/content/basics/migration/_index.en.md +++ b/exampleSite/content/basics/migration/_index.en.md @@ -32,6 +32,8 @@ This document shows you what's new in the latest release. For a detailed list of In addition it offers some extensions. Currently only the `wrap` extension option is provided to control whether a code block should be wrapped or scrolled if to long to fit. +- {{% badge style="info" icon="plus-circle" title=" " %}}New{{% /badge %}} The [`siteparam` shortcode]({{% relref "shortcodes/siteparam" %}}) is now capable to display nested params aswell as adding support for text formatting. + --- ## 5.16.0 (2023-06-10) diff --git a/exampleSite/content/shortcodes/siteparam.en.md b/exampleSite/content/shortcodes/siteparam.en.md index 7fa2a3c2fe4..fc0e2d52f55 100644 --- a/exampleSite/content/shortcodes/siteparam.en.md +++ b/exampleSite/content/shortcodes/siteparam.en.md @@ -1,6 +1,6 @@ +++ description = "Get value of site params" -title = "Site Param" +title = "SiteParam" +++ The `siteparam` shortcode prints values of site params. @@ -52,3 +52,26 @@ While the examples are using shortcodes with named parameter you are free to use ``` `editURL` value: {{% siteparam name="editURL" %}} + +### Nested parameter with Markdown and HTML formatting + +To use formatted parameter, add this in your `config.toml`: + +````toml +[markup.goldmark.renderer] + unsafe = true +```` + +{{% tab title="config.toml" %}} +````toml +[params] + [params.siteparam.test] + text = "A **nested** parameter with formatting" +```` +{{% /tab %}} + +```go +Formatted parameter: {{%/* siteparam name="siteparam.test.text" */%}} +``` + +Formatted parameter: {{% siteparam name="siteparam.test.text" %}} diff --git a/exampleSite/content/shortcodes/siteparam.pir.md b/exampleSite/content/shortcodes/siteparam.pir.md index f6b3da9860e..29e32ece46e 100644 --- a/exampleSite/content/shortcodes/siteparam.pir.md +++ b/exampleSite/content/shortcodes/siteparam.pir.md @@ -1,5 +1,5 @@ +++ descrption = "Get value o' ship parrrams varrriables 'n yer plank" -title = "Ship Param" +title = "SiteParam" +++ {{< piratify >}} \ No newline at end of file diff --git a/layouts/partials/shortcodes/siteparam.html b/layouts/partials/shortcodes/siteparam.html index edfa288ed8e..fb78381b3a5 100644 --- a/layouts/partials/shortcodes/siteparam.html +++ b/layouts/partials/shortcodes/siteparam.html @@ -1,10 +1,11 @@ {{- $context := .context }} -{{- $paramName := .name }} +{{- $paramNames := split .name "." }} {{- with $context }} -{{- $siteParams := .Site.Params }} -{{- with $paramName }} - {{- with $siteParams }} - {{- index . (lower $paramName) }} +{{- $params := .Site.Params }} +{{- range $paramName := $paramNames }} + {{- with $params }} + {{- $params = index . (lower $paramName) }} {{- end }} {{- end }} +{{- $params | .RenderString }} {{- end }} \ No newline at end of file