-
-
Notifications
You must be signed in to change notification settings - Fork 2.5k
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
Can't use RSS with content folder #5619
Comments
👍 Ideally we'd be able to use Ugly workaround: const slugRegex = /^src\/content\/blog\/(.*?)\.mdx?$/i
...
link: new URL(`/posts/${post.url.replace(slugRegex, '$1/')}`, import.meta.env.SITE).toString(), |
You can use the import rss from '@astrojs/rss';
import { getCollection } from 'astro:content';
import { SITE_TITLE, SITE_DESCRIPTION } from '../config';
const posts = await getCollection('blog');
export const get = () =>
rss({
title: SITE_TITLE,
description: SITE_DESCRIPTION,
site: import.meta.env.SITE,
items: posts.map((post) => ({
title: post.data.title,
description: post.data.description,
pubDate: post.data.pubDate,
link: post.slug,
})),
}); |
I can't seem to get a good build from doing that. |
I did verify that it works: louiss0/test-windows#1 (open in StackBlitz). |
I tried out the example but I did not get a good build out of it. This is what I get when I try to build the site. Using get collection does not allow you to get the build you want. I don't know what is happening but the files i need refuse to come out. Do I need to build while the server is running or something? |
It looks like you are running |
I did that after the build the files that are generated from the build on the left. It's not about the command It's about the files. As you can see no html files are generated at all. |
How am I supposed to write the url. I see no url out put any more |
You seem to have run into a separate import rss from "@astrojs/rss";
import { getCollection } from "astro:content";
import { SITE_TITLE, SITE_DESCRIPTION } from "../config";
export const get = async () => {
const posts = await getCollection("blog");
return rss({
title: SITE_TITLE,
description: SITE_DESCRIPTION,
site: import.meta.env.SITE,
items: posts.map((post) => ({
title: post.data.title,
description: post.data.description,
pubDate: post.data.pubDate,
link: post.slug,
})),
});
}; |
You got it the astro team needs to be told that this is how to use I'll have to write lots of boilerplate code to be able to get multiple collections from multiple files. I want the content folder just to be the base. |
Thanks! 🚀 I got the early exit issue using |
What version of
astro
are you using?1.7.0
Are you using an SSR adapter? If so, which one?
NONE
What package manager are you using?
pnpm
What operating system are you using?
Windows
Describe the Bug
I can't use RSS with Astro when I try to use the content folder to render the rss stuff it will not work.
This is the error that I get when running the code.
This is what my config looks like
Link to Minimal Reproducible Example
https://github.com/louiss0/test-windows
Participation
The text was updated successfully, but these errors were encountered: