mirror of
https://github.com/svemagie/blog-eleventy-indiekit.git
synced 2026-04-02 16:44:56 +02:00
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:
30
_data/cv.js
30
_data/cv.js
@@ -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
|
||||
* 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 {
|
||||
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: [],
|
||||
@@ -19,3 +31,5 @@ export default {
|
||||
education: [],
|
||||
interests: [],
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user