diff --git a/_data/funkwhaleActivity.js b/_data/funkwhaleActivity.js index 316aeb4..4824942 100644 --- a/_data/funkwhaleActivity.js +++ b/_data/funkwhaleActivity.js @@ -5,28 +5,36 @@ import EleventyFetch from "@11ty/eleventy-fetch"; -const INDIEKIT_URL = process.env.SITE_URL || "https://example.com"; +const INDIEKIT_URL = + process.env.INDIEKIT_URL || process.env.SITE_URL || "https://example.com"; const FUNKWHALE_INSTANCE = process.env.FUNKWHALE_INSTANCE || ""; /** * Fetch from Indiekit's public Funkwhale API endpoint */ async function fetchFromIndiekit(endpoint) { - try { - const url = `${INDIEKIT_URL}/funkwhaleapi/api/${endpoint}`; - console.log(`[funkwhaleActivity] Fetching from Indiekit: ${url}`); - const data = await EleventyFetch(url, { - duration: "15m", - type: "json", - }); - console.log(`[funkwhaleActivity] Indiekit ${endpoint} success`); - return data; - } catch (error) { - console.log( - `[funkwhaleActivity] Indiekit API unavailable for ${endpoint}: ${error.message}` - ); - return null; + const urls = [ + `${INDIEKIT_URL}/funkwhale/api/${endpoint}`, + `${INDIEKIT_URL}/funkwhaleapi/api/${endpoint}`, + ]; + + for (const url of urls) { + try { + console.log(`[funkwhaleActivity] Fetching from Indiekit: ${url}`); + const data = await EleventyFetch(url, { + duration: "15m", + type: "json", + }); + console.log(`[funkwhaleActivity] Indiekit ${endpoint} success via ${url}`); + return data; + } catch (error) { + console.log( + `[funkwhaleActivity] Indiekit API unavailable for ${endpoint} at ${url}: ${error.message}` + ); + } } + + return null; } /** diff --git a/_data/lastfmActivity.js b/_data/lastfmActivity.js index d7dd837..f64aa36 100644 --- a/_data/lastfmActivity.js +++ b/_data/lastfmActivity.js @@ -5,28 +5,36 @@ import EleventyFetch from "@11ty/eleventy-fetch"; -const INDIEKIT_URL = process.env.SITE_URL || "https://example.com"; +const INDIEKIT_URL = + process.env.INDIEKIT_URL || process.env.SITE_URL || "https://example.com"; const LASTFM_USERNAME = process.env.LASTFM_USERNAME || ""; /** * Fetch from Indiekit's public Last.fm API endpoint */ async function fetchFromIndiekit(endpoint) { - try { - const url = `${INDIEKIT_URL}/lastfmapi/api/${endpoint}`; - console.log(`[lastfmActivity] Fetching from Indiekit: ${url}`); - const data = await EleventyFetch(url, { - duration: "15m", - type: "json", - }); - console.log(`[lastfmActivity] Indiekit ${endpoint} success`); - return data; - } catch (error) { - console.log( - `[lastfmActivity] Indiekit API unavailable for ${endpoint}: ${error.message}` - ); - return null; + const urls = [ + `${INDIEKIT_URL}/lastfmapi/api/${endpoint}`, + `${INDIEKIT_URL}/lastfm/api/${endpoint}`, + ]; + + for (const url of urls) { + try { + console.log(`[lastfmActivity] Fetching from Indiekit: ${url}`); + const data = await EleventyFetch(url, { + duration: "15m", + type: "json", + }); + console.log(`[lastfmActivity] Indiekit ${endpoint} success via ${url}`); + return data; + } catch (error) { + console.log( + `[lastfmActivity] Indiekit API unavailable for ${endpoint} at ${url}: ${error.message}` + ); + } } + + return null; } export default async function () { diff --git a/theme/_data/funkwhaleActivity.js b/theme/_data/funkwhaleActivity.js index 316aeb4..4824942 100644 --- a/theme/_data/funkwhaleActivity.js +++ b/theme/_data/funkwhaleActivity.js @@ -5,28 +5,36 @@ import EleventyFetch from "@11ty/eleventy-fetch"; -const INDIEKIT_URL = process.env.SITE_URL || "https://example.com"; +const INDIEKIT_URL = + process.env.INDIEKIT_URL || process.env.SITE_URL || "https://example.com"; const FUNKWHALE_INSTANCE = process.env.FUNKWHALE_INSTANCE || ""; /** * Fetch from Indiekit's public Funkwhale API endpoint */ async function fetchFromIndiekit(endpoint) { - try { - const url = `${INDIEKIT_URL}/funkwhaleapi/api/${endpoint}`; - console.log(`[funkwhaleActivity] Fetching from Indiekit: ${url}`); - const data = await EleventyFetch(url, { - duration: "15m", - type: "json", - }); - console.log(`[funkwhaleActivity] Indiekit ${endpoint} success`); - return data; - } catch (error) { - console.log( - `[funkwhaleActivity] Indiekit API unavailable for ${endpoint}: ${error.message}` - ); - return null; + const urls = [ + `${INDIEKIT_URL}/funkwhale/api/${endpoint}`, + `${INDIEKIT_URL}/funkwhaleapi/api/${endpoint}`, + ]; + + for (const url of urls) { + try { + console.log(`[funkwhaleActivity] Fetching from Indiekit: ${url}`); + const data = await EleventyFetch(url, { + duration: "15m", + type: "json", + }); + console.log(`[funkwhaleActivity] Indiekit ${endpoint} success via ${url}`); + return data; + } catch (error) { + console.log( + `[funkwhaleActivity] Indiekit API unavailable for ${endpoint} at ${url}: ${error.message}` + ); + } } + + return null; } /** diff --git a/theme/_data/lastfmActivity.js b/theme/_data/lastfmActivity.js index d7dd837..f64aa36 100644 --- a/theme/_data/lastfmActivity.js +++ b/theme/_data/lastfmActivity.js @@ -5,28 +5,36 @@ import EleventyFetch from "@11ty/eleventy-fetch"; -const INDIEKIT_URL = process.env.SITE_URL || "https://example.com"; +const INDIEKIT_URL = + process.env.INDIEKIT_URL || process.env.SITE_URL || "https://example.com"; const LASTFM_USERNAME = process.env.LASTFM_USERNAME || ""; /** * Fetch from Indiekit's public Last.fm API endpoint */ async function fetchFromIndiekit(endpoint) { - try { - const url = `${INDIEKIT_URL}/lastfmapi/api/${endpoint}`; - console.log(`[lastfmActivity] Fetching from Indiekit: ${url}`); - const data = await EleventyFetch(url, { - duration: "15m", - type: "json", - }); - console.log(`[lastfmActivity] Indiekit ${endpoint} success`); - return data; - } catch (error) { - console.log( - `[lastfmActivity] Indiekit API unavailable for ${endpoint}: ${error.message}` - ); - return null; + const urls = [ + `${INDIEKIT_URL}/lastfmapi/api/${endpoint}`, + `${INDIEKIT_URL}/lastfm/api/${endpoint}`, + ]; + + for (const url of urls) { + try { + console.log(`[lastfmActivity] Fetching from Indiekit: ${url}`); + const data = await EleventyFetch(url, { + duration: "15m", + type: "json", + }); + console.log(`[lastfmActivity] Indiekit ${endpoint} success via ${url}`); + return data; + } catch (error) { + console.log( + `[lastfmActivity] Indiekit API unavailable for ${endpoint} at ${url}: ${error.message}` + ); + } } + + return null; } export default async function () {