{{- define "title" -}}
  {{- .Site.Title -}}
  {{- if .Site.Params.index_with_subtitle | and .Site.Params.header.subtitle.name -}}
    {{- printf " - %v" .Site.Params.header.subtitle.name -}}
  {{- end -}}
{{- end -}}

{{- define "content" -}}
  {{- $profile := .Site.Params.home.profile -}}
  {{- $posts := .Site.Params.home.posts -}}
  {{- $pages := slice -}}

  {{- /* Paginate calculation */ -}}
  {{- if ne $posts.enable false -}}
    {{- $pages = .Site.Store.Get "mainSectionPages" -}}
    {{- if .Site.Params.hidden_from_home_page -}}
      {{- $pages = where $pages "Params.hidden_from_home_page" false -}}
    {{- else -}}
      {{- $pages = where $pages "Params.hidden_from_home_page" "!=" true -}}
    {{- end -}}
    {{- with $posts.paginate | default .Site.Params.paginate -}}
      {{- $pages = $.Paginate $pages . -}}
    {{- else -}}
      {{- $pages = .Paginate $pages -}}
    {{- end -}}
  {{- end -}}

  <div class="page home{{ if ne $posts.enable false }} posts{{ end }}">
    {{- /* Only show profile and content on first page */ -}}
    {{- if (not $profile.only_first_page) | or (eq $.Paginator.PageNumber 1) -}}
      {{- /* Profile */ -}}
      {{- if ne $profile.enable false -}}
        {{- partial "home/profile.html" . -}}
      {{- end -}}

      {{- /* Content */ -}}
      {{- if .Content -}}
        <div class="single">
          <div class="content" id="content">
            {{- dict "Content" .Content "Ruby" (.Param "ruby") "Fraction" (.Param "fraction") "Fontawesome" (.Param "fontawesome") | partial "function/content.html" | safeHTML -}}
          </div>
        </div>
      {{- end -}}
    {{- end -}}

    {{- /* Paginate rendering */ -}}
    {{- if ne $posts.enable false -}}
      {{- range $pages.Pages -}}
        {{- .Render "summary" -}}
      {{- end -}}
      {{- partial "base/paginator.html" . -}}
    {{- end -}}
  </div>
{{- end -}}
