Skip to content

fix: reading time not displaying in article/components/details partial#1278

Merged
CaiJimmy merged 1 commit into
CaiJimmy:masterfrom
delize:fix/details-readingtime-site-context
Mar 4, 2026
Merged

fix: reading time not displaying in article/components/details partial#1278
CaiJimmy merged 1 commit into
CaiJimmy:masterfrom
delize:fix/details-readingtime-site-context

Conversation

@delize
Copy link
Copy Markdown
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.
Copy link
Copy Markdown
Owner

@CaiJimmy CaiJimmy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@CaiJimmy CaiJimmy changed the title Fix reading time not displaying in details partial fix: reading time not displaying in article/components/details partial Mar 4, 2026
@CaiJimmy CaiJimmy merged commit a0bd007 into CaiJimmy:master Mar 4, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

v4 beta: global params.article.readingTime ignored on single pages (details partial uses .Site with dict context)

2 participants