LukeSmithxyz / lugo

Luke's Hugo Theme
184 stars 64 forks source link

improved tagcloud shortcode readability #18

Closed NorthOC closed 1 year ago

NorthOC commented 1 year ago

The tagcloud shortcode is hard to modify. I broke it down for easier readability.

From this:

{{ if isset .Site.Taxonomies "tags" }}{{ if not (eq (len .Site.Taxonomies.tags) 0) }}   <ul id="tagcloud">
    {{ range $name, $items := .Site.Taxonomies.tags }}{{ $url := printf "%s/%s" "tags" ($name | urlize | lower)}}<li><a href="{{ $url | absURL }}" id="tag_{{ $name }}">{{ $name | title }}</a></li>
    {{ end }}</ul>{{ end }}{{ end }}

To this:

{{ if isset .Site.Taxonomies "tags" }}
    {{ if not (eq (len .Site.Taxonomies.tags) 0) }}
        <ul id="tagcloud">
        {{ range $name, $items := .Site.Taxonomies.tags }}
            {{ $url := printf "%s/%s" "tags" ($name | urlize | lower)}}
            <li>
                <a href="{{ $url | absURL }}" id="tag_{{ $name }}">{{ $name | title }}</a>
            </li>
        {{ end }}
        </ul>
    {{ end }}
{{ end }}