Files
indiekit-blog/_data/homepageConfig.js
Ricardo bada61e2e4 fix: resolve homepage.json via content/ symlink instead of absolute path
CONTENT_DIR env var wasn't set on Cloudron, so the data file tried
/data/content/.indiekit/homepage.json which doesn't exist. Now resolves
relative to the Eleventy project dir through the content/ symlink.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-08 17:10:28 +01:00

30 lines
1.0 KiB
JavaScript

/**
* Homepage Configuration Data
* Reads config from indiekit-endpoint-homepage plugin (when installed).
* Falls back to null — home.njk then uses the default layout.
*
* Future: The homepage plugin will write a .indiekit/homepage.json file
* that Eleventy watches. On change, a rebuild picks up the new config,
* allowing layout changes without a Docker rebuild.
*/
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 {
// Resolve via the content/ symlink relative to the Eleventy project
const configPath = resolve(__dirname, "..", "content", ".indiekit", "homepage.json");
const raw = readFileSync(configPath, "utf8");
const config = JSON.parse(raw);
console.log("[homepageConfig] Loaded plugin config");
return config;
} catch {
// No homepage plugin config — this is the normal case for most deployments
return null;
}
}