Feeds problems
The other day a blog reader - I assume - let me know that my feed content was broken. The content syndication was failing because, in every post that loaded an image with the theme’s gallery shortcode, the code appeared instead of the images:
<description>Can you almost smell it?
if (!jQuery) { alert("jquery is not loaded"); } $( document ).ready(() = { const gallery = $("
</description>
I imagine the shortcode I’m using (which is part of a theme) doesn’t take in account the feeds, so I had to spend some time looking for a possible solution. I also realized that my RSS feeds weren’t including the full content of each post, only an “excerpt” version. Big mistake on my part, as I’ve always ranted about that.
Getting down to it, the biggest challenge I faced was finding something that could be executed before the shortcode, as it would be more complicated to fix once the {{ <gallery ...> }}
had been replaced. That’s where RawContent
came to the rescue. By creating a new home.xml
template for the feeds, I was able to edit the description
tag to, initially, disable the galleries:
<description>
{{ .RawContent | replaceRE `<\s*gallery[^>]*>` "`[image not loaded in rss]`" | markdownify | htmlEscape | safeHTML }}
</description>
Finally, I also separated the feeds by category to keep things more organized. So, as of now, the following feeds are available:
- Posts: Blog posts.
- Microposts or Log: Microposts from the blog (most relevant updates from Mastodon / Bluesky).
- Watching: Series and movies I’m tracking.
- Reading: Books I’m reading.
- Listening: Albums currently playing on my Spotify.
- Playing: Video games I’m currently playing.
Thanks @benalb for the heads-up.
—
2024-10-28 Update: Found an issue related to this problem.