fix: fall back to URL as link text in See Also when post has no title
Build & Deploy / build-and-deploy (push) Failing after 1m4s
Build & Deploy / build-and-deploy (push) Failing after 1m4s
Titleless posts (notes, reposts) produced an empty <a> in See Also. The condition `_relPost.data.title if _relPost else relUrl` only fell back to the URL when postByUrl returned null — not when the post was found but carried no title field. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -130,7 +130,10 @@ withBlogSidebar: true
|
||||
|
||||
{# See Also — explicit related: frontmatter + in-text links to other blog posts #}
|
||||
{% set _seeAlso = page.inputPath | seeAlsoLinks(related) %}
|
||||
{% if _seeAlso.length > 0 %}
|
||||
{# Cross-link posts that share the same external target URL (repostOf, likeOf, etc.) #}
|
||||
{% set _targetUrl = repostedUrl or likedUrl or bookmarkedUrl or replyTo %}
|
||||
{% set _sameTarget = collections.posts | sameTargetPosts(_targetUrl, page.url) %}
|
||||
{% if _seeAlso.length > 0 or _sameTarget.length > 0 %}
|
||||
<section class="post-related mt-6 pt-5 border-t border-surface-200 dark:border-surface-700">
|
||||
<h2 class="text-xs font-semibold text-surface-500 dark:text-surface-400 uppercase tracking-widest mb-3">See Also</h2>
|
||||
<ul class="space-y-1.5 list-none p-0 m-0">
|
||||
@@ -138,7 +141,14 @@ withBlogSidebar: true
|
||||
{% set _relPost = collections.posts | postByUrl(relUrl) %}
|
||||
<li>
|
||||
<a href="{{ relUrl }}" class="text-sm text-accent-700 dark:text-accent-300 hover:underline">
|
||||
{{ _relPost.data.title if _relPost else relUrl }}
|
||||
{{ (_relPost.data.title if _relPost else null) or relUrl }}
|
||||
</a>
|
||||
</li>
|
||||
{% endfor %}
|
||||
{% for stp in _sameTarget %}
|
||||
<li>
|
||||
<a href="{{ stp.url }}" class="text-sm text-accent-700 dark:text-accent-300 hover:underline">
|
||||
{{ stp.data.title or stp.url }}
|
||||
</a>
|
||||
</li>
|
||||
{% endfor %}
|
||||
|
||||
Reference in New Issue
Block a user