-
-
Notifications
You must be signed in to change notification settings - Fork 52
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/Atom feed support #172
Comments
Hi @preslavrachev, Thanks for the kind words! This is a great idea, I don't use RSS feeds a ton so I'm using https://www.nasa.gov/rss/dyn/breaking_news.rss as a model. Looks like they simply put it in a string inside I originally thought about accomplishing this using jsonfeed-to-rss and passing Plenti's Here's the demo site: https://jimafisk.github.io/plenti-rss Here are the steps I took:
<script>
export let allContent;
let allPosts = allContent.filter(content => content.type == "blog");
let rssFeed = '<?xml version="1.0" encoding="UTF-8" ?><rss version="2.0"><channel><title>My Site Blog</title><link>https://www.mysite.com/blog</link><description>Awesome blog posts for my site</description>';
allPosts.forEach(post => {
rssFeed += '<item><title>' + post.fields.title + '</title>';
rssFeed += '<link>' + post.path + '</link>';
rssFeed += '<description>' + post.fields.body[0] + '</description>';
rssFeed += '</item>';
});
rssFeed += '</channel></rss>';
</script>
<pre style="word-wrap: break-word; white-space: pre-wrap;">
{rssFeed}
</pre> (I also added a conditional in So with that, every time you add a blog post to your site, it should automatically get added to your RSS feed without additional coding. It's not the nicest looking solution, mainly because you can't currently use template literals (there's a bug when adding backticks in Plenti: #121), but would something like this work for you? |
@jimafisk thank you for the thorough answer. Yeah, I am OK with creating a custom template for RSS. In fact, I usually do something similar for my backend projects. However, what you've presented here won't really work, because the RSS feed needs to be only the raw XML and nothing more. In your case, the RSS feed seems to be a full-fledged web page with a head, body, etc. To be honest, I don't think this is a problem that can be solved from Svelte. I think that the Go builder is the better place to do it. It has to enumerate all the content during building anyway, plus it has the compiled Svelte content, so it might as well output one or more RSS files, based on some predefined rules. |
Ahh yes that makes sense. So you could go outside of the wrapper in <script>
import RSS from '../content/rss.svelte';
export let allContent;
</script>
{#if content.path == "rss"}
<RSS {allContent} />
{:else}
<html lang="en">
{...}
</html>
{/if} Then in <head>
<link rel="alternate" type="application/rss+xml" title="RSS Feed" href="rss" />
</head> Unfortunately it still doesn't solve the issue of rendering xml in a Svelte component. The |
I can't promise anything, but I will try to use the quiet time around the holidays to look at the code and sketch something out. |
Has there been any further thought on this issue recently? Looks like it's been over a year since anything related has been discussed. Discovered Plenti yesterday and it looks amazing, but the lack of xml/rss templating support is a deal breaker for my purposes. |
Hi @axodys, thanks for your interest in the project! Are you looking for a simple way to auto-generate a For me, in an ideal world you could build this out yourself in the |
Hello,
First of all, I want to thank you for the amazing tool. As a long-time practitioner of both Go, Hugo, and Svelte, I cannot help but marvel at the possibility to combine the superpowers of all three together.
I am not sure I noticed any support for exporting an RSS/Atom feed. This is important to me (and frankly, for the future of the open Web).
What would be required for making this work and is this something I could maybe contribute to?
The text was updated successfully, but these errors were encountered: