fix: exclude image links from See Also; show path-only for untitled URL fallbacks
Build & Deploy / build-and-deploy (push) Successful in 1m23s

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
svemagie
2026-04-10 10:25:41 +02:00
parent 2f2a0ada14
commit e4390db99e
2 changed files with 10 additions and 4 deletions
+3 -3
View File
@@ -141,14 +141,14 @@ withBlogSidebar: true
{% set _relPost = collections.posts | postByUrl(relUrl) %} {% set _relPost = collections.posts | postByUrl(relUrl) %}
<li> <li>
<a href="{{ relUrl }}" class="text-sm text-accent-700 dark:text-accent-300 hover:underline"> <a href="{{ relUrl }}" class="text-sm text-accent-700 dark:text-accent-300 hover:underline">
{{ (_relPost.data.title if _relPost else null) or relUrl }} {{ (_relPost.data.title if _relPost else null) or (relUrl | pathOnly) }}
</a> </a>
</li> </li>
{% endfor %} {% endfor %}
{% for stp in _sameTarget %} {% for stp in _sameTarget %}
<li> <li>
<a href="{{ stp.url }}" class="text-sm text-accent-700 dark:text-accent-300 hover:underline"> <a href="{{ stp.url }}" class="text-sm text-accent-700 dark:text-accent-300 hover:underline">
{{ stp.data.title or stp.url }} {{ stp.data.title or (stp.url | pathOnly) }}
</a> </a>
</li> </li>
{% endfor %} {% endfor %}
@@ -165,7 +165,7 @@ withBlogSidebar: true
{% for post in _backlinks %} {% for post in _backlinks %}
<li> <li>
<a href="{{ post.url }}" class="text-sm text-accent-700 dark:text-accent-300 hover:underline"> <a href="{{ post.url }}" class="text-sm text-accent-700 dark:text-accent-300 hover:underline">
{{ post.data.title or post.url }} {{ post.data.title or (post.url | pathOnly) }}
</a> </a>
</li> </li>
{% endfor %} {% endfor %}
+7 -1
View File
@@ -1357,13 +1357,19 @@ export default function (eleventyConfig) {
try { try {
const content = readFileSync(inputPath, "utf-8"); const content = readFileSync(inputPath, "utf-8");
const escaped = siteUrl.replace(/[.*+?^${}()|[\]\\]/g, "\\$&"); const escaped = siteUrl.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
const re = new RegExp(`\\]\\((${escaped}/[^)\\s]+)\\)`, "g"); const re = new RegExp(`(?<!!)\\]\\((${escaped}/[^)\\s]+)\\)`, "g");
let m; let m;
while ((m = re.exec(content)) !== null) add(m[1]); while ((m = re.exec(content)) !== null) add(m[1]);
} catch { /* ignore */ } } catch { /* ignore */ }
return result; return result;
}); });
// Strip origin from a URL, returning just the path (and query/hash if present).
eleventyConfig.addFilter("pathOnly", function (url) {
try { return new URL(String(url)).pathname.replace(/\/$/, "") || "/"; }
catch { return String(url); }
});
// Find other published posts that share the same external target URL // Find other published posts that share the same external target URL
// (repostOf, likeOf, bookmarkOf, inReplyTo). Used to cross-link related posts. // (repostOf, likeOf, bookmarkOf, inReplyTo). Used to cross-link related posts.
eleventyConfig.addFilter("sameTargetPosts", function (posts, targetUrl, currentUrl) { eleventyConfig.addFilter("sameTargetPosts", function (posts, targetUrl, currentUrl) {