Initial commit: fristy.net personal site
This commit is contained in:
56 files changed
+6038
No files matched your search
@@ -0,0 +1,61 @@
|
||||
const GITEA_API = "https://git.fristy.net/api/v1";
|
||||
const GITEA_USER = "fristy";
|
||||
|
||||
const EXCLUDED_REPOS = new Set([".profile"]);
|
||||
|
||||
export interface GiteaRepo {
|
||||
id: number;
|
||||
name: string;
|
||||
fullName: string;
|
||||
description: string | null;
|
||||
language: string | null;
|
||||
htmlUrl: string;
|
||||
website: string | null;
|
||||
stars: number;
|
||||
forks: number;
|
||||
updatedAt: string;
|
||||
}
|
||||
|
||||
interface GiteaApiRepo {
|
||||
id: number;
|
||||
name: string;
|
||||
full_name: string;
|
||||
description: string | null;
|
||||
language: string | null;
|
||||
html_url: string;
|
||||
website: string;
|
||||
stars_count: number;
|
||||
forks_count: number;
|
||||
updated_at: string;
|
||||
}
|
||||
|
||||
export async function getRepos(): Promise<GiteaRepo[]> {
|
||||
try {
|
||||
const response = await fetch(
|
||||
`${GITEA_API}/users/${GITEA_USER}/repos?limit=50&sort=updated&order=desc`,
|
||||
{ next: { revalidate: 3600 } },
|
||||
);
|
||||
if (!response.ok) {
|
||||
console.error(`cannot fetch gitea repos: ${response.status}`);
|
||||
return [];
|
||||
}
|
||||
const data = (await response.json()) as GiteaApiRepo[];
|
||||
return data
|
||||
.filter((repo) => !EXCLUDED_REPOS.has(repo.name))
|
||||
.map((repo) => ({
|
||||
id: repo.id,
|
||||
name: repo.name,
|
||||
fullName: repo.full_name,
|
||||
description: repo.description,
|
||||
language: repo.language,
|
||||
htmlUrl: repo.html_url,
|
||||
website: repo.website || null,
|
||||
stars: repo.stars_count,
|
||||
forks: repo.forks_count,
|
||||
updatedAt: repo.updated_at,
|
||||
}));
|
||||
} catch (error) {
|
||||
console.error("cannot fetch gitea repos:", error);
|
||||
return [];
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user