{{ $section_name := .Get "section" }}

{{ $section := .Site.GetPage $section_name }}
{{ if not $section }}
  {{ errorf "bookcase resource not found" }}
{{ end }}

{{ if ne $section.Kind "section" }}
  {{ errorf "bookcase resource must be a section" }}
{{ end }}

{{ $list_sections := $section.Params.bookcase_list_sections | default true }}
{{ $list_pages := $section.Params.bookcase_list_pages | default true }}

{{ $pages := default nil }}
{{ if and $list_sections $list_pages }}
    {{ $pages = $section.Pages