Improve feeds according to W3C
This commit is contained in:
parent
d56a8cc95d
commit
c1a59ed51a
9 changed files with 137 additions and 53 deletions
|
|
@ -6,6 +6,9 @@ import { blogFeedItem, type EntryWithPubDate } from "@utils/feed";
|
|||
const MAX_ITEMS = 8;
|
||||
|
||||
export const GET: APIRoute = async ({ site }) => {
|
||||
if (!site) {
|
||||
throw new Error("site is required.");
|
||||
}
|
||||
const posts = (
|
||||
(await getCollection("blog", (post) => !post.data.isDraft && post.data.pubDate)) as EntryWithPubDate<"blog">[]
|
||||
)
|
||||
|
|
@ -15,7 +18,9 @@ export const GET: APIRoute = async ({ site }) => {
|
|||
return rss({
|
||||
title: "Blog | Bad Manners",
|
||||
description: "Blog posts by Bad Manners.",
|
||||
site: new URL("/blog", site!),
|
||||
site: new URL("blog", site),
|
||||
xmlns: { atom: "http://www.w3.org/2005/Atom" },
|
||||
customData: `<link href="${new URL("blog", site)}" rel="alternate" type="text/html" /><atom:link href="${new URL("blog/feed.xml", site)}" rel="self" type="application/rss+xml" />`,
|
||||
items: await Promise.all(
|
||||
posts.map(async ({ data, slug, render }) => blogFeedItem(site, data, slug, (await render()).Content)),
|
||||
),
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue