mirror of
https://github.com/ld3z/new-manga.git
synced 2026-11-09 20:23:45 -07:00
add specific feeds for specifc manga
This commit is contained in:
parent
0277da93e5
commit
082db594dd
6 changed files with 397 additions and 3 deletions
|
|
@ -47,7 +47,27 @@ const description = `Latest ${type!.toUpperCase()} comics in ${getLanguageName(l
|
|||
</h1>
|
||||
|
||||
<div class="flex flex-col sm:flex-row justify-between items-start sm:items-center gap-4 mb-8">
|
||||
<LanguageSelector currentLang={lang!} currentType={type!} />
|
||||
<div class="flex items-center gap-4">
|
||||
<LanguageSelector currentLang={lang!} currentType={type!} />
|
||||
<a
|
||||
href="/custom"
|
||||
class="inline-flex items-center gap-2 px-4 py-2 bg-accent text-secondary hover:bg-accent-light rounded-md transition-colors font-medium"
|
||||
>
|
||||
<svg
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
class="w-5 h-5"
|
||||
viewBox="0 0 24 24"
|
||||
fill="none"
|
||||
stroke="currentColor"
|
||||
stroke-width="2"
|
||||
stroke-linecap="round"
|
||||
stroke-linejoin="round"
|
||||
>
|
||||
<path d="M12 5v14M5 12h14"/>
|
||||
</svg>
|
||||
Custom Feed
|
||||
</a>
|
||||
</div>
|
||||
<RSSLink lang={lang!} type={type!} />
|
||||
</div>
|
||||
|
||||
|
|
|
|||
22
src/pages/custom.astro
Normal file
22
src/pages/custom.astro
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
---
|
||||
import Layout from '../layouts/Layout.astro';
|
||||
import SlugInput from '../components/SlugInput.astro';
|
||||
|
||||
const title = "ComicK - Custom RSS Feed";
|
||||
const description = "Create a custom RSS feed for your favorite comics";
|
||||
---
|
||||
|
||||
<Layout title={title} description={description}>
|
||||
<main class="mx-auto px-4 sm:px-6 lg:px-8 max-w-[800px] py-8">
|
||||
<h1 class="text-4xl font-bold text-center mb-8">Custom RSS Feed</h1>
|
||||
|
||||
<div class="bg-secondary/50 p-6 rounded-lg shadow-lg">
|
||||
<SlugInput />
|
||||
</div>
|
||||
|
||||
<div class="mt-8 text-center text-primary/60">
|
||||
<p>Add the comic slugs from the URLs of your favorite comics on ComicK.</p>
|
||||
<p class="mt-2">Example: For "https://comick.io/comic/01-one-piece", the slug is "01-one-piece"</p>
|
||||
</div>
|
||||
</main>
|
||||
</Layout>
|
||||
36
src/pages/rss/custom/[slugs].xml.ts
Normal file
36
src/pages/rss/custom/[slugs].xml.ts
Normal file
|
|
@ -0,0 +1,36 @@
|
|||
import rss from "@astrojs/rss";
|
||||
import { getChaptersForSlugs, isValidLanguage } from "../../../lib/api";
|
||||
import type { APIRoute } from "astro";
|
||||
|
||||
export const GET: APIRoute = async ({ params, url }) => {
|
||||
const slugs = params.slugs?.split(',') || [];
|
||||
const lang = url.searchParams.get('lang') || 'en';
|
||||
|
||||
if (slugs.length === 0) {
|
||||
return new Response("No slugs provided", { status: 400 });
|
||||
}
|
||||
|
||||
if (!isValidLanguage(lang)) {
|
||||
return new Response("Invalid language", { status: 400 });
|
||||
}
|
||||
|
||||
console.log('Processing RSS request for slugs:', slugs, 'in language:', lang);
|
||||
const chapters = await getChaptersForSlugs(slugs, lang);
|
||||
|
||||
if (chapters.length === 0) {
|
||||
console.log('No chapters found for any of the provided slugs');
|
||||
return new Response("No chapters found for the provided comics", { status: 404 });
|
||||
}
|
||||
|
||||
return rss({
|
||||
title: `ComicK - Custom Feed (${lang.toUpperCase()})`,
|
||||
description: `Custom RSS feed for selected comics: ${slugs.join(', ')}`,
|
||||
site: "https://github.com/ld3z/manga-rss",
|
||||
items: chapters.map((chapter) => ({
|
||||
title: `${chapter.md_comics.title} - Chapter ${chapter.chap}`,
|
||||
link: `https://comick.io/comic/${chapter.md_comics.slug}`,
|
||||
pubDate: new Date(chapter.updated_at),
|
||||
description: `New chapter available: Chapter ${chapter.chap}`,
|
||||
})),
|
||||
});
|
||||
};
|
||||
Loading…
Add table
Add a link
Reference in a new issue