#Need rss import meta glob to be filtered before generating the rss feed
1 messages · Page 1 of 1 (latest)
That above code doesn't work. I don't know what I need to do to make it work though.
The RSS feed ends up empty
const globModules = import.meta.glob('./publications/*.astro');
async function filteredRssItems(globModules) {
const modules = await Promise.all(
Object.entries(globModules).map(async ([path, resolver]) => {
const mod = await resolver();
return { path, ...mod };
})
);
// Filter by post.pub
const filtered = modules.filter(m => m.post?.pub);
// Sort oldest first (ascending)
filtered.sort((a, b) => new Date(a.post.pub) - new Date(b.post.pub));
// Map to RSS items
return filtered.map(m => ({
title: m.post.title,
description: m.post.description || '',
pubDate: new Date(m.post.pub),
link: m.path.replace('./publications', '/publications').replace('.astro', '')
}));
}
// Usage
items: await filteredRssItems(import.meta.glob('./publications/*.astro'))
chatgpt gave me that