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)),
|
||||
),
|
||||
|
|
|
|||
|
|
@ -6,6 +6,9 @@ import { blogFeedItem, gameFeedItem, storyFeedItem, type EntryWithPubDate } from
|
|||
const MAX_ITEMS = 8;
|
||||
|
||||
export const GET: APIRoute = async ({ site }) => {
|
||||
if (!site) {
|
||||
throw new Error("site is required.");
|
||||
}
|
||||
const stories = (
|
||||
(await getCollection(
|
||||
"stories",
|
||||
|
|
@ -28,7 +31,9 @@ export const GET: APIRoute = async ({ site }) => {
|
|||
return rss({
|
||||
title: "Gallery | Bad Manners",
|
||||
description: "Stories, games, and more by Bad Manners.",
|
||||
site: site!,
|
||||
site: site,
|
||||
xmlns: { atom: "http://www.w3.org/2005/Atom" },
|
||||
customData: `<link href="${site}" rel="alternate" type="text/html" /><atom:link href="${new URL("feed.xml", site)}" rel="self" type="application/rss+xml" />`,
|
||||
items: await Promise.all(
|
||||
[
|
||||
stories.map(({ data, slug, render }) => ({
|
||||
|
|
|
|||
|
|
@ -6,6 +6,9 @@ import { gameFeedItem, type EntryWithPubDate } from "@utils/feed";
|
|||
const MAX_ITEMS = 8;
|
||||
|
||||
export const GET: APIRoute = async ({ site }) => {
|
||||
if (!site) {
|
||||
throw new Error("site is required.");
|
||||
}
|
||||
const stories = (
|
||||
(await getCollection("games", (game) => !game.data.isDraft && game.data.pubDate)) as EntryWithPubDate<"games">[]
|
||||
)
|
||||
|
|
@ -15,7 +18,9 @@ export const GET: APIRoute = async ({ site }) => {
|
|||
return rss({
|
||||
title: "Games | Bad Manners",
|
||||
description: "Games by Bad Manners.",
|
||||
site: new URL("/games", site!),
|
||||
site: new URL("games", site),
|
||||
xmlns: { atom: "http://www.w3.org/2005/Atom" },
|
||||
customData: `<link href="${new URL("games", site)}" rel="alternate" type="text/html" /><atom:link href="${new URL("games/feed.xml", site)}" rel="self" type="application/rss+xml" />`,
|
||||
items: await Promise.all(
|
||||
stories.map(async ({ data, slug, render }) => gameFeedItem(site, data, slug, (await render()).Content)),
|
||||
),
|
||||
|
|
|
|||
|
|
@ -6,6 +6,9 @@ import { storyFeedItem, type EntryWithPubDate } from "@utils/feed";
|
|||
const MAX_ITEMS = 8;
|
||||
|
||||
export const GET: APIRoute = async ({ site }) => {
|
||||
if (!site) {
|
||||
throw new Error("site is required.");
|
||||
}
|
||||
const stories = (
|
||||
(await getCollection(
|
||||
"stories",
|
||||
|
|
@ -18,7 +21,9 @@ export const GET: APIRoute = async ({ site }) => {
|
|||
return rss({
|
||||
title: "Stories | Bad Manners",
|
||||
description: "Stories by Bad Manners.",
|
||||
site: new URL("/stories/1", site!),
|
||||
site: new URL("stories/1", site),
|
||||
xmlns: { atom: "http://www.w3.org/2005/Atom" },
|
||||
customData: `<link href="${new URL("stories/1", site)}" rel="alternate" type="text/html" /><atom:link href="${new URL("stories/feed.xml", site)}" rel="self" type="application/rss+xml" />`,
|
||||
items: await Promise.all(
|
||||
stories.map(async ({ data, slug, render }) => storyFeedItem(site, data, slug, (await render()).Content)),
|
||||
),
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue