Conversation
There was a problem hiding this comment.
Just ran into the same issue, and the fix proposed with this PR solved my problem.
I realized that this contribution proposes a slight more elegant solution to the problem .
@tobiaskohlbau: can you have a look, please? Can we take over this solution here?
AFAIK the proposed solution would not work. As the and within the if only checks for the currently scoped Parent but not for every pages |
|
Hello, I confirm what @tobiaskohlbau said. Using Hugo 0.124.1, which contains the fix referred to above, on a docs only site, that is with the following front matter in I still get a warning: But the warning is solved when adding the modified partial from this PR. |
|
I re-tested today and, in fact, this is not a warning, but an error: I still confirm this PR fixes the issue. |
You are right. Your solution is more general and should be merged unchanged. |
| {{ $pages = (where $pages ".Parent" "!=" nil) -}} | ||
| {{ if and .Parent .Parent.File -}} | ||
| {{ $pages = (where $pages ".Parent.File" "!=" nil) -}} | ||
| {{ if and $parent $parent.File -}} |
There was a problem hiding this comment.
After looking at this more closely, it seems to make sense indeed.
Btw, the $parent variable is misnamed, because$parent is set to .Page.
Can we inline the variable instead?
Btw, IMHO .Page cannot be falsy, but .Page.File could be falsy. So the if condition can be simplified.
There was a problem hiding this comment.
Will track separately:
During rendering the section index of a docs list it could happen that a file has no parent for e.g. the homepage. If such scenario is existing the .Parent.File of a file is nil. Therefore this case should be handled within the rendering itself. Fixes google#1874 Signed-off-by: Tobias Kohlbau <[email protected]>
chalin
left a comment
There was a problem hiding this comment.
I'm willing to give this a try.
RSLGTM based on appraisals by @deining and @yann-soubeyrand.
Thanks all! ✨
During rendering the section index of a docs list it could happen that a file has no parent for e.g. the homepage. If such scenario is existing the .Parent.File of a file is nil. Therefore this case should be handled within the rendering itself.
Fixes #1874