Skip to content

Commit

Permalink
More adjustments for images in rss
Browse files Browse the repository at this point in the history
  • Loading branch information
hisnameisjimmy committed Mar 15, 2024
1 parent d71ac4a commit e53d8d3
Showing 1 changed file with 24 additions and 4 deletions.
28 changes: 24 additions & 4 deletions gatsby-config.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,10 +58,30 @@ module.exports = {
: undefined,
custom_elements: [
{
'content:encoded': edge.node.html.replace(
/(?<=\"|\s)\/static\//g,
`${site.siteMetadata.siteUrl}/static/`,
),
'content:encoded': edge.node.html
.replace(
/(<img [^>]*srcSet=")([^"]+)"/g,
function (match, p1, p2) {
return (
p1 +
p2
.split(',')
.map((item) =>
item.trim().startsWith('/static/')
? `${
site.siteMetadata.siteUrl
}${item.trim()}`
: item.trim(),
)
.join(', ') +
'"'
);
},
)
.replace(
/(<img [^>]*src=")(\/static\/[^"]+")/g,
`${site.siteMetadata.siteUrl}$2`,
),
},
],
};
Expand Down

0 comments on commit e53d8d3

Please sign in to comment.