Hacker News new | ask | show | jobs
by incanus77 1927 days ago
I have a ~200 LOC Hugo partial I've built up which reads in the webmentions via jQuery, then parses them out into Twitter, Micro.blog, or "other". If at least one of either/or Twitter or Micro.blog, pull out the root URL and show that at the top of the comments to encourage discussion. Otherwise, parse out like, repost, or plain old mention and add an icon.

I also have an HN parser for posts like this one[1] if they've hit a certain comment threshold.

I don't have any problem with sharing it, but I just haven't published it anywhere yet on account of not wanting the maintenance or support overhead. I think all of it can be gleaned from the page source, anyway.

[1] https://justinmiller.io/posts/2019/09/21/pi-gadget/ (see bottom)

1 comments

was it easy to get it setup? I too have a Hugo blog but other than occasionally adding posts and changing the theme, haven't done any intense partial-building. Sounds like it could be a fun little project
I mean, the JS itself is the 200 LOC, so it's not trivial, but feel free to crib my source as a start. The partials are really straightforward, though — my layouts/microposts/single.html just brings in the webmentions.html partial with one tag at the right part of the layout (i.e. almost the bottom) and then that JS does the work of... whatever you want. You could start just iterating the contents of any webmentions array pulled in as an unnumbered list, then iterate your presentation from there.