-
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.
Implement an RSS feed (at rss.xml). (#66)
Co-authored-by: Luc van Kampen <[email protected]> Co-authored-by: Jakob Helgesson <[email protected]>
- Loading branch information
1 parent
6c5cbbe
commit a0f7a93
Showing
4 changed files
with
79 additions
and
1 deletion.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
import { covers } from 'assets/assets'; | ||
import { Feed } from 'feed'; | ||
|
||
import { getPostsMetadata } from '@/lib/get_posts'; | ||
|
||
export const GET = async (request: Request) => { | ||
const feed = new Feed({ | ||
title: 'ENS Blog', | ||
description: 'The official blog of the Ethereum Name Service', | ||
link: 'https://blog.ens.domains', | ||
language: 'en', | ||
image: 'https://blog.ens.domains/opengraph.jpg', | ||
generator: 'NextJS on Edgeserver', | ||
feedLinks: { | ||
atom: 'https://blog.ens.domains/rss.xml', | ||
}, | ||
id: 'https://blog.ens.domains', | ||
copyright: '© ENS Domains', | ||
}); | ||
|
||
const posts = await getPostsMetadata(); | ||
|
||
for (const post of posts) { | ||
const postCovers = covers[post.file as keyof typeof covers]; | ||
const postCoverThumb = await postCovers['cover-thumb'].then( | ||
(cover) => cover.default | ||
); | ||
|
||
feed.addItem({ | ||
title: post.title, | ||
guid: 'https://blog.ens.domains/post/' + post.slug, | ||
link: 'https://blog.ens.domains/post/' + post.slug, | ||
date: new Date(post.date), | ||
description: post.description, | ||
author: post.authors.map((author) => { | ||
return { | ||
name: author, | ||
link: 'https://blog.ens.domains/author/' + author, | ||
}; | ||
}), | ||
image: postCoverThumb.src, | ||
}); | ||
} | ||
|
||
return new Response(feed.atom1(), { | ||
headers: { | ||
'Content-Type': 'application/atom+xml; charset=utf-8', | ||
}, | ||
}); | ||
}; |
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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.