{{ $s := partialCached "scratch.html" . }}

{{ $currentFile := (printf "/%s" .File) }}
{{ $scratch := $s.Get $currentFile }}

{{ if eq hugo.Environment "preview" }}
  {{- $gitUrl := .Site.Params.giturl -}}
    <div class="headiter">
        <a class="edit-button" target="_blank" href="{{ $gitUrl }}/_edit/master/content/{{ .File }}">edit_this</a>
        <a class="edit-button" target="_blank" href="{{ $gitUrl }}/_new/master/content/{{ $scratch.core }}/">add_new_{{ $scratch.core }}</a>
        <a class="edit-button" target="_blank" href="{{ $gitUrl }}/_new/master/content/{{ $scratch.mantle }}/">add_new_{{ $scratch.mantle }}</a>
        <a class="edit-button" target="_blank" href="{{ $gitUrl }}/_new/master/content/{{ $scratch.crust }}/">add_new_{{ $scratch.crust }}</a>
        <a class="edit-button" target="_blank" href="{{ $gitUrl }}/_edit/master/PUBLISH.trigger.md">publish</a>
        <a class="edit-button" target="_blank" href="{{ $gitUrl }}"> ? </a>
    </div>
{{ end }}

<div class="header">
    <a title="{{ $.Site.Home.Title }}'s Bibliotheke" href="/library/BROWSE_LIBRARY.html" class="bibliotheke" target="_blank">
        <img src="/images/bibliotheke.svg" />
    </a>
    <div class="breadcrumbs">
    {{ if eq $scratch.depth "mantle" }}
        {{ if isset $scratch "is_in" }}
        <a href="{{ with (index $scratch.is_in 0) }}{{ .RelPermalink }}{{ end }}{{ if eq hugo.Environment "offline" }}index.html{{ end }}"><span class="sup">{{ with (index $scratch.is_in 0) }}{{ substr .Title 0 1  }}</span><i>{{ substr .Title 1 }}</i>{{ if gt (len $scratch.is_in) 1 }}+{{ end}}</a>{{ end }}
        {{ end }}
        <span class="mantlebar"><i> » <a href="{{ .RelPermalink }}{{ if eq hugo.Environment "offline" }}index.html{{ end }}">{{ .Title }}</a></i></span>
    {{ end  }}

    {{ if eq $scratch.depth "crust" }}
        {{ if isset $scratch "is_in" }}
            {{ $_ := index $scratch.is_in 0 }}
            {{ $_ = $s.Get (printf "/%s" $_.File) }}

            {{ if isset $_ "is_in" }}
              {{ $home := index $_.is_in 0 }}
                <a href="{{ $home.RelPermalink }}{{ if eq hugo.Environment "offline" }}index.html{{ end }}"><span class="sup">{{ substr $home.Title 0 1  }}</span><i>{{ substr $home.Title 1 }}</i></a>
            {{ end }}
        » <a href="{{ with (index $scratch.is_in 0) }}{{ .RelPermalink }}{{ end }}{{ if eq hugo.Environment "offline" }}index.html{{ end }}">{{ with (index $scratch.is_in 0) }}<i>{{ .Title }}</i></a>{{ end }}
      {{ end }}
        <span class="mantlebar"><i> » <a href="{{ .RelPermalink }}{{ if eq hugo.Environment "offline" }}index.html{{ end }}">{{ .Title }}</a></i></span>
    {{ end  }}
    </div>
</div>

