This repository has been archived on 2026-10-04. You can view files and clone it. You cannot open issues or pull requests or push a commit.
Files
webklar-alt/src/lib/projects.ts
T
rootandClaude Opus 5 d12fa7d04f Projekte-Abschnitt zurück auf die alte Darstellung
Die Live-Kachelansicht aller Gitea-Repositories ist nicht gewollt: der
Abschnitt "Projekte" zeigt wieder die kuratierte Liste wie zuvor.

Dynamisch bleibt allein der Projektzähler im Hero – lib/projects.ts ist
deshalb auf fetchProjects + Snapshot-Typ eingedampft, ProjectCard.tsx
entfällt.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-08-06 21:14:11 +00:00

29 lines
1.2 KiB
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
/**
* Live-Projektzahl für die Statistik-Zeile im Hero.
*
* Quelle: GET /api/projects (contact-api-Container) – zählt serverseitig die
* Repositories, die aktuell in Gitea (git.webklar.com) liegen, angereichert um
* die Hosting-Metadaten aus Appwrite. Der Gitea-Token bleibt dadurch auf dem
* Server. Die Antwort enthält mehr Felder als hier genutzt werden; für die
* Homepage ist nur `total` relevant.
*/
export type ProjectsSnapshot = {
/** Zeitpunkt, zu dem der Server-Snapshot erzeugt wurde (ISO) */
generatedAt: string;
/** Anzahl der Repositories, die aktuell in Gitea existieren */
total: number;
counts: Record<string, number>;
source: string;
};
const API_URL = import.meta.env.VITE_PROJECTS_API ?? "/api/projects";
export async function fetchProjects(signal?: AbortSignal): Promise<ProjectsSnapshot> {
const res = await fetch(API_URL, { signal, headers: { Accept: "application/json" } });
if (!res.ok) throw new Error(`Projektzahl konnte nicht geladen werden (HTTP ${res.status})`);
const data = (await res.json()) as ProjectsSnapshot;
if (typeof data?.total !== "number") throw new Error("Unerwartete Antwort der Projekt-API");
return data;
}