48 lines
1.7 KiB
TypeScript
48 lines
1.7 KiB
TypeScript
import { getAllPosts } from "@/lib/db"
|
|
|
|
export const dynamic = "force-dynamic"
|
|
|
|
// Feed RSS 2.0 del fansub: para que la gente se suscriba y siga los lanzamientos.
|
|
export async function GET() {
|
|
const posts = getAllPosts(true).slice(0, 30)
|
|
|
|
const items = posts
|
|
.map((p) => {
|
|
const pubDate = p.published_at
|
|
? new Date(p.published_at).toUTCString()
|
|
: new Date(p.created_at).toUTCString()
|
|
const description =
|
|
(p.summary && !p.summary.startsWith("**") && p.summary.length > 30
|
|
? p.summary.slice(0, 300)
|
|
: `${p.num_pages} páginas`) || `${p.num_pages} páginas`
|
|
return ` <item>
|
|
<title><![CDATA[${p.title}${p.title_jpn ? ` (${p.title_jpn})` : ""}]]></title>
|
|
<link>https://worstscan.xyz/p/${p.slug}</link>
|
|
<guid isPermaLink="false">worstscan-${p.gid}</guid>
|
|
<pubDate>${pubDate}</pubDate>
|
|
<description><![CDATA[${description}]]></description>
|
|
<enclosure url="https://worstscan.xyz/api/cover/${p.gid}" type="image/jpeg" />
|
|
</item>`
|
|
})
|
|
.join("\n")
|
|
|
|
const xml = `<?xml version="1.0" encoding="UTF-8"?>
|
|
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
|
|
<channel>
|
|
<title>worst-scan fansub</title>
|
|
<link>https://worstscan.xyz</link>
|
|
<description>Escaneos y traducciones de manga</description>
|
|
<language>es</language>
|
|
<lastBuildDate>${new Date().toUTCString()}</lastBuildDate>
|
|
<atom:link href="https://worstscan.xyz/rss.xml" rel="self" type="application/rss+xml" />
|
|
${items}
|
|
</channel>
|
|
</rss>`
|
|
|
|
return new Response(xml, {
|
|
headers: {
|
|
"Content-Type": "application/rss+xml; charset=utf-8",
|
|
"Cache-Control": "public, max-age=600",
|
|
},
|
|
})
|
|
} |