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:
+23
-9
@@ -1,16 +1,28 @@
|
|||||||
/**
|
/**
|
||||||
* 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";
|
||||||
|
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,
|
lastUpdated: null,
|
||||||
experience: [],
|
experience: [],
|
||||||
projects: [],
|
projects: [],
|
||||||
@@ -18,4 +30,6 @@ export default {
|
|||||||
languages: [],
|
languages: [],
|
||||||
education: [],
|
education: [],
|
||||||
interests: [],
|
interests: [],
|
||||||
};
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user