Skip to content

Fix reading time not displaying in details partial#1278

Open
delize wants to merge 1 commit intoCaiJimmy:masterfrom
delize:fix/details-readingtime-site-context
Open

Fix reading time not displaying in details partial#1278
delize wants to merge 1 commit intoCaiJimmy:masterfrom
delize:fix/details-readingtime-site-context

Conversation

@delize
Copy link
Contributor

@delize delize commented Feb 21, 2026

Summary

  • Fix .Site.Params.article.readingTime resolving to nil in details.html because the partial receives a dict context, not a page context
  • Change to $Page.Site.Params.article.readingTime to match the pattern already used on lines 40 and 67 of the same file

Problem

The details.html partial is called with a dict:

{{ partial "article/components/details" (dict "Page" $Page "IsList" $IsList) }}

When . (dot) is a dict, .Site resolves to nil. This causes $showReadingTime to always be false, so the reading time is never rendered despite readingTime = true being set in site config.

Lines 40 and 67 of the same file already correctly use $Page.Site.Params — only line 31 was missed.

Test plan

  • Verify readingTime = true in params.toml under [article]
  • Build site and confirm <time class="article-time--reading"> appears in article HTML
  • Confirm reading time displays on both list and single page views
The details.html partial receives a dict context via:
  partial "article/components/details" (dict "Page" $Page "IsList" $IsList)

When the dot context is a dict, .Site resolves to nil, so
.Site.Params.article.readingTime always returns empty/false,
causing the reading time to never display.

Lines 40 and 67 of the same file already correctly use
$Page.Site.Params — this fixes line 31 to be consistent.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

1 participant