diff --git a/eleventy.config.js b/eleventy.config.js index 4a1bb97..dc8545c 100644 --- a/eleventy.config.js +++ b/eleventy.config.js @@ -1364,6 +1364,21 @@ export default function (eleventyConfig) { return result; }); + // Find other published posts that share the same external target URL + // (repostOf, likeOf, bookmarkOf, inReplyTo). Used to cross-link related posts. + eleventyConfig.addFilter("sameTargetPosts", function (posts, targetUrl, currentUrl) { + if (!targetUrl) return []; + const norm = (u) => String(u).replace(/\/$/, ""); + const t = norm(targetUrl); + return (posts || []).filter((p) => { + if (norm(p.url) === norm(currentUrl)) return false; + const d = p.data; + return [d.repostOf, d.repost_of, d.likeOf, d.like_of, + d.bookmarkOf, d.bookmark_of, d.inReplyTo, d.in_reply_to] + .some((v) => v && norm(v) === t); + }); + }); + // Strip garden/* tags from a category list so they don't render as // plain category pills alongside the garden badge. eleventyConfig.addFilter("withoutGardenTags", (categories) => {