[SOLVED] Having trouble with list of authors array


#1

My config.toml

[params.authors] [params.authors.guy1] name = "Jill Mill" [params.authors.guy2] name = "Joe Schmoe"

        <div class="authors-list">
            {{ range $index := .Site.Params.authors }}

            {{ range $key := $index }}

            <p><a href="{{ $.Site.BaseURL }}authors/{{ $key | urlize }}"><i class="fa fa-tags"></i> {{ $key }}</a></p>

            {{ end }}

            {{ end }}
        </div>

I’m having trouble w/ this Hugo syntax, but I am trying to iterate over .Site.Params.authors, and then iterate over each author and grab only the $value for $key (where $key = name) so that the $value would be the full name, “Jill Bill” or “Joe Schmoe”


#2

And what that ‘index’ do?

{{ index $r 0 }}

for example?

Where is this documented?


#3

{{ range $name, $items := .Site.Params.authors }} {{ range $key, $val := $items }} {{ if eq $key "name" }} <p><a href="{{ $.Site.BaseURL }}authors/{{ $val | urlize | lower }}"><i class="fa fa-tags"></i> {{ $val }}</a> </p> {{ end }} {{ end }} {{ end }}

This works, but I didn’t know I would have to use a conditional. I thought it could filter by like how php is, $array[‘key’] or something.


#4

https://hugodocs.info/functions/index-function/

(Also soliciting feedback on the concept.)


#5

Thank you very much! :slight_smile:

“(Also soliciting feedback on the concept.)” What does this mean? I don’t understand, sorry.


#6

It’s a concept docs site so I’m looking for feedback on areas for improvement…


#7

Oh yeah, I noticed that. Thanks, man! Cool new docs site. More betterer than the older one. I’ll browser and let you know. (If I understand you correctly. English is not my strength)


#8

Nicely done! One thing. When I middle click mouse on a link on the sidebar, it opens the new window w/ the previous windows href, not the link’s anchor.