Fix reading time not displaying in details partial#1278
Open
delize wants to merge 1 commit intoCaiJimmy:masterfrom
Open
Fix reading time not displaying in details partial#1278delize wants to merge 1 commit intoCaiJimmy:masterfrom
delize wants to merge 1 commit intoCaiJimmy:masterfrom
Conversation
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
.Site.Params.article.readingTimeresolving to nil indetails.htmlbecause the partial receives a dict context, not a page context$Page.Site.Params.article.readingTimeto match the pattern already used on lines 40 and 67 of the same fileProblem
The
details.htmlpartial is called with a dict:{{ partial "article/components/details" (dict "Page" $Page "IsList" $IsList) }}When
.(dot) is a dict,.Siteresolves to nil. This causes$showReadingTimeto always be false, so the reading time is never rendered despitereadingTime = truebeing 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
readingTime = trueinparams.tomlunder[article]<time class="article-time--reading">appears in article HTML