{{ $bookSection := default "docs" .Site.Params.BookSection  }}
{{ if eq $bookSection "*" }}
  {{ $bookSection = "/" }}{{/* Backward compatibility */}}
{{ end }}

{{ with .Site.GetPage $bookSection }}
  {{ $pages := partialCached "docs/prev-next-cache" .Pages }}
  {{ $prev := $pages.Next $ }}
  {{ $next := $pages.Prev $ }}

  {{- if or $prev $next }}
  <div class="flex flex-wrap justify-between">
    <span>
    {{ with $prev }}
      <a href="{{ .RelPermalink }}" class="flex align-center">
        <img src="{{ partial "docs/icon" "backward" }}" class="book-icon" alt="{{ partial "docs/text/i18n" "Backward" }}" />
        <span>{{ partial "docs/title" . }}</span>
      </a>
    {{ end }}
    </span>
    <span>
    {{ with $next }}
      <a href="{{ .RelPermalink }}" class="flex align-center">
        <span>{{ partial "docs/title" . }}</span>
        <img src="{{ partial "docs/icon" "forward" }}" class="book-icon" alt="{{ partial "docs/text/i18n" "Forward" }}" />
      </a>
    {{ end }}
    </span>
  </div>
  {{ end -}}
{{ end }}
