mirror of
https://github.com/svemagie/blog-eleventy-indiekit.git
synced 2026-05-15 06:58:50 +02:00
feat: prefer sourceTitle over feedTitle in news page
For aggregated feeds (like FreshRSS), display the original source title (e.g., "Hacker News") instead of the aggregator name. Falls back to feedTitle for direct RSS feeds. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -134,13 +134,22 @@ withSidebar: true
|
|||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
<div class="flex flex-wrap items-center gap-2 text-xs text-surface-500">
|
<div class="flex flex-wrap items-center gap-2 text-xs text-surface-500">
|
||||||
{% if item.feedTitle %}
|
{# Use sourceTitle for aggregators, fall back to feedTitle for direct feeds #}
|
||||||
<span class="inline-flex items-center gap-1 px-2 py-0.5 bg-surface-100 dark:bg-surface-700 rounded-full">
|
{% set displayTitle = item.sourceTitle or item.feedTitle %}
|
||||||
|
{% set displayUrl = item.sourceUrl or (item.feedInfo and item.feedInfo.siteUrl) %}
|
||||||
|
{% if displayTitle %}
|
||||||
|
<a
|
||||||
|
href="{{ displayUrl or item.link }}"
|
||||||
|
class="inline-flex items-center gap-1 px-2 py-0.5 bg-surface-100 dark:bg-surface-700 rounded-full hover:bg-surface-200 dark:hover:bg-surface-600 transition-colors"
|
||||||
|
target="_blank"
|
||||||
|
rel="noopener"
|
||||||
|
title="{{ displayTitle }}"
|
||||||
|
>
|
||||||
{% if item.feedInfo and item.feedInfo.imageUrl %}
|
{% if item.feedInfo and item.feedInfo.imageUrl %}
|
||||||
<img src="{{ item.feedInfo.imageUrl }}" alt="" class="w-3 h-3 rounded-sm">
|
<img src="{{ item.feedInfo.imageUrl }}" alt="" class="w-3 h-3 rounded-sm">
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{{ item.feedTitle }}
|
{{ displayTitle | truncate(25) }}
|
||||||
</span>
|
</a>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
{% if item.author %}
|
{% if item.author %}
|
||||||
@@ -200,7 +209,8 @@ withSidebar: true
|
|||||||
|
|
||||||
<div class="flex items-center justify-between text-xs text-surface-500">
|
<div class="flex items-center justify-between text-xs text-surface-500">
|
||||||
<span class="truncate max-w-[60%]">
|
<span class="truncate max-w-[60%]">
|
||||||
{% if item.feedTitle %}{{ item.feedTitle }}{% endif %}
|
{# Use sourceTitle for aggregators, fall back to feedTitle for direct feeds #}
|
||||||
|
{% if item.sourceTitle %}{{ item.sourceTitle | truncate(20) }}{% elif item.feedTitle %}{{ item.feedTitle | truncate(20) }}{% endif %}
|
||||||
</span>
|
</span>
|
||||||
{% if item.pubDate %}
|
{% if item.pubDate %}
|
||||||
<time datetime="{{ item.pubDate }}">{{ item.pubDate | date("PP") }}</time>
|
<time datetime="{{ item.pubDate }}">{{ item.pubDate | date("PP") }}</time>
|
||||||
@@ -232,17 +242,20 @@ withSidebar: true
|
|||||||
<div class="p-6">
|
<div class="p-6">
|
||||||
{# Meta bar #}
|
{# Meta bar #}
|
||||||
<div class="flex flex-wrap items-center gap-3 mb-4 text-sm">
|
<div class="flex flex-wrap items-center gap-3 mb-4 text-sm">
|
||||||
{% if item.feedInfo %}
|
{# Source link - use sourceTitle/Url for aggregators, feedInfo for direct feeds #}
|
||||||
|
{% set displayTitle = item.sourceTitle or item.feedTitle %}
|
||||||
|
{% set displayUrl = item.sourceUrl or (item.feedInfo and item.feedInfo.siteUrl) %}
|
||||||
|
{% if displayTitle %}
|
||||||
<a
|
<a
|
||||||
href="{{ item.feedInfo.siteUrl }}"
|
href="{{ displayUrl or item.link }}"
|
||||||
class="inline-flex items-center gap-2 px-3 py-1 bg-surface-100 dark:bg-surface-700 rounded-full hover:bg-surface-200 dark:hover:bg-surface-600 transition-colors"
|
class="inline-flex items-center gap-2 px-3 py-1 bg-surface-100 dark:bg-surface-700 rounded-full hover:bg-surface-200 dark:hover:bg-surface-600 transition-colors"
|
||||||
target="_blank"
|
target="_blank"
|
||||||
rel="noopener"
|
rel="noopener"
|
||||||
>
|
>
|
||||||
{% if item.feedInfo.imageUrl %}
|
{% if item.feedInfo and item.feedInfo.imageUrl %}
|
||||||
<img src="{{ item.feedInfo.imageUrl }}" alt="" class="w-4 h-4 rounded">
|
<img src="{{ item.feedInfo.imageUrl }}" alt="" class="w-4 h-4 rounded">
|
||||||
{% endif %}
|
{% endif %}
|
||||||
<span class="font-medium text-surface-700 dark:text-surface-300">{{ item.feedTitle }}</span>
|
<span class="font-medium text-surface-700 dark:text-surface-300">{{ displayTitle }}</span>
|
||||||
</a>
|
</a>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user