mirror of
https://github.com/McShelby/hugo-theme-relearn.git
synced 2025-01-18 19:00:24 +00:00
siteparam: support nested parameters and text formatting #590
This commit is contained in:
parent
80c1b4e04e
commit
e9d3eb6489
5 changed files with 35 additions and 7 deletions
|
@ -231,3 +231,5 @@ title = "Hugo Relearn Documentation"
|
|||
# security reasons
|
||||
mermaidInitialize = "{ \"securityLevel\": \"loose\" }"
|
||||
mermaidZoom = true
|
||||
[params.siteparam.test]
|
||||
text = "A **nested** parameter <b>with</b> formatting"
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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 <b>with</b> formatting"
|
||||
````
|
||||
{{% /tab %}}
|
||||
|
||||
```go
|
||||
Formatted parameter: {{%/* siteparam name="siteparam.test.text" */%}}
|
||||
```
|
||||
|
||||
Formatted parameter: {{% siteparam name="siteparam.test.text" %}}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
+++
|
||||
descrption = "Get value o' ship parrrams varrriables 'n yer plank"
|
||||
title = "Ship Param"
|
||||
title = "SiteParam"
|
||||
+++
|
||||
{{< piratify >}}
|
|
@ -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 }}
|
Loading…
Reference in a new issue