Webmentions revisited

Some changes to webmentions handling on this site

Docs: https://docs.hugoblox.com/content/writing-markdown-latex/#callouts

Parameters

#0 : optional, positional Add the class “alert-{#0}” to the

container of the callout element. Default Hugo Blox Builder available styles are “note” and “warning”. Otherwise you can create your own class (see assets/scss/blox-bootstrap/elements/_callout.scss). */}}

This is a very brief note for my own benefit - if you are even slightly interested I recommend following the links to find other authors who have done a much better job of explaining this!

I had previously displayed WebMentions on posts via a script that ran on each pageview, queried webmention.io for mentions relevant to that page and rendered them - entirely based on the original approach documented by Sebastian de Dyne.

In the most recent iteration of changes I have:

  • adapted the processing of inbound webmentions so they are pulled periodically into data files in the repo by Github actions, then processed when the site is built so they are baked into the rendered static pages
  • added a Netlify build plugin to push outgoing webmentions from my site to the sites I link to

Processing inbound web mentions

Key elements:

  • a Github action that runs every thirty minutes and calls a retrieval script
  • the retrieval script which pulls webmentions from webmention.io and stores them as data files in the source repo for the site
  • a processing script that is run each time the site is built - this reads the raw webmentions and processes them into a form suitable for Hugo to digest
  • changes to page layouts to render a webmentions section

For all of this I am indebted to Rowan Manning’s approach.

Sending web mentions when the site is built

This is the other side of the coin. There are a range of approaches, but I decided to go with a Netlify build plugin configured to only run on production builds.

All the examples I could find work by processing the RSS feed for the site, and most take the approach of posting webmentions for any remote sites linked from the last (or a configurable last number of) posts. This will fall down if you ever create more than one post in between publishes - rare but not impossible.

I then found the approach documented by Mark Everitt which compares the RSS feed before and after the build and pushes webmentions for all new items, and have adapted his code.

Other things

A note to myself - new functionality based on code developed by others, I need to spend some time to make the repo for this site openable, then make it public. now done - here

Avatar
Proactive application of technology to business

My interests include technology, personal knowledge management, social change

Next
Previous