#How to use correct path in RSS feed item for images?

4 messages · Page 1 of 1 (latest)

hidden ocean
#

Hey all,

Got a problem here when trying to build my RSS feed with images.

I have an existing RSS feed set up, but I'm not using the content field from the rssSchema.

I am wanting to start posting on dev.to and added my RSS feed to my dev.to account, which will pull all my blog post as a draft. The drafts have the title and description, but not the content. I want the content of my blog to be included.

I followed the tutorial on Astro on generating the content body. Everything is dandy except the <img> tags. They are still pointing to a relative path like ._images/path/to/img.png.

There's no info on how to do this.

But I was able to get this far where I'm rendering the markdown with markdownIt.render(post.body) and passing that to an HTML parser where I then filter all the image tags.

From there, I'm grabbing the src attribute that has relative path to the image.

I am trying to get the Astro local optimized image, then replace the relative path with the actual optimized image path, and then sanitize it with sanitize-html.

When I use a string literal with import(), it shows the Astro image. But when I use a dynamic template literal like import(${src}) I get an error.

I know Astro is using Vite and Rollup under the hood, but I don't know enough about build systems to get this working correctly.

I'm not sure why it's importing the Astro image using string literal vs template literal.

Can anyone lend a hand? Is this even possible?

torn zenith
#

Hi

If you're import is fully static, why not just at the top of the file

import MyImage from "./_images/..."

Also did you tried using mdx ?

hidden ocean
#

I haven't introduced MDX in my project, but it is planned.

How would using the import like that affect the content collection and the RSS output using sanitize-html and markdown-it?

rustic thorn