From 7004dbc4f11f370a7db3924e63cab17f4489e049 Mon Sep 17 00:00:00 2001 From: Ricardo Date: Mon, 9 Feb 2026 10:55:22 +0100 Subject: [PATCH] feat: read CV data from plugin file instead of hardcoded defaults _data/cv.js now reads from content/.indiekit/cv.json written by the CV plugin, matching the homepageConfig.js pattern. Falls back to empty defaults when no plugin is installed. Co-Authored-By: Claude Opus 4.6 --- _data/cv.js | 46 ++++++++++++++++++++++++++++++---------------- 1 file changed, 30 insertions(+), 16 deletions(-) diff --git a/_data/cv.js b/_data/cv.js index 2dda1e2..1d48dc5 100644 --- a/_data/cv.js +++ b/_data/cv.js @@ -1,21 +1,35 @@ /** - * CV Data — Empty defaults. + * CV Data — reads from indiekit-endpoint-cv plugin data file. * - * When the indiekit-endpoint-cv plugin is installed, it serves CV data - * via its API endpoint and the homepage plugin renders it. + * The CV plugin writes content/.indiekit/cv.json on every save + * and on startup. Eleventy reads that file here. * - * Without the plugin, users can edit this file directly: - * - Add entries to the `experience` array - * - Add entries to the `projects` array - * - Modify the `skills` object + * Falls back to empty defaults if no plugin is installed. */ -export default { - lastUpdated: null, - experience: [], - projects: [], - skills: {}, - languages: [], - education: [], - interests: [], -}; +import { readFileSync } from "node:fs"; +import { resolve, dirname } from "node:path"; +import { fileURLToPath } from "node:url"; + +const __dirname = dirname(fileURLToPath(import.meta.url)); + +export default function () { + 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 plugin"); + return data; + } catch { + // No CV plugin data file — return empty defaults + return { + lastUpdated: null, + experience: [], + projects: [], + skills: {}, + languages: [], + education: [], + interests: [], + }; + } +}