debug: inline ogSlug computation + debug comment to diagnose race condition

Computes ogSlug using inline Nunjucks string ops instead of filter call.
Adds HTML debug comment showing page.url, permalink, and computed ogSlug
to diagnose Eleventy 3.x parallel rendering race condition.
This commit is contained in:
Ricardo
2026-02-24 19:39:59 +01:00
parent ad8af6f027
commit 520bc5f582
+10 -6
View File
@@ -23,13 +23,17 @@
<meta property="og:type" content="{% if page.url == '/' %}website{% else %}article{% endif %}">
<meta property="og:description" content="{{ ogDesc }}">
<meta name="description" content="{{ ogDesc }}">
{# Compute OG slug from page.url — NOT permalink or eleventyComputed values.
Eleventy 3.x parallel rendering (issue #3183) cross-contaminates eleventyComputed
return values across pages. permalink is set by eleventyComputed and is UNRELIABLE.
page.url is set by Eleventy's internal pipeline and IS correct in templates
(verified: og:url uses page.url and always shows the right URL). #}
{% set _ogSlug = page.url | ogSlug %}
{# Compute OG slug inline from page.url using string ops — avoid filter calls
which may be affected by Eleventy 3.x parallel rendering race conditions.
page.url is correct (verified via og:url), compute slug inline. #}
{% set _urlParts = page.url.split('/') | reject("equalto", "") | list %}
{% if _urlParts | length >= 5 %}
{% set _ogSlug = _urlParts[1] + '-' + _urlParts[2] + '-' + _urlParts[3] + '-' + _urlParts[4] %}
{% else %}
{% set _ogSlug = _urlParts | last | default("") %}
{% endif %}
{% set _hasOg = _ogSlug | hasOgImage %}
<!-- debug:og page.url={{ page.url }} permalink={{ permalink }} ogSlug={{ _ogSlug }} -->
{% if ogPhoto and ogPhoto != "" and (ogPhoto | length) > 10 %}
<meta property="og:image" content="{% if 'http' in ogPhoto %}{{ ogPhoto }}{% else %}{{ site.url }}{% if ogPhoto[0] != '/' %}/{% endif %}{{ ogPhoto }}{% endif %}">
{% elif image and image != "" and (image | length) > 10 %}