Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

update RSS layout to fix image rendering #491

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

apreshill
Copy link
Collaborator

@apreshill apreshill commented Dec 9, 2020

I believe this is ready- the index.xml now contains absolute urls to all images in posts, but the layout still allows relative image links by post authors (respecting page bundling).

current:
https://www.tidyverse.org/blog/index.xml

updated:
https://deploy-preview-491--tidyverse-org.netlify.app/blog/index.xml

h/t to this individual: https://jdheyburn.co.uk/blog/who-goes-blogging-6-three-steps-to-improve-hugos-rss-feeds/

@apreshill apreshill marked this pull request as ready for review December 9, 2020 19:19
@@ -32,7 +32,9 @@
<link>{{ .Permalink }}</link>
<pubDate>{{ .Date.Format "Mon, 02 Jan 2006 15:04:05 -0700" | safeHTML }}</pubDate>
<guid>{{ .Permalink }}</guid>
<description>{{ .Content | html }}</description>
{{- $content := replaceRE "a href=\"(#.*?)\"" (printf "%s%s%s" "a href=\"" .Permalink "$1\"") .Content -}}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you please use a comment here to link back to that blog post that explains how this works?

It's unfortunate that hugo doesn't provide something built in for this case, because the regexp approach is going to be fragile (i.e. it relies on the alt attribute coming after the src attribute).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants