I’m trying to pass a tag name into a shortcode and render n
items. I haven’t found a way to list content under a certain tag when that tag is passed into a shortcode.
For example, this is the way you would do this in a template where you know the tag you’re trying to list:
{{ range first 5 .Site.Taxonomies.tags.alabama }}
{{ .Page.Title }}
{{ end }}
But what if you’re passing the tag name into a shortcode?
What if the tag name contains spaces?
In my Markdown:
{{< content-by-tag tag="alabama" number="5" >}}
Shortcode:
{{ range first (.Get "number") .Site.Taxonomy.tags[ .Get "tag" ] }} <= Is there any way?
{{ .Render "teaser" }}
{{ end }}