mirror of
https://github.com/vercel/chat.git
synced 2026-09-14 18:32:29 +08:00
47 lines
1.1 KiB
TypeScript
47 lines
1.1 KiB
TypeScript
import { Feed } from "feed";
|
|
import type { NextRequest } from "next/server";
|
|
import { title } from "@/geistdocs";
|
|
import { source } from "@/lib/geistdocs/source";
|
|
|
|
const protocol = process.env.NODE_ENV === "production" ? "https" : "http";
|
|
const baseUrl = `${protocol}://${process.env.NEXT_PUBLIC_VERCEL_PROJECT_PRODUCTION_URL}`;
|
|
|
|
export const revalidate = false;
|
|
|
|
export const GET = async (
|
|
_req: NextRequest,
|
|
{ params }: RouteContext<"/[lang]/rss.xml">
|
|
) => {
|
|
const { lang } = await params;
|
|
const feed = new Feed({
|
|
title,
|
|
id: baseUrl,
|
|
link: baseUrl,
|
|
language: lang,
|
|
copyright: `All rights reserved ${new Date().getFullYear()}, Vercel`,
|
|
});
|
|
|
|
for (const page of source.getPages(lang)) {
|
|
feed.addItem({
|
|
id: page.url,
|
|
title: page.data.title,
|
|
description: page.data.description,
|
|
link: `${baseUrl}${page.url}`,
|
|
date: new Date(page.data.lastModified ?? new Date()),
|
|
author: [
|
|
{
|
|
name: "Vercel",
|
|
},
|
|
],
|
|
});
|
|
}
|
|
|
|
const rss = feed.rss2();
|
|
|
|
return new Response(rss, {
|
|
headers: {
|
|
"Content-Type": "application/rss+xml",
|
|
},
|
|
});
|
|
};
|