Skip to content

Commit

Permalink
Define feed
Browse files Browse the repository at this point in the history
  • Loading branch information
otoyo committed Jan 21, 2023
1 parent e89b676 commit dc46da6
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions src/pages/feed.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import rss from '@astrojs/rss'
import {
PUBLIC_SITE_TITLE,
PUBLIC_SITE_DESCRIPTION,
} from '../server-constants'
import { getAllPosts } from '../lib/notion/client'
import { getPostLink } from '../lib/blog-helpers'

export async function get() {
const posts = await getAllPosts()

return rss({
title: PUBLIC_SITE_TITLE,
description: PUBLIC_SITE_DESCRIPTION,
site: import.meta.env.SITE,
items: posts.map((post) => ({
link: new URL(getPostLink(post.Slug), import.meta.env.SITE).toString(),
title: post.Title,
pubDate: new Date(post.Date),
})),
})
}

0 comments on commit dc46da6

Please sign in to comment.