I have a hierarchy of sections…
/content/logs/section-one
/content/logs/section-one/step-one
/content/logs/section-one/step-two
/content/logs/section-one/step-three
/content/logs/section-two
/content/logs/section-two/step-one
/content/logs/section-two/step-two
Each of the leaf pages have frontmatter that indicates how many hours of work were involved in the log entry…
i.e.
hoursworked: 5.25
I would like each list page in the hierarchy to display the total number of hours worked for all of the leaf pages underneath it, even if multiple levels underneath it.
I’ve successfully created a recursive partial that outputs all the hours worked…
{{ range ( .Pages ) }}
{{ if .IsPage }}
{{ float .Params.hoursworked }}
{{ end }}
{{ if .IsSection }}
{{- partial “recursivepages.html” . -}}
{{ end }}
{{ end }}
But have been unable to figure out how to add all those values together. The add function seems unable to accept the output of a partial, at least the way I’ve implemented it.
Any ideas how I can implement this?