I am exploring this example git clone --single-branch -b hugo-forum-topic-40858 https://github.com/jmooring/hugo-testing hugo-forum-topic-40858. What’s the correct way to pass the context in a shortcode so that the pages $p in the same branch bundle are shown by the shortcode when the code is added to it?
{{ $p := append .CurrentSection.Pages.ByWeight (slice .CurrentSection) }}
{{- with $p.Next . }}
{{- end }}
Page templates (baseof, page, section, taxonomy, term, home) receive the current page in context. Or to put it another way, the dot (.) in a page template is a Page object, allowing to do this:
.CurrentSection.Pages.ByWeight
Unlike page templates, the dot in a shortcode template does not represent the current page. To access the current page within a shortcode template you must do:
I actually did that before but an error kept popping up execute of template failed at <.>: wrong type for value; expected page.Page; got *hugolib.ShortcodeWithPage. It seems {{- with $p.Next . }} should be {{- with $p.Next .Page }}. (I also noticed I need to add .Page before every variable).