-
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.
Add a link tag to the page metadata to make the RSS feed discoverable. Add @astrojs/rss package.
- Loading branch information
1 parent
60da3b2
commit 4a96aaa
Showing
7 changed files
with
90 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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
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,35 @@ | ||
import rss from "@astrojs/rss"; | ||
import { getCollection } from "astro:content"; | ||
import { dateFromSlug, formatRSSDate } from "@/utils"; | ||
|
||
export async function GET(context) | ||
{ | ||
const blog = await getCollection("blog"); | ||
const items = blog.map((post) => { | ||
const { | ||
slug, | ||
data: { | ||
title, | ||
descriptionHTML, | ||
// pubDate is required, but some posts don't have a date specified, so | ||
// create one from the filename | ||
date = dateFromSlug(slug), | ||
}, | ||
} = post; | ||
|
||
return { | ||
title, | ||
description: descriptionHTML, | ||
pubDate: formatRSSDate(date), | ||
link: `/blog/${slug}`, | ||
}; | ||
}); | ||
|
||
return rss({ | ||
title: "SF Civic Tech Blog", | ||
description: "News from SF Civic Tech", | ||
site: context.site, | ||
trailingSlash: false, | ||
items, | ||
}); | ||
} |
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