The MiniFlux Blogroll in Hugo on this site is dynamic, pulling in my RSS feeds from Miniflux. I use this partial below to render a list of public feeds by category.
It’s important to change $allowed_categories
here in the script, and to set miniflux.url
and miniflux.apiKey
in your site config.
{{/*
GetMinifluxFeeds
Get a list of MiniFlux feeds by category
@author @qcasey
@context Page (.)
@access public
@example - Go Template
{{ partialCached "func/GetMinifluxFeeds" . }}
*/}}
{{ $mf_url := .Site.Params.miniflux.url }}
{{ $mf_apiKey := .Site.Params.miniflux.apiKey }}
{{ $allowed_categories := (slice "Digital Gardens and Blogs" "News" "Releases") }}
{{ if (and $mf_url $mf_apiKey) }}
{{ $categories := getJSON (printf "%s/v1/categories" $mf_url) (dict "X-Auth-Token" $mf_apiKey) }}
{{ with $categories }}
{{ $feeds := getJSON (printf "%s/v1/feeds" $mf_url) (dict "X-Auth-Token" $mf_apiKey) }}
{{ if $feeds }}
{{ range $categories }}
{{ if in $allowed_categories .title }}
{{ $c := . }}
<h2 id="{{ $c.title | lower }}">{{ $c.title }}</h2>
<ul class="blogroll">
{{ range $feeds }}
{{ if eq .category.id $c.id }}
<li>
<a href="{{ .site_url }}">
{{ with .icon.feed_id }}
{{ $icon := getJSON (printf "%s/v1/feeds/%.0f/icon" $mf_url .) (dict "X-Auth-Token" $mf_apiKey) }}
{{ with $icon }}
<img width="20" height="20" src="data:{{ .data }}" />
{{ end }}
{{ end }}
{{ .title }}
</a>
</li>
{{ end }}
{{ end }}
</ul>
{{ end }}
{{ end }}
{{ end }}
{{ end }}
{{ end }}