{{ define "main" }}
  {{ $ttop := debug.Timer "single" }}
  <article class="max-w-5xl lg:max-w-3xl" id="article">
    {{ partial "layouts/docsheader.html" . }}
    <div class="content">
      {{ with .Params.description }}
        <div class="lead">
          {{ . | markdownify }}
        </div>
      {{ end }}
      {{ if .Params.show_publish_date }}
        {{ with .PublishDate }}
          <p
            class="text-gray-500 dark:text-gray-400 text-sm/5 md:text-base/2 mb-2 sm:mb-4">
            {{ partial "layouts/date.html" . }}
          </p>
        {{ end }}
      {{ end }}
      {{ $t := debug.Timer "single.categories" }}
      {{ $categories := .GetTerms "categories" }}
      {{ with $categories }}
        <div class="mb-4 sm:mb-6 flex flex-wrap gap-2">
          {{ range . }}
            {{ $text := .LinkTitle }}
            {{ $class := "" }}
            {{ range (slice true false ) }}
              {{ $color := partial "helpers/funcs/color-from-string.html" (dict "text" $text "dark" . "--single" "green" ) }}

              {{ $prefix := "" }}
              {{ if . }}
                {{ $prefix = "dark:" }}
              {{ end }}
              {{ $class = printf "%sbg-%s-%d %stext-%s-%d border %sborder-%s-%d"
                $prefix $color.color $color.shade1
                $prefix $color.color $color.shade2
                $prefix $color.color $color.shade3
              }}
            {{ end }}


            <a
              href="{{ .RelPermalink }}"
              class="{{ $class }} text-xs h-auto tracking-widest uppercase font-light not-prose no-underline inline-block py-1 px-3 rounded-xl shadow-xs hover:opacity-80 hover:shadow-none">
              {{ .LinkTitle }}
            </a>
          {{ end }}
        </div>
      {{ end }}
      {{ $t.Stop }}

      {{ if .Params.functions_and_methods.signatures }}
        <div class="mb-4 not-prose">
          {{- partial "docs/functions-signatures.html" . -}}
          {{- partial "docs/functions-return-type.html" . -}}
          {{- partial "docs/functions-aliases.html" . -}}
        </div>
      {{ end }}
      {{ $t := debug.Timer "single.content" }}
      {{ .Content }}
      {{ $t.Stop }}
      {{ $t := debug.Timer "single.page-edit" }}
      {{ partial "layouts/page-edit.html" . }}
      {{ $t.Stop }}
    </div>
  </article>
  {{ $ttop.Stop }}
{{ end }}

{{ define "rightsidebar_content" }}
  {{/* in-this-section.html depends on these being reneredc first. */}}
  {{ $related := partial "layouts/related.html" . }}
  {{ $toc := partial "layouts/toc.html" . }}
  {{ if not .Params.hide_in_this_section }}
    {{ partial "layouts/in-this-section.html" . }}
  {{ end }}
  {{ $related }}
  {{ if $.Store.Get "hasToc" }}
    {{ $toc }}
  {{ end }}
{{ end }}
