.Render "summary" + lang.Merge = Scratch gone?

I understand this is a mess, but maybe someone can help.

This repository holds my website stripped to just two posts to indicate the problem. It is based on the LoveIt theme with my modifications, and it’s my modifications I can’t debug here.

The problem: /posts/2020/english.en.md uses {{< mermaid >}} shortcode that does not render. The shortcode is supposed to work by setting a field in .Page.Scratch(“this”) that later is detected in /layouts/partials/assets.html that injects the corresponding style and script. It looks like .Page.Scratch set up in this shortcode doesn’t persist.

hugo && grep "mermaid.min" public/en/posts/2020/english/index.html - nothing

The same shortcode in the other post (/posts/2020/russian.md) renders just fine:

hugo && grep "mermaid.min" public/posts/2020/russian/index.html - shows the expected output.

Weird things that confuse me:

  • default language rendering properly while another language isn’t is weird in itself, right?
  • deleting /content/posts/2020/russian.md results in correct rendering of the remaining post
  • deleting line 27 in themes/loveit/layouts/index.html results in correct rendering
  • deleting line 43 in themes/loveit/layouts/index.html results in correct rendering

Why? For the love of gods, what does lang.Merge on index page have to do with the rendering of the individual posts? Why does showing summaries on the index page affect individual post rendering?

Am I dumb? Am I missing something obvious?

I don’t yet see fully through your layout there but could it be that the languages are overwriting each other in the .Scratch part of the whole system?

The shortcode mermaid.html is as follows:

{{- $id := dict "Content" (trim .Inner "\n") "Scratch" .Page.Scratch | partial "function/id.html" -}}
<div class="mermaid" id="{{ $id }}"></div>
{{- .Page.Scratch.SetInMap "this" "mermaid" true -}}

And I don’t see anything that indicates that languages are scratched separately… Maybe ask the developer of the loveit theme. If that is you, I am asking you :wink:

No, I’m not the author of the theme. Unfortunately, the author seems to have largely disappeared from GitHub, so there’s no way to contact him.

Your theory doesn’t explain the fact that if I avoid calling .Summary on the merged pages (by deleting line 43 in themes/loveit/layouts/index.html) the rendering is correct.

I have a serious suspicion about lang.Merge, I’ve already seen it misbehave under other circumstances, too.