fix: exclude image links from See Also; show path-only for untitled URL fallbacks
Build & Deploy / build-and-deploy (push) Successful in 1m23s
Build & Deploy / build-and-deploy (push) Successful in 1m23s
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -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
@@ -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) {
|
||||||
|
|||||||
Reference in New Issue
Block a user