fix feed?

This commit is contained in:
ld3zian 2025-01-28 17:48:05 -07:00
parent f66aa36890
commit 40552e471c
2 changed files with 23 additions and 9 deletions

View file

@ -3,7 +3,7 @@ import { getChaptersForSlugs, isValidLanguage } from "../../lib/api";
import { getFeedMapping } from "../../lib/db";
import type { APIRoute } from "astro";
export const GET: APIRoute = async ({ params }) => {
export const GET: APIRoute = async ({ params, request }) => {
const feedId = params.feedId?.replace('.xml', '');
if (!feedId) {
@ -28,21 +28,28 @@ export const GET: APIRoute = async ({ params }) => {
return new Response("No chapters found for the provided comics", { status: 404 });
}
const siteUrl = new URL(request.url).origin;
const feedUrl = new URL(request.url).href;
const feed = new Feed({
title: `ComicK - Custom Feed (${lang.toUpperCase()})`,
description: `Custom RSS feed for selected comics: ${slugs.join(', ')}`,
id: "https://github.com/ld3z/manga-rss",
link: "https://github.com/ld3z/manga-rss",
id: feedUrl,
link: siteUrl,
feedLinks: {
rss2: feedUrl
},
language: lang,
copyright: "All rights reserved",
updated: new Date(),
});
chapters.forEach((chapter) => {
const chapterUrl = `https://comick.io/comic/${chapter.md_comics.slug}`;
feed.addItem({
title: `${chapter.md_comics.title} - Chapter ${chapter.chap}`,
id: `${chapter.md_comics.slug}-${chapter.chap}`,
link: `https://comick.io/comic/${chapter.md_comics.slug}`,
id: `urn:comick:${chapter.md_comics.slug}:${chapter.chap}`,
link: chapterUrl,
description: `
<div>
${

View file

@ -22,21 +22,28 @@ export const GET: APIRoute = async ({ params, url }) => {
return new Response("No chapters found for the provided comics", { status: 404 });
}
const siteUrl = new URL(url).origin;
const feedUrl = new URL(url).href;
const feed = new Feed({
title: `ComicK - Custom Feed (${lang.toUpperCase()})`,
description: `Custom RSS feed for selected comics: ${slugs.join(', ')}`,
id: "https://github.com/ld3z/manga-rss",
link: "https://github.com/ld3z/manga-rss",
id: feedUrl,
link: siteUrl,
feedLinks: {
rss2: feedUrl
},
language: lang,
copyright: "All rights reserved",
updated: new Date(),
});
chapters.forEach((chapter) => {
const chapterUrl = `https://comick.io/comic/${chapter.md_comics.slug}`;
feed.addItem({
title: `${chapter.md_comics.title} - Chapter ${chapter.chap}`,
id: `${chapter.md_comics.slug}-${chapter.chap}`,
link: `https://comick.io/comic/${chapter.md_comics.slug}`,
id: `urn:comick:${chapter.md_comics.slug}:${chapter.chap}`,
link: chapterUrl,
description: `New chapter available: Chapter ${chapter.chap}`,
date: new Date(chapter.updated_at),
});