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 <noreply@anthropic.com>
This commit is contained in:
Ricardo
2026-02-09 10:55:22 +01:00
parent 523f538d1b
commit 7004dbc4f1
+30 -16
View File
@@ -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 * The CV plugin writes content/.indiekit/cv.json on every save
* via its API endpoint and the homepage plugin renders it. * and on startup. Eleventy reads that file here.
* *
* Without the plugin, users can edit this file directly: * Falls back to empty defaults if no plugin is installed.
* - Add entries to the `experience` array
* - Add entries to the `projects` array
* - Modify the `skills` object
*/ */
export default { import { readFileSync } from "node:fs";
lastUpdated: null, import { resolve, dirname } from "node:path";
experience: [], import { fileURLToPath } from "node:url";
projects: [],
skills: {}, const __dirname = dirname(fileURLToPath(import.meta.url));
languages: [],
education: [], export default function () {
interests: [], 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: [],
};
}
}