blogroll links generated in hugo

This commit is contained in:
Wouter Groeneveld 2022-01-20 21:21:49 +01:00
parent 05980eeb3f
commit 4df6d0f6df
13 changed files with 658 additions and 3 deletions

1
.gitignore vendored
View File

@ -9,6 +9,7 @@ resources/
node_modules/
docs/
*.lock
*.class
.certificates

View File

@ -58,6 +58,12 @@ enableGitInfo = true
disable = false
privacyEnhanced = true
# added since Hugo 0.9x to allow babel to be executed
[security]
enableInlineShortcodes = false
[security.exec]
allow = ['^dart-sass-embedded$', '^go$', '^npx$', '^postcss$', 'babel']
[[menu.main]]
name = "Brain Baking"
pre = "<svg width='24' height='24'><use xlink:href='#book'></use></svg> "
@ -80,8 +86,15 @@ enableGitInfo = true
name = "About"
pre = "<svg width='24' height='24'><use xlink:href='#about'></use></svg> "
url = "/about"
weight = 4
[[menu.mainright]]
name = "Links"
pre = "<svg width='24' height='24'><use xlink:href='#link'></use></svg> "
url = "/links"
weight = 5
[outputs]
home = ["HTML", "RSS"]
page = ["HTML"]

15
content/links.md Normal file
View File

@ -0,0 +1,15 @@
---
title: Fellow Brain Bakers
---
_Brain Baking_ never happens in isolation. This page contains a list of curious websites and fellow bloggers that deserve a shout-out. It is a nostalgic throwback to the nineties _<svg class='icon'><use xlink:href='#link'></use></svg>links_ pages, like my recently excavated [2007 browser bookmarks](/museum/fav.html).
Enjoy the serendipitous discoveries by clicking through!
## Blogroll
This is an automatically updated and maintained blogroll by my RSS reader. Those who'd rather download the `.opml` file, [here you go](https://raw.githubusercontent.com/wgroeneveld/brainbaking/master/data/blogroll.xml).
Visit [blogroll.org](https://blogroll.org/) for a superior humanly curated list of "fine personal & independent blogs". It's a great way to get to know new people and sites.
{{< blogroll >}}

View File

@ -0,0 +1,74 @@
---
title: Generating a Blogroll With OPML in Hugo
date: 2022-01-20T20:16:00+01:00
categories:
- webdesign
tags:
- hugo
---
Blogrolls have been on my mind lately. It's a rather fancy word for a more common but far from mundane corner of your website, called a _links_ section. Ever since [my first website in 1998](/museum/1998/)---you can marvel at my old junk at the [Brain Baking Museum](/museum)---I've had a links section. But for some reason, on the latest revision of this site, it's been gone for years.
A links page is fun for a couple of reasons:
- It shows what the website owner is interested in;
- It's a chance to give a shout-out to fellow _websiters_ (if I'd type _blogger_ here, I'd be too limiting);
- It can be used to play the im-bored-lets-click-through-stuff game (isn't that the purpose of those webrings?).
Especially since I've been encountering my own site in the midst of the links of others (thank you!), I felt a bit bad for not returning the favor. Enter the [/links page](/links)!
After getting nostalgic (again...), I rummaged through my digital archive to dig up [my 2007 browser bookmarks](/museum/fav.html). It's a lot of fun to scroll through and instantly gives an impression of what I was up to back then (Infinity engine game modding, Nintendo DS programming, Wizardry 8 guide writing, retro gaming, BSD and Linux kernel programming, Magic the Gathering, hip-hop).
So much yet so little has changed! It's a bit embarrassing. Or should I be proud? I'm not sure. I feel a bit conflicted when looking back at it. Like Brit Butler wrote in "[Deliberate Action](https://blog.kingcons.io/posts/Deliberate-Action.html)":
> A tremendous amount has happened, but I feel like I've lost the boy I remember from college a little. He was excited about things: video games, music, common lisp, poetry.
Anyway. As Ruben would write: _I digress_.
## Hugo and XML parsing
Since nowadays I manage my digital intake via my RSS reader, which already contains an XML-based list of links in an `.opml` file, I took a stab at automating this process.
Recently, Hugo implemented [XML Data support](https://github.com/gohugoio/hugo/commit/0eaaa8fee37068bfc8ecfb760f770ecc9a7af22a) (part of the `0.92.0` release). This means chucking an XML file in `/data` automatically exposes it in the template engine, making iterating over entries using `{{ range $.Site.Data.blogroll.body.outline }}` trivial. Or so I thought.
The supplied example in the commit message of the patch is very brief and only covers retrieving contents of XML tags: `<title>sup</title>` can be accessed via the not-so-special `{{ .title }}` shortcode, as it becomes a Go property. But OPML outline XML is something like this:
```xml
<outline text="Brain Baking" title="Brain Baking" description="" type="rss" version="RSS" htmlUrl="https://brainbaking.com/" xmlUrl="http://brainbaking.com/index.xml"/>
```
All attributes, no content: the `outline` tag is auto-closed (`/>`). I had no clue how to fetch that data, as dumping the entire variable printed a map of keys prepended with a dash. Why? It seems that someone else submitted an issue to the hugoDocs repository, so I took the effort to summarize changes into a pull request. Accessing properties, apparently, is done via `{{ index $body.outline "-title" }}`.
I've never used Hugo's [index function](https://gohugo.io/functions/index-function/) before. Having to prepend attribute names with `-` feels awkward. I presume the changes are still young and a bit untested. Hopefully it'll evolve and stabilize over time. The problem right now is a total lack of documentation. Hopefully this blog post helps alleviate the problem a bit.
## NetNewsWire OPML exports
Where does the OPML file come from? NetNewsWire keeps track of local subscriptions ("On My Mac") in a file somewhere (`/Users/me/Library/Containers/com.ranchero.NetNewsWire-Evergreen/Data/Library/Application\ Support/NetNewsWire/Accounts/OnMyMac/Subscriptions.opml`). Copying over suffices, but of course does not auto-update when I add more feeds in the reader. Other options I've considered:
- Softlinks. Nothing but trouble while committing into git, tried a lot of different approaches;
- Hardlinks. Borked in MacOS. As soon as NetNewsWire makes a change, the hardlink is severed;
- Third party hardlink cmd-based solutions. Didn't work;
- Write a script that parses it into JSON and add to the CI. Too complicated;
- Add a stupid copy command into the user's crontab.
The last option is currently in use, although not ideal. Oh well.
Another problem is the lack of metadata, or description information. The [/links](/links) page contains little information of the link itself that way, especially if the blogger's `<title/>` tag is a bit... woozy. Like, "Articles", for instance. Any RSS feed, such as mine, contains a (proper) title and description:
```xml
<channel>
<title>Brain Baking</title>
<link>http://localhost:1313/</link>
<description>Freshly Baked Thoughts by Wouter Groeneveld </description>
...
</channel>
```
It somehow doesn't get saved into the OPML, although there's a description tag---it's [hardcoded to the empty string](https://github.com/Ranchero-Software/NetNewsWire/issues/3406). Why? I'd love to hack away in the Swift code but could use some help.
## Bonus material
Hey, this site also supports dark mode from now on! It seems to be a thing and after discovering MacOS Montery's "Auto" Appearance switch setting, I couldn't resist. Enjoy!
![](../darkmode.gif "Switching from light to dark mode in MacOS.")

View File

@ -19,7 +19,7 @@ It takes a lot of courage to do so---to write, not about the things you're good
But my public writing does not come close to Winnie's blog. I simply don't have the guts to do so. These things, for now, stay in my analog journal.
> I don't with to wait till death is imminent for me to realize that I should have loved deeper, traveled further, written more.
> I don't want to wait till death is imminent for me to realize that I should have loved deeper, traveled further, written more.
Why do these quotes grab me by the throat? Is it because they're deeply infused with philosophy, which I'm also fascinated by? Is it because her thinking patterns align with mine? Is it out of respect for opening up, admitting to the sensitivity?

View File

@ -0,0 +1,9 @@
---
title: "Archive by year: 2022"
type: archive
icontag: tag
url: /post/2022/
disableComments: true
---
{{< archive 2022 >}}

View File

@ -40,7 +40,8 @@ I also write about retro PC/Handheld gaming and actual _bread baking_ on sister
### By year
- [2021](/post/2021) ... when I got that shiny new M1 MacBook Air
- [2022](/post/2022) ... when working from home was still a thing
- [2021](/post/2021) ... when I got back into both retro (80486) and modern (M1) hardware
- [2020](/post/2020) ... when I paid attention to webdesign and wrote a book about baking
- [2019](/post/2019) ... when computing education articles started appearing
- [2018](/post/2018) ... when my PhD work started and I tried writing essays in Dutch

62
data/blogroll.xml Normal file
View File

@ -0,0 +1,62 @@
<?xml version="1.0" encoding="UTF-8"?>
<!-- OPML generated by NetNewsWire -->
<opml version="1.1">
<head>
<title>On My Mac</title>
</head>
<body>
<outline text="Code" title="Code">
<outline text="articles on Jamie Tanna | Software Engineer" title="articles on Jamie Tanna | Software Engineer" description="" type="rss" version="RSS" htmlUrl="https://www.jvt.me/kind/articles/" xmlUrl="https://www.jvt.me/kind/articles/feed.xml"/>
<outline text="Coder's Block" title="Coder's Block" description="" type="rss" version="RSS" htmlUrl="https://codersblock.com/" xmlUrl="https://codersblock.com/rss.xml"/>
<outline text="fabiensanglard.net" title="fabiensanglard.net" description="" type="rss" version="RSS" htmlUrl="https://fabiensanglard.net/" xmlUrl="https://fabiensanglard.net/rss.xml"/>
<outline text="Jessitron" title="Jessitron" description="" type="rss" version="RSS" htmlUrl="https://jessitron.com/" xmlUrl="https://jessitron.com/feed/"/>
<outline text="Josh Comeau's blog" title="Josh Comeau's blog" description="" type="rss" version="RSS" htmlUrl="https://www.joshwcomeau.com/" xmlUrl="https://www.joshwcomeau.com/rss.xml"/>
<outline text="Oh Hello Ana" title="Oh Hello Ana" description="" type="rss" version="RSS" htmlUrl="" xmlUrl="https://ohhelloana.blog/feed.xml"/>
<outline text="Programming Digressions" title="Programming Digressions" description="" type="rss" version="RSS" htmlUrl="https://programming-digressions.com/" xmlUrl="https://programming-digressions.com/feed"/>
<outline text="The Pragmatic Engineer" title="The Pragmatic Engineer" description="" type="rss" version="RSS" htmlUrl="https://blog.pragmaticengineer.com/" xmlUrl="https://blog.pragmaticengineer.com/rss/"/>
</outline>
<outline text="Gaming" title="Gaming">
<outline text="Casual Magic with Shivam Bhatt" title="Casual Magic with Shivam Bhatt" description="" type="rss" version="RSS" htmlUrl="http://casualmagic.libsyn.com/website" xmlUrl="http://casualmagic.libsyn.com/rss"/>
<outline text="Hardcore Gaming 101" title="Hardcore Gaming 101" description="" type="rss" version="RSS" htmlUrl="http://www.hardcoregaming101.net/" xmlUrl="http://www.hardcoregaming101.net/feed/"/>
<outline text="Press The Buttons" title="Press The Buttons" description="" type="rss" version="RSS" htmlUrl="https://www.pressthebuttons.com/" xmlUrl="https://www.pressthebuttons.com/atom.xml"/>
<outline text="Random Battles: my life long level grind" title="Random Battles: my life long level grind" description="" type="rss" version="RSS" htmlUrl="https://randombattlesblog.wordpress.com/" xmlUrl="https://randombattlesblog.wordpress.com/feed/"/>
<outline text="Retronauts Subscription" title="Retronauts Subscription" description="" type="rss" version="RSS" htmlUrl="https://www.patreon.com/retronauts" xmlUrl="https://www.patreon.com/rss/retronauts?auth=eVU2jEFz2gYCKvJ5HZv9T7Cn0moFDbGu"/>
<outline text="Strife Streams" title="Strife Streams" description="" type="rss" version="RSS" htmlUrl="https://www.strifestreams.com/" xmlUrl="https://www.strifestreams.com/rss"/>
<outline text="The CRPG Addict" title="The CRPG Addict" description="" type="rss" version="RSS" htmlUrl="http://crpgaddict.blogspot.com/" xmlUrl="https://crpgaddict.blogspot.com/feeds/posts/default"/>
</outline>
<outline text="Own" title="Own">
<outline text="Brain Baking" title="Brain Baking" description="" type="rss" version="RSS" htmlUrl="https://brainbaking.com/" xmlUrl="http://brainbaking.com/index.xml"/>
<outline text="Kristien Thoelen" title="Kristien Thoelen" description="" type="rss" version="RSS" htmlUrl="https://kristienthoelen.be/" xmlUrl="https://kristienthoelen.be/feed/"/>
<outline text="Retro Gaming on Jefklaks Codex" title="Retro Gaming on Jefklaks Codex" description="" type="rss" version="RSS" htmlUrl="https://jefklakscodex.com/" xmlUrl="https://jefklakscodex.com/index.xml"/>
</outline>
<outline text="Personal Blogs" title="Personal Blogs">
<outline text="Bildung" title="Bildung" description="" type="rss" version="RSS" htmlUrl="https://bildung.royscholten.nl/" xmlUrl="https://bildung.royscholten.nl/feed/"/>
<outline text="Blog on roytang.net" title="Blog on roytang.net" description="" type="rss" version="RSS" htmlUrl="https://roytang.net/blog/" xmlUrl="https://roytang.net/blog/feed/rss"/>
<outline text="Chris Aldrich" title="Chris Aldrich" description="" type="rss" version="RSS" htmlUrl="https://boffosocko.com/" xmlUrl="http://www.boffosocko.com/?cat=-484&amp;feed=rss2"/>
<outline text="Henrique Dias" title="Henrique Dias" description="" type="rss" version="RSS" htmlUrl="" xmlUrl="https://hacdias.com/articles/feed.xml"/>
<outline text="Improved Means for Achieving Deteriorated Ends" title="Improved Means for Achieving Deteriorated Ends" description="" type="rss" version="RSS" htmlUrl="https://blog.kingcons.io/" xmlUrl="https://blog.kingcons.io/rss.xml"/>
<outline text="Interdependent Thoughts" title="Interdependent Thoughts" description="" type="rss" version="RSS" htmlUrl="https://www.zylstra.org/blog" xmlUrl="https://www.zylstra.org/blog/feed/"/>
<outline text="Michael Harley's blog" title="Michael Harley's blog" description="" type="rss" version="RSS" htmlUrl="" xmlUrl="https://obsolete29.com/feed/feed.xml"/>
<outline text="Nate Dickson Thinks..." title="Nate Dickson Thinks..." description="" type="rss" version="RSS" htmlUrl="https://thoughts.natedickson.com/" xmlUrl="https://thoughts.natedickson.com/feed/"/>
<outline text="P. I. Moore" title="P. I. Moore" description="" type="rss" version="RSS" htmlUrl="https://pimoore.ca/" xmlUrl="https://pimoore.ca/feed.xml"/>
<outline text="Peter Rukavina's Weblog" title="Peter Rukavina's Weblog" description="" type="rss" version="RSS" htmlUrl="https://ruk.ca/" xmlUrl="https://ruk.ca/rss/feedburner.xml"/>
<outline text="ReadWriteRespond | Read Write Collect" title="ReadWriteRespond | Read Write Collect" description="" type="rss" version="RSS" htmlUrl="https://collect.readwriterespond.com/" xmlUrl="https://collect.readwriterespond.com/tag/readwriterespond/feed/"/>
<outline text="Rubenerd" title="Rubenerd" description="" type="rss" version="RSS" htmlUrl="https://rubenerd.com/" xmlUrl="https://rubenerd.com/feed/"/>
<outline text="Stefan Imhoff" title="Stefan Imhoff" description="" type="rss" version="RSS" htmlUrl="https://www.stefanimhoff.de/" xmlUrl="https://www.stefanimhoff.de/index.xml"/>
<outline text="Twelve Travel Feet" title="Twelve Travel Feet" description="" type="rss" version="RSS" htmlUrl="https://twelvetravelfeet.home.blog/" xmlUrl="https://twelvetravelfeet.home.blog/feed/"/>
<outline text="Winnie Lim" title="Winnie Lim" description="" type="rss" version="RSS" htmlUrl="https://winnielim.org/" xmlUrl="https://winnielim.org/feed/"/>
<outline text="WordRidden" title="WordRidden" description="" type="rss" version="RSS" htmlUrl="http://www.wordridden.com/" xmlUrl="https://wordridden.com/rss"/>
</outline>
<outline text="Philosophy/Psychology" title="Philosophy/Psychology">
<outline text="Brain Pickings" title="Brain Pickings" description="" type="rss" version="RSS" htmlUrl="https://www.themarginalian.org/" xmlUrl="https://feeds.feedburner.com/brainpickings/rss"/>
<outline text="Farnam Street" title="Farnam Street" description="" type="rss" version="RSS" htmlUrl="https://fs.blog/" xmlUrl="https://fs.blog/feed/"/>
</outline>
<outline text="Technology" title="Technology">
<outline text="ancientelectronics" title="ancientelectronics" description="" type="rss" version="RSS" htmlUrl="https://ancientelectronics.wordpress.com/" xmlUrl="https://ancientelectronics.wordpress.com/feed/"/>
<outline text="Digging the Digital" title="Digging the Digital" description="" type="rss" version="RSS" htmlUrl="https://diggingthedigital.com/" xmlUrl="https://diggingthedigital.com/feed/"/>
<outline text="FOSS Academic" title="FOSS Academic" description="" type="rss" version="RSS" htmlUrl="https://fossacademic.tech/" xmlUrl="https://fossacademic.tech/feed.xml"/>
<outline text="i need coffee" title="i need coffee" description="" type="rss" version="RSS" htmlUrl="https://ineed.coffee/" xmlUrl="https://ineed.coffee/feed.xml"/>
<outline text="Laura Kalbag" title="Laura Kalbag" description="" type="rss" version="RSS" htmlUrl="https://laurakalbag.com/posts/" xmlUrl="https://laurakalbag.com/posts/index.xml"/>
</outline>
</body>
</opml>

View File

@ -0,0 +1,16 @@
{{ range $.Site.Data.blogroll.body.outline }}
<h3>{{ index . "-title" }}</h3>
<ul>
{{ range .outline }}
{{ $url := index . "-htmlUrl" }}
{{ if eq $url "" }}
{{ $url = index . "-xmlUrl" }}
{{ end }}
<li><a href="{{ $url }}">{{ index . "-title" }}</a>&nbsp;&nbsp;<svg class='icon'><use xlink:href='#link'></use></svg>{{ replaceRE `https?://` "" $url }}</li>
{{ end }}
</ul>
{{ end }}

460
static/museum/fav.html Normal file

File diff suppressed because one or more lines are too long

Binary file not shown.

After

Width:  |  Height:  |  Size: 196 KiB

View File

@ -18,7 +18,7 @@
<channel>
<title>{{ if eq .Title .Site.Title }}{{ .Site.Title }}{{ else }}{{ with .Title }}{{.}} on {{ end }}{{ .Site.Title }}{{ end }}</title>
<link>{{ .Permalink }}</link>
<description>{{ .Site.Title }} | {{ .Site.Params.description }} by {{ .Site.Author.name }} </description>
<description>{{ .Site.Params.description }} by {{ .Site.Author.name }} </description>
<generator>Hugo -- gohugo.io</generator>{{ with .Site.LanguageCode }}
<language>{{.}}</language>{{end}}
<managingEditor>{{ with $.Site.Author.name }}{{.}}{{end}}</managingEditor>

View File

@ -54,4 +54,8 @@
<symbol id="folder" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg">
<path fill="currentColor" d="M6.1,10L4,18V8H21A2,2 0 0,0 19,6H12L10,4H4A2,2 0 0,0 2,6V18A2,2 0 0,0 4,20H19C19.9,20 20.7,19.4 20.9,18.5L23.2,10H6.1M19,18H6L7.6,12H20.6L19,18Z" />
</symbol>
<symbol id="link" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg">
<path fill="none" d="M0 0h24v24H0z"/>
<path fill="currentColor" d="M3.9 12c0-1.71 1.39-3.1 3.1-3.1h4V7H7c-2.76 0-5 2.24-5 5s2.24 5 5 5h4v-1.9H7c-1.71 0-3.1-1.39-3.1-3.1zM8 13h8v-2H8v2zm9-6h-4v1.9h4c1.71 0 3.1 1.39 3.1 3.1s-1.39 3.1-3.1 3.1h-4V17h4c2.76 0 5-2.24 5-5s-2.24-5-5-5z"/>
</symbol>
</svg>

Before

Width:  |  Height:  |  Size: 6.9 KiB

After

Width:  |  Height:  |  Size: 7.3 KiB