I have converted an OPML file to JSON in data/blogroll.json
that I want to parse. I created a layout layouts/blogroll.html
that parses the file, but I keep getting errors:
Error: Error building site: failed to render pages: render of "page" failed: "/Users/REDACTED/Code/REDACTED/themes/smpl/layouts/_default/blogroll.html:12:20": execute of template failed: template: _default/blogroll.html:12:20: executing "_default/blogroll.html" at <index $item "_htmlUrl">: error calling index: cannot index slice/array with type string
This is my setup, can someone tell me how to get a working template?
blogroll.html
...
<ul>
{{ $blogroll := $.Site.Data.blogroll.body }}
{{ $groups := $blogroll.outline }}
{{ range $groups }}
<li>
{{ ._text }}
<ul>
{{ $items := .outline }}
{{ range $items }}
{{ $item := . }}
<li>
<a href="{{ index $item "_htmlUrl" }}">
{{ index $item "_text" }}
</a>
</li>
{{ end }}
</ul>
</li>
{{ end }}
</ul>
...
blogroll.json
{
"head": {
"title": "REDACTED subscriptions in feedly Cloud"
},
"body": {
"outline": [
{
"outline": [
{
"_type": "rss",
"_text": "Henrique Dias",
"_title": "Henrique Dias",
"_xmlUrl": "https://hacdias.com/all/feed.xml",
"_htmlUrl": "https://hacdias.com/all/"
},
{
"_type": "rss",
"_text": "Horst Gutmann: zerokspot.com",
"_title": "Horst Gutmann: zerokspot.com",
"_xmlUrl": "https://zerokspot.com/index.xml",
"_htmlUrl": "https://zerokspot.com/"
}
],
"_text": "People",
"_title": "People"
},
{
"outline": [
{
"_type": "rss",
"_text": "Bits of Freedom",
"_title": "Bits of Freedom",
"_xmlUrl": "https://www.bitsoffreedom.nl/feed/",
"_htmlUrl": "https://www.bitsoffreedom.nl"
},
{
"_type": "rss",
"_text": "Cryptomator Blog",
"_title": "Cryptomator Blog",
"_xmlUrl": "https://cryptomator.org/feed.xml",
"_htmlUrl": "https://cryptomator.org/"
}
],
"_text": "Privacy",
"_title": "Privacy"
}
]
},
"_version": "1.0"
}