{{- define "main" -}}
{{- with .Site.GetPage "/" -}} {{- .Content -}} {{- end -}}
{{- $bookSection := default "docs" .Site.Params.BookSection -}} {{- if eq $bookSection "*" -}} {{ $bookSection = "/" -}} {{- end -}} {{- with .Site.GetPage $bookSection -}} {{- range (where .Pages "Params.bookHidden" "ne" true) -}} {{- if .IsSection -}} {{- $chapternb := index (findRESubmatch `^0*(\d+)` .File.Dir) 0 1 -}} {{- $isAppendix := hasPrefix .File.Dir "99" -}} {{- if $isAppendix -}}

Appendix

{{- else -}}

Chapter {{ $chapternb }}

{{ .Title }}

{{- end -}} {{- .Content -}} {{- range $index, $page := .Pages -}}

{{- if $isAppendix -}} {{ index (slice "A" "B") $index }}. {{- else -}} {{ $chapternb }}.{{ add $index 1 }}. {{ end }} {{ $page.Title }}

{{- .Content -}} {{- end -}}
{{- end -}} {{- end -}} {{- end -}}
{{- end -}}