diff --git a/eleventy.config.js b/eleventy.config.js index d0f4de8..1617781 100644 --- a/eleventy.config.js +++ b/eleventy.config.js @@ -344,11 +344,7 @@ export default function (eleventyConfig) { eleventyConfig.addFilter("hasOgImage", (fileSlug) => { if (!fileSlug) return false; const ogPath = resolve(__dirname, ".cache", "og", `${fileSlug}.png`); - const exists = existsSync(ogPath); - if (!exists && fileSlug.includes("quand-un-oui")) { - console.log(`[og-debug] fileSlug=${fileSlug}, path=${ogPath}, exists=${exists}`); - } - return exists; + return existsSync(ogPath); }); // Current timestamp filter (for client-side JS buildtime) diff --git a/lib/og.js b/lib/og.js index 59fefc1..dd672ae 100644 --- a/lib/og.js +++ b/lib/og.js @@ -105,6 +105,14 @@ function formatDate(dateStr) { } } +/** + * Strip YYYY-MM-DD- date prefix from filename to match Eleventy's page.fileSlug. + * Eleventy v3 parses dates from filenames and removes the prefix from fileSlug. + */ +function toEleventySlug(filename) { + return filename.replace(/^\d{4}-\d{2}-\d{2}-/, ""); +} + function truncateTitle(title, max = 120) { if (!title || title.length <= max) return title || "Untitled"; return title.slice(0, max).trim() + "\u2026"; @@ -299,7 +307,7 @@ export async function generateOgImages(contentDir, cacheDir, siteName) { continue; } - const slug = basename(filePath, ".md"); + const slug = toEleventySlug(basename(filePath, ".md")); const title = fm.title || fm.name || extractBodyText(raw); const date = fm.published || fm.date || ""; const postType = detectPostType(filePath);