<!DOCTYPE html>
<html lang="{{ default .Site.Language.Lang .Site.LanguageCode }}" dir="{{ default "ltr" .Site.Language.LanguageDirection }}">
<head>
  {{ partial "docs/html-head" . }}
  {{ partial "docs/inject/head" . }}
</head>
<body dir="{{ default "ltr" .Site.Language.LanguageDirection }}" class="book-kind-{{ .Kind }} book-type-{{ .Type }}{{ with .Layout }} book-layout-{{ . }}{{ end }}">
  <input type="checkbox" class="hidden toggle" id="menu-control" />
  <input type="checkbox" class="hidden toggle" id="toc-control" />
  <main class="container flex">
    {{ template "menu-container" . }} <!-- Left menu -->

    <div class="book-page">
      <header class="book-header hidden">
        {{ template "header" . }} <!-- Mobile layout header -->
      </header>

      {{ partial "docs/inject/content-before" . }}
      {{ template "main" . }} <!-- Page Content -->
      {{ partial "docs/inject/content-after" . }}

      <footer class="book-footer">
        {{ template "footer" . }} <!-- Footer under page content -->
        {{ template "comments" . }} <!-- Comments block -->
        {{ partial "docs/inject/footer" . }}
        {{ template "copyright" . }} <!-- Copyright block -->
        {{ template "clipboard" . }}
      </footer>

      <label for="menu-control" class="hidden book-menu-overlay"></label>
    </div>

    {{ template "toc-container" . }} <!-- Table of Contents -->
  </main>

  {{ partial "docs/inject/body" . }}
</body>
</html>

{{ define "menu-container" }}
<aside class="book-menu">
  <div class="book-menu-content">
    {{ template "menu" . }}
  </div>
</aside>
{{ end }}

{{ define "menu" }}
  {{ partial "docs/menu" . }}
{{ end }}

{{ define "header" }}
  {{ partial "docs/header" . }}

  {{ if partial "docs/toc-show" . }}
  <aside class="hidden">
    {{ template "toc" . }}
  </aside>
  {{ end }}
{{ end }}

{{ define "footer" }}
  {{ partial "docs/footer" . }}
{{ end }}

{{ define "clipboard" }}
  <!-- Clipboard -->
  {{ with resources.Get "clipboard.js" | resources.Minify }}
    <script>{{ .Content | safeJS }}</script>
  {{ end }}
{{ end }}

{{ define "copyright" }}
  {{ if .Site.Copyright }}
  <div class="book-copyright flex justify-center">
    {{ partial "docs/copyright" . }}
  </div>
  {{ end }}
{{ end }}

{{ define "comments" }}
  {{ if and .Content (default true (default .Site.Params.BookComments .Params.BookComments)) }}
  <div class="book-comments">
    {{- partial "docs/comments" . -}}
  </div>
  {{ end }}
{{ end }}

{{ define "main" }}
  <article class="markdown book-article">
    {{- .Content -}}
  </article>
{{ end }}

{{ define "toc-container" }}
  {{ if partial "docs/toc-show" . }}
  <aside class="book-toc">
    <div class="book-toc-content">
      {{ template "toc" . }}
    </div>
  </aside>
  {{ end }}
{{ end }}

{{ define "toc" }}
  {{ partial "docs/toc" . }}
{{ end }}
