init site

This commit is contained in:
ld3zian 2025-01-13 17:44:11 -07:00
parent 40a7e60a8b
commit c765ca9c85
20 changed files with 6860 additions and 1 deletions

View file

@ -0,0 +1,125 @@
---
import Layout from '../../layouts/Layout.astro';
import ComicCard from '../../components/ComicCard.astro';
import LanguageSelector from '../../components/LanguageSelector.astro';
import RSSLink from '../../components/RSSLink.astro';
import { fetchComics, isValidLanguage, isValidContentType } from '../../lib/api';
import type { Comic } from '../../lib/types';
export async function getStaticPaths() {
const languages = ['en', 'fr', 'es', 'it', 'pl', 'tr', 'ja', 'zh', 'sv'];
const types = ['sfw', 'nsfw'];
return languages.flatMap(lang =>
types.map(type => ({
params: { lang, type },
}))
);
}
const { lang, type } = Astro.params;
if (!isValidLanguage(lang!) || !isValidContentType(type!)) {
return Astro.redirect('/en/sfw');
}
let comics: Comic[] = [];
let error: string | null = null;
try {
comics = await fetchComics(lang, type);
console.log(`Fetched ${comics.length} comics`); // Debug log
} catch (e) {
console.error('Failed to fetch comics:', e);
error = e instanceof Error ? e.message : 'Failed to fetch comics';
}
---
<Layout title={`Comick - ${lang?.toUpperCase()} ${type?.toUpperCase()}`}>
<main>
<h1>ComicK-RSS</h1>
<div class="controls">
<LanguageSelector currentLang={lang!} currentType={type!} />
<RSSLink lang={lang!} type={type!} />
</div>
{error && (
<div class="error-message">
<p>Error: {error}</p>
</div>
)}
{comics.length > 0 ? (
<div class="comics-grid">
{comics.map(comic => (
<ComicCard comic={comic} />
))}
</div>
) : (
<div class="no-comics">
<p>No comics found. Please try a different language or content type.</p>
<p class="debug-info">Language: {lang}, Type: {type}</p>
</div>
)}
</main>
</Layout>
<style>
main {
margin: auto;
padding: 1rem;
width: 1200px;
max-width: calc(100% - 2rem);
color: white;
font-size: 20px;
line-height: 1.6;
}
.controls {
display: flex;
justify-content: space-between;
align-items: center;
margin-bottom: 2rem;
}
h1 {
font-size: 3rem;
font-weight: 700;
line-height: 1;
text-align: center;
margin-bottom: 1em;
background-image: var(--accent-gradient);
-webkit-background-clip: text;
-webkit-text-fill-color: transparent;
background-size: 400%;
background-position: 0%;
}
.comics-grid {
display: grid;
grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
gap: 2rem;
padding: 0;
}
.no-comics {
text-align: center;
padding: 2rem;
background: #23262d;
border-radius: 8px;
}
.error-message {
background: #ff4444;
color: white;
padding: 1rem;
border-radius: 8px;
margin-bottom: 2rem;
}
.debug-info {
font-size: 0.8rem;
color: #666;
margin-top: 1rem;
}
</style>

5
src/pages/index.astro Normal file
View file

@ -0,0 +1,5 @@
---
export const prerender = false;
---
<meta http-equiv="refresh" content="0;url=/en/sfw">

View file

@ -0,0 +1,63 @@
import rss from "@astrojs/rss";
import {
fetchComics,
isValidLanguage,
isValidContentType,
} from "../../../lib/api";
import type { APIRoute } from "astro";
export const GET: APIRoute = async ({ params, request }) => {
const { lang = "en", type = "sfw" } = params;
if (!isValidLanguage(lang) || !isValidContentType(type)) {
return new Response("Invalid language or content type", { status: 400 });
}
const comics = await fetchComics(lang, type);
const siteURL = new URL(request.url).origin;
return rss({
title: `ComicK - ${lang.toUpperCase()} ${type.toUpperCase()}`,
description: `A simple RSS feed for ComicK!`,
site: "https://github.com/ld3z/manga-rss",
items: comics.map((comic) => ({
title: `<![CDATA[${comic.md_comics.title} - Chapter ${comic.chap}]]`,
link: `https://comick.io/comic/${comic.md_comics.slug}`,
pubDate: new Date(comic.updated_at),
description: `<![CDATA[Chapter ${comic.chap} of ${
comic.md_comics.title
} is now available on ComicK!
${
comic.md_comics.md_covers[0]
? `<img src="https://meo.comick.pictures/${comic.md_comics.md_covers[0].b2key}"
alt="Cover" style="max-width: 300px;" />]]`
: ""
}
`,
})),
});
};
export function getStaticPaths() {
return [
{ params: { lang: "en", type: "sfw" } },
{ params: { lang: "en", type: "nsfw" } },
{ params: { lang: "fr", type: "sfw" } },
{ params: { lang: "fr", type: "nsfw" } },
{ params: { lang: "es", type: "nsfw" } },
{ params: { lang: "es", type: "sfw" } },
{ params: { lang: "it", type: "sfw" } },
{ params: { lang: "it", type: "nsfw" } },
{ params: { lang: "pl", type: "sfw" } },
{ params: { lang: "pl", type: "nsfw" } },
{ params: { lang: "tr", type: "sfw" } },
{ params: { lang: "tr", type: "nsfw" } },
{ params: { lang: "ja", type: "sfw" } },
{ params: { lang: "ja", type: "nsfw" } },
{ params: { lang: "zh", type: "sfw" } },
{ params: { lang: "zh", type: "nsfw" } },
{ params: { lang: "sv", type: "sfw" } },
{ params: { lang: "sv", type: "nsfw" } },
// Add other combinations as needed
];
}