Recursive subpages: Is there a simpler way?

What it should do: Return all pages (with or without sections) or current page.

My current solution consists of a partial named page-crawler.html:

{{ $currentPage := .context }}
{{ $pages := default (slice) .pages }}

{{ with $currentPage.Pages }}
    {{ range . }}
        {{ if .IsPage }}
            {{ $pages = $pages | append . }}
        {{ end }}

        {{ $subContext := . }}
        {{ with .Pages }}
            {{ $subpages := partial "page-crawler" (dict "context" $subContext) }}
            {{ $pages = $pages | append $subpages }}
        {{ end }}
    {{ end }}
{{ end }}

{{ return $pages }}

Could this be done without a component?

We have a recent addition in .RegularPagesRecursive.

1 Like

That is very awesome!

1 Like

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.