oscarmlage oscarmlage

Feeds problems

Written by oscarmlage on

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(&#34;jquery is not loaded&#34;); } $( document ).ready(() = { const gallery = $(&#34;
</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:

Thanks @benalb for the heads-up.

2024-10-28 Update: Found an issue related to this problem.