Files
blog-eleventy-indiekit/about.11tydata.js
Ricardo f03e48e4db fix: use 11tydata.js for conditional about page permalink
Using a JavaScript data file to return boolean false for permalink
when about.md exists, instead of trying to compute it in Nunjucks
which returns string "false" and causes errors.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-02 12:34:01 +01:00

22 lines
756 B
JavaScript

// Template data file for about.njk
// Dynamically sets permalink based on whether about.md exists in content/pages/
import { existsSync } from "fs";
import { resolve, dirname } from "path";
import { fileURLToPath } from "url";
const __dirname = dirname(fileURLToPath(import.meta.url));
export default function() {
// Check for about.md in content/pages/ directory
const aboutPath = resolve(__dirname, "content/pages/about.md");
const aboutExists = existsSync(aboutPath);
return {
// If about.md exists, disable this template's permalink
// If not, use /about/ as the permalink
permalink: aboutExists ? false : "/about/",
// Also exclude from collections if about.md exists
eleventyExcludeFromCollections: aboutExists
};
}