diff --git a/_data/cv.js b/_data/cv.js index 10f0e8e..81b9472 100644 --- a/_data/cv.js +++ b/_data/cv.js @@ -1,23 +1,10 @@ /** - * CV Data - * - * API-first for split backend/frontend deployments: - * - Try Indiekit public API (`/cvapi/data.json`, fallback `/cv/data.json`) - * - Fallback to local plugin file (`content/.indiekit/cv.json`) - * - * Returns empty defaults if neither source is available. + * CV Data — static mode + * Edit cvStatic.js to update CV content. */ -import EleventyFetch from "@11ty/eleventy-fetch"; -import { readFileSync } from "node:fs"; -import { resolve, dirname } from "node:path"; -import { fileURLToPath } from "node:url"; import cvStatic from "./cvStatic.js"; -const __dirname = dirname(fileURLToPath(import.meta.url)); -const INDIEKIT_URL = - process.env.INDIEKIT_URL || process.env.SITE_URL || "https://example.com"; - const EMPTY_CV = { lastUpdated: null, experience: [], @@ -30,55 +17,6 @@ const EMPTY_CV = { interestTypes: {}, }; -async function fetchFromIndiekit(path) { - const urls = [ - `${INDIEKIT_URL}/cvapi/${path}`, - `${INDIEKIT_URL}/cv/${path}`, - ]; - - for (const url of urls) { - try { - console.log(`[cv] Fetching from Indiekit: ${url}`); - const data = await EleventyFetch(url, { - duration: "15m", - type: "json", - }); - console.log(`[cv] Indiekit ${path} success via ${url}`); - return data; - } catch (error) { - console.log(`[cv] Indiekit API unavailable at ${url}: ${error.message}`); - } - } - - return null; -} - -function readLocalCvFile() { - try { - const cvPath = resolve(__dirname, "..", "content", ".indiekit", "cv.json"); - const raw = readFileSync(cvPath, "utf8"); - const data = JSON.parse(raw); - console.log("[cv] Loaded CV data from local plugin file"); - return data; - } catch { - return null; - } -} - -export default async function () { - const apiData = await fetchFromIndiekit("data.json"); - if (apiData && typeof apiData === "object") { - return { ...EMPTY_CV, ...apiData }; - } - - const localData = readLocalCvFile(); - if (localData && typeof localData === "object") { - return { ...EMPTY_CV, ...localData }; - } - - if (cvStatic && typeof cvStatic === "object") { - return { ...EMPTY_CV, ...cvStatic }; - } - - return EMPTY_CV; +export default function () { + return { ...EMPTY_CV, ...cvStatic }; } diff --git a/_data/cvPageConfig.js b/_data/cvPageConfig.js index 0776008..9ee5db1 100644 --- a/_data/cvPageConfig.js +++ b/_data/cvPageConfig.js @@ -1,80 +1,10 @@ /** - * CV Page Configuration Data - * - * API-first for split backend/frontend deployments: - * - Try Indiekit public API (`/cvapi/page.json`, fallback `/cv/page.json`) - * - Fallback to local plugin file (`content/.indiekit/cv-page.json`) - * - * Falls back to null so cv.njk can use the hardcoded default layout. + * CV Page Configuration — static mode + * Edit cvPageConfigStatic.js to customize layout, or keep null for the default. */ -import EleventyFetch from "@11ty/eleventy-fetch"; -import { readFileSync } from "node:fs"; -import { resolve, dirname } from "node:path"; -import { fileURLToPath } from "node:url"; import cvPageConfigStatic from "./cvPageConfigStatic.js"; -const __dirname = dirname(fileURLToPath(import.meta.url)); -const INDIEKIT_URL = - process.env.INDIEKIT_URL || process.env.SITE_URL || "https://example.com"; - -async function fetchFromIndiekit(path) { - const urls = [ - `${INDIEKIT_URL}/cvapi/${path}`, - `${INDIEKIT_URL}/cv/${path}`, - ]; - - for (const url of urls) { - try { - console.log(`[cvPageConfig] Fetching from Indiekit: ${url}`); - const data = await EleventyFetch(url, { - duration: "15m", - type: "json", - }); - console.log(`[cvPageConfig] Indiekit ${path} success via ${url}`); - return data; - } catch (error) { - console.log( - `[cvPageConfig] Indiekit API unavailable at ${url}: ${error.message}` - ); - } - } - - return null; -} - -function readLocalConfigFile() { - try { - const configPath = resolve( - __dirname, - "..", - "content", - ".indiekit", - "cv-page.json" - ); - const raw = readFileSync(configPath, "utf8"); - const config = JSON.parse(raw); - console.log("[cvPageConfig] Loaded local CV page builder config"); - return config; - } catch { - return null; - } -} - -export default async function () { - const apiConfig = await fetchFromIndiekit("page.json"); - if (apiConfig && typeof apiConfig === "object") { - return apiConfig; - } - - const localConfig = readLocalConfigFile(); - if (localConfig && typeof localConfig === "object") { - return localConfig; - } - - if (cvPageConfigStatic && typeof cvPageConfigStatic === "object") { - return cvPageConfigStatic; - } - - return null; +export default function () { + return cvPageConfigStatic; }