import { type DayjsDate, toRFC822 } from "./date";
import { xml } from "./mark-template";
import { minifyInternally } from "./minify";
type Page = {
content: string;
pubDate: DayjsDate;
url: string;
};
type Project = {
description: string;
language?: string;
pages: Page[];
title: string;
url: string;
};
export function createTurboRss(project: Project) {
const body = minifyInternally(xml`
${project.title}
${project.description}
${project.url}
${project.language || "ru"}
${project.pages.map(mapPage).join("")}
`);
return new Response(body, { headers: { "Content-Type": "application/xml" } });
}
function mapPage(page: Page) {
return xml`
-
true
${page.url}
${toRFC822(page.pubDate)}
`;
}