mirror of
https://github.com/svemagie/blog-eleventy-indiekit.git
synced 2026-04-02 16:44:56 +02:00
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>
30 lines
1.0 KiB
JavaScript
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;
|
|
}
|
|
}
|