adding metadata to rss flow to make n8n read right proprieties

This commit is contained in:
2026-05-26 11:25:57 +02:00
parent dec57ba6f2
commit 03aafdc673
+34 -31
View File
@@ -3,38 +3,41 @@ import RSS from 'rss';
import { getAllArticles } from '@/lib/blog/get-articles'; import { getAllArticles } from '@/lib/blog/get-articles';
export async function GET() { export async function GET() {
const siteUrl = 'https://matheoguilbert.fr'; const siteUrl = 'https://matheoguilbert.fr';
const feed = new RSS({
title: 'Macthéo Guilbert | Blog',
description: 'Développement web, UI/UX et automatisations.',
feed_url: `${siteUrl}/rss.xml`,
site_url: siteUrl,
language: 'fr',
pubDate: new Date(),
});
try { const feed = new RSS({
const articles = await getAllArticles('fr'); title: 'Macthéo Guilbert | Blog',
description: 'Développement web, UI/UX et automatisations.',
articles.forEach((article) => { feed_url: `${siteUrl}/rss.xml`,
feed.item({ site_url: siteUrl,
title: article.title, language: 'fr',
description: article.description, pubDate: new Date(),
url: `${siteUrl}/fr/blog/${article.slug}`,
guid: article.slug,
date: article.date,
});
}); });
return new NextResponse(feed.xml({ indent: true }), { try {
headers: { const articles = await getAllArticles('fr');
'Content-Type': 'application/xml; charset=utf-8',
'Cache-Control': 'no-store, no-cache, must-revalidate, proxy-revalidate', articles.forEach((article) => {
}, feed.item({
}); title: article.title,
} catch (error) { description: article.description,
console.error('Erreur lors de la génération du flux RSS:', error); url: `${siteUrl}/fr/blog/${article.slug}`,
return new NextResponse('Internal Server Error', { status: 500 }); guid: article.slug,
} date: article.date,
custom_elements: [
{ 'meta_description': article.description }
],
});
});
return new NextResponse(feed.xml({ indent: true }), {
headers: {
'Content-Type': 'application/xml; charset=utf-8',
'Cache-Control': 'no-store, no-cache, must-revalidate, proxy-revalidate',
},
});
} catch (error) {
console.error('Erreur lors de la génération du flux RSS:', error);
return new NextResponse('Internal Server Error', { status: 500 });
}
} }