adding metadata to rss flow to make n8n read right proprieties
This commit is contained in:
+34
-31
@@ -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({
|
const feed = new RSS({
|
||||||
title: 'Macthéo Guilbert | Blog',
|
title: 'Macthéo Guilbert | Blog',
|
||||||
description: 'Développement web, UI/UX et automatisations.',
|
description: 'Développement web, UI/UX et automatisations.',
|
||||||
feed_url: `${siteUrl}/rss.xml`,
|
feed_url: `${siteUrl}/rss.xml`,
|
||||||
site_url: siteUrl,
|
site_url: siteUrl,
|
||||||
language: 'fr',
|
language: 'fr',
|
||||||
pubDate: new Date(),
|
pubDate: new Date(),
|
||||||
});
|
|
||||||
|
|
||||||
try {
|
|
||||||
const articles = await getAllArticles('fr');
|
|
||||||
|
|
||||||
articles.forEach((article) => {
|
|
||||||
feed.item({
|
|
||||||
title: article.title,
|
|
||||||
description: article.description,
|
|
||||||
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 });
|
||||||
|
}
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user