Fix GitHub widget/data endpoints to prefer /github/api routes
This commit is contained in:
@@ -16,21 +16,28 @@ const FALLBACK_FEATURED_REPOS = process.env.GITHUB_FEATURED_REPOS?.split(",").fi
|
||||
* Fetch from Indiekit's public GitHub API endpoint
|
||||
*/
|
||||
async function fetchFromIndiekit(endpoint) {
|
||||
try {
|
||||
const url = `${INDIEKIT_URL}/githubapi/api/${endpoint}`;
|
||||
console.log(`[githubActivity] Fetching from Indiekit: ${url}`);
|
||||
const data = await EleventyFetch(url, {
|
||||
duration: "15m",
|
||||
type: "json",
|
||||
});
|
||||
console.log(`[githubActivity] Indiekit ${endpoint} success`);
|
||||
return data;
|
||||
} catch (error) {
|
||||
console.log(
|
||||
`[githubActivity] Indiekit API unavailable for ${endpoint}: ${error.message}`
|
||||
);
|
||||
return null;
|
||||
const urls = [
|
||||
`${INDIEKIT_URL}/github/api/${endpoint}`,
|
||||
`${INDIEKIT_URL}/githubapi/api/${endpoint}`,
|
||||
];
|
||||
|
||||
for (const url of urls) {
|
||||
try {
|
||||
console.log(`[githubActivity] Fetching from Indiekit: ${url}`);
|
||||
const data = await EleventyFetch(url, {
|
||||
duration: "15m",
|
||||
type: "json",
|
||||
});
|
||||
console.log(`[githubActivity] Indiekit ${endpoint} success via ${url}`);
|
||||
return data;
|
||||
} catch (error) {
|
||||
console.log(
|
||||
`[githubActivity] Indiekit API unavailable for ${endpoint} at ${url}: ${error.message}`
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -12,16 +12,28 @@ const INDIEKIT_URL = process.env.SITE_URL || "https://example.com";
|
||||
|
||||
export default async function () {
|
||||
try {
|
||||
const url = `${INDIEKIT_URL}/githubapi/api/starred/all`;
|
||||
const response = await EleventyFetch(url, {
|
||||
duration: "15m",
|
||||
type: "json",
|
||||
});
|
||||
const urls = [
|
||||
`${INDIEKIT_URL}/github/api/starred/all`,
|
||||
`${INDIEKIT_URL}/githubapi/api/starred/all`,
|
||||
];
|
||||
|
||||
return {
|
||||
totalCount: response.totalCount || 0,
|
||||
buildDate: new Date().toISOString(),
|
||||
};
|
||||
for (const url of urls) {
|
||||
try {
|
||||
const response = await EleventyFetch(url, {
|
||||
duration: "15m",
|
||||
type: "json",
|
||||
});
|
||||
|
||||
return {
|
||||
totalCount: response.totalCount || 0,
|
||||
buildDate: new Date().toISOString(),
|
||||
};
|
||||
} catch (error) {
|
||||
console.log(`[githubStarred] Could not fetch ${url}: ${error.message}`);
|
||||
}
|
||||
}
|
||||
|
||||
throw new Error("No GitHub starred endpoint responded");
|
||||
} catch (error) {
|
||||
console.log(`[githubStarred] Could not fetch starred count: ${error.message}`);
|
||||
return {
|
||||
|
||||
Reference in New Issue
Block a user