-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
50a120f
commit 0d23a4b
Showing
4 changed files
with
105 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
import { getRssData } from '@/lib/getcontent'; | ||
|
||
export async function GET(request: Request) { | ||
try { | ||
const rssData = await getRssData(); | ||
|
||
const xmlItems = rssData | ||
.map( | ||
(item) => ` | ||
<item> | ||
<title xml:lang="${item.lang}">${item.title}</title> | ||
<link>https://augustinmauroy.github.io/${item.lang}/blog/${ | ||
item.slug | ||
}</link> | ||
<pubDate>${item.date.toUTCString()}</pubDate> | ||
<description xml:lang="${item.lang}">${ | ||
item.description | ||
}</description> | ||
</item> | ||
`, | ||
) | ||
.join('\n'); | ||
|
||
const rssContent = ` | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<rss version="2.0"> | ||
<channel> | ||
<title>Votre titre de flux RSS</title> | ||
<link>https://augustinmauroy.github.io/blog</link> | ||
<description>Votre description de flux RSS</description> | ||
${xmlItems} | ||
</channel> | ||
</rss> | ||
`; | ||
|
||
return new Response(rssContent, { | ||
headers: { | ||
'content-type': 'application/xml;charset=UTF-8', | ||
}, | ||
}); | ||
} catch (error) { | ||
return new Response('error', { | ||
status: 500, | ||
}); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters