Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

siteparam: support nested parameters and text formatting #590

Closed
ChristopherBarrington opened this issue Jul 24, 2023 · 1 comment
Closed
Assignees
Labels
feature New feature or request
Milestone

Comments

@ChristopherBarrington
Copy link

The shortcode currently looks for an index in .Site.Params but if the index is a map it cannot return a value from the map. If the user passes name="group.key" it should return the key value from the group map.

The following worked for me:

{{ $context := .context }}
{{ $paramNames := split .name "." }}
{{ with $context }}
	{{ $params := .Site.Params }}
	{{ range $paramName := $paramNames }}
		{{ $params = index $params $paramName }}
	{{ end }}
	{{ markdownify $params }}
{{ end }}

worked for me. Though I had to use markdownify to get the text formatted as I wanted (my params has nested maps with markdown at the end) and the {{<>}} variant of the shortcode. It would be good to see the proper way to do what i surely butchered!

https://github.com/McShelby/hugo-theme-relearn/blob/main/layouts/partials/shortcodes/siteparam.html

@McShelby McShelby self-assigned this Jul 26, 2023
@McShelby McShelby added the feature New feature or request label Jul 26, 2023
@McShelby McShelby added this to the 5.17.2 milestone Jul 26, 2023
@McShelby
Copy link
Owner

Thanks for submission.

Funnily enough I played with the thought to remove this shortcode entirely as I couldn't imagine a use case.

You've convinced me to keep it and make your proposed changes (while changing the implementation slightly).

@McShelby McShelby changed the title siteparam shortcode with nested parameters siteparam: support nested parameters and text formatting Jul 26, 2023
McShelby added a commit that referenced this issue Jul 26, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants