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

RSS package doesn't support images #10946

Open
1 task
markoa opened this issue Feb 12, 2025 · 8 comments
Open
1 task

RSS package doesn't support images #10946

markoa opened this issue Feb 12, 2025 · 8 comments
Labels
good first issue Good for newcomers help wanted Issues looking for someone to run with them! improve or update documentation Enhance / update existing documentation (e.g. add example, improve description, update for changes)

Comments

@markoa
Copy link

markoa commented Feb 12, 2025

Astro Info

Astro                    v5.1.0
Node                     v23.1.0
System                   macOS (arm64)
Package Manager          npm
Output                   static
Adapter                  none
Integrations             @astrojs/tailwind
                         @astrojs/mdx

If this issue only occurs in one browser, which browser is a problem?

No response

Describe the Bug

Including full post content is RSS 101. The recipe to that doesn't produce valid image paths.

What's the expected result?

The recipe should generate content with valid image paths. Ideally it would with MDX too.

Link to Minimal Reproducible Example

https://docs.astro.build/en/recipes/rss/#including-full-post-content

Participation

  • I am willing to submit a pull request for this issue.
@ematipico ematipico transferred this issue from withastro/astro Feb 12, 2025
@ArmandPhilippot
Copy link
Member

Hi! Sorry for the delay, I just saw that the topic came back on Discord so it reminded me of this issue.

We already discussed how we could write a recipe for this in #10317 (and in Talking & Doc'ing) but the conclusion was that it was too difficult to document properly because the generation is heavily dependent on the user project.

Images won't work, but neither will links if they are relative. So to include the full post, you should think about images, relative links, styles, scripts, and other elements that might be relevant to your project. For example, you may have unnecessary elements for an RSS feed (those used only for styling or interaction on your website) that should be removed. It's a bit tricky to document and involves a fair amount of code that can be difficult to follow.

So I'm not sure what we can do here... But, you can get inspiration from existing projects such as:

@markoa
Copy link
Author

markoa commented Feb 17, 2025

Thank you @ArmandPhilippot! I was able to implement the feed manually by following the first example that you shared.

My impression is that this recipe handles the most common use cases and would encourage you / Astro team to include a convenience function that wraps it.

I have noticed that any custom presentation beyond basic Markdown is better off solved on the layout level via additional frontmatter data, so that the feed can remain manageable.

My code in case anyone finds it useful:

@sarah11918
Copy link
Member

So, just to figure out where we landed here:

  1. Is the existing recipe incorrect or is it only fully working if your content is just plain text/basic Markdown, no links/images?
  2. Assuming it's the second one, could we address the issue by:
    • calling attention to this by adding something about "full Markdown text content, though images and links may not be included"
    • Adding a link to the helpful third-party integration someone can install for rendering full content, including MDX

Would those two things be helpful here?

@ArmandPhilippot
Copy link
Member

  1. The recipe is correct, it's the second one. Rendering the full post content is a bit more complex than described when it's not just text.

  2. It's not that the images and links aren't included, they are. It's that when images use a relative path as a source, they will be broken (and unless they are remote images, usually the path is relative, so images are "always" broken). The same applies to links.
    But, yeah, something like "full Markdown text content, though images and links might be broken if they use relative paths" could work. And I believe this is the best we can do in docs.

    However, if you refer to Chris' repo, this is not an integration that someone can install. This is an example to show how we can handle that. So this is more a source of inspiration (not yet ready for Astro 5 though). But, yeah, it might be useful to link to an example!

    I don't think anyone has made an integration for this as there are other things to consider as discussed during T&D for Add recipe for rendering Markdown and MDX content in an RSS feed #10317.

@sarah11918
Copy link
Member

sarah11918 commented Feb 26, 2025

Alright, thanks Armand for careful analysis here!

Seems like the best we can do is update this section in docs to something like....:

Including full post text content
Added in: [email protected]

The content key contains the full content of a post as HTML. This allows @astrojs/rss to make the full Markdown text of your post available to RSS feed readers. Images and links with full URL paths are also supported. However, images and internal links to other pages using relative paths are not.

When rendering full post content, you will have to consider images, relative links, styles, scripts, and other elements beyond standard Markdown text that you may have in your posts. You may need to include additional logic in your src/pages/rss.xml.js endpoint to account for these, or to remove elements that are unnecessary for an RSS feed (e.g. those that are used only for styling or interaction on your website).

You can see one specific community implementation that addresses some of these concerns for an example of how to proceed.

the tip etc...

What do y'all think?

@ArmandPhilippot
Copy link
Member

Looks perfect to me! 🙌🏽 Much better than what I tried on my side. 😅

@sarah11918 sarah11918 added improve or update documentation Enhance / update existing documentation (e.g. add example, improve description, update for changes) good first issue Good for newcomers help wanted Issues looking for someone to run with them! labels Mar 3, 2025
@sarah11918
Copy link
Member

Thanks everyone! I've updated with the appropriate help wanted labels and would accept a PR of the style I suggested in this earlier post:

Seems like the best we can do is update this section in docs to something like....:

@9thQuadrant
Copy link
Contributor

@sarah11918 i would like to work on this

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Good for newcomers help wanted Issues looking for someone to run with them! improve or update documentation Enhance / update existing documentation (e.g. add example, improve description, update for changes)
Projects
None yet
Development

No branches or pull requests

4 participants