chore: switch GitHub widget and changelog to Gitea
- Sidebar "GitHub" widget renamed to "Gitea", links point to gitea.giersig.eu/giersig.eu - Runtime widget JS fetches commits/repos/PRs directly from Gitea API - Build-time data files (githubActivity, githubRepos) switched from GitHub API to Gitea API - changelog.njk fetches from Gitea API directly with client-side commit categorisation - GITEA_URL / GITEA_ORG added to deploy.yml build env Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -1,48 +1,41 @@
|
||||
/**
|
||||
* GitHub Repos Data
|
||||
* Fetches public repositories from GitHub API
|
||||
* Gitea Repos Data
|
||||
* Fetches public repositories from Gitea org API
|
||||
*/
|
||||
|
||||
import { cachedFetch } from "../lib/data-fetch.js";
|
||||
|
||||
export default async function () {
|
||||
const username = process.env.GITHUB_USERNAME || "";
|
||||
const GITEA_URL = process.env.GITEA_URL || "https://gitea.giersig.eu";
|
||||
const GITEA_ORG = process.env.GITEA_ORG || "giersig.eu";
|
||||
|
||||
export default async function () {
|
||||
try {
|
||||
// Fetch public repos, sorted by updated date
|
||||
const url = `https://api.github.com/users/${username}/repos?sort=updated&per_page=10&type=owner`;
|
||||
const url = `${GITEA_URL}/api/v1/orgs/${GITEA_ORG}/repos?limit=10&sort=newest`;
|
||||
|
||||
const repos = await cachedFetch(url, {
|
||||
duration: "1h", // Cache for 1 hour
|
||||
duration: "1h",
|
||||
type: "json",
|
||||
fetchOptions: {
|
||||
headers: {
|
||||
Accept: "application/vnd.github.v3+json",
|
||||
"User-Agent": "Eleventy-Site",
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
// Filter and transform repos
|
||||
return repos
|
||||
.filter((repo) => !repo.fork && !repo.private) // Exclude forks and private repos
|
||||
.filter((repo) => !repo.fork && !repo.private)
|
||||
.map((repo) => ({
|
||||
name: repo.name,
|
||||
full_name: repo.full_name,
|
||||
description: repo.description,
|
||||
html_url: repo.html_url,
|
||||
homepage: repo.homepage,
|
||||
homepage: repo.website || repo.homepage,
|
||||
language: repo.language,
|
||||
stargazers_count: repo.stargazers_count,
|
||||
forks_count: repo.forks_count,
|
||||
open_issues_count: repo.open_issues_count,
|
||||
stargazers_count: repo.stars_count || repo.stargazers_count || 0,
|
||||
forks_count: repo.forks_count || 0,
|
||||
open_issues_count: repo.open_issues_count || 0,
|
||||
topics: repo.topics || [],
|
||||
updated_at: repo.updated_at,
|
||||
created_at: repo.created_at,
|
||||
updated_at: repo.updated,
|
||||
created_at: repo.created,
|
||||
}))
|
||||
.slice(0, 10); // Limit to 10 repos
|
||||
.slice(0, 10);
|
||||
} catch (error) {
|
||||
console.error("Error fetching GitHub repos:", error.message);
|
||||
console.error("Error fetching Gitea repos:", error.message);
|
||||
return [];
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user