fix: extractFirstImage matching x-bind:src from Alpine.js

The regex matched x-bind:src="comment.author.photo" from the comments
component, causing the literal string to appear in og:image meta tags.
Every Mastodon instance fetching OG data hit /comment.author.photo → 404.

Require whitespace before src= so only actual HTML src attributes match.
This commit is contained in:
Ricardo
2026-02-22 20:37:07 +01:00
parent 834fd2b927
commit c457eb6f04

View File

@@ -335,7 +335,7 @@ export default function (eleventyConfig) {
eleventyConfig.addFilter("extractFirstImage", (content) => {
if (!content) return null;
// Match all <img> tags, skip hidden ones and data URIs
const imgRegex = /<img[^>]+src=["']([^"']+)["'][^>]*>/gi;
const imgRegex = /<img[^>]*?\ssrc=["']([^"']+)["'][^>]*>/gi;
let match;
while ((match = imgRegex.exec(content)) !== null) {
const fullTag = match[0];