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

{{ $currentNode := . }}
{{ $currentDir := "" }}
{{ with .File }}
  {{ $currentDir = .Dir }}
{{ end }}
{{ $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/{{ $currentNode.File }}">edit_this</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 ne $scratch.depth "core" }}
        <a href="{{ with $.GetPage (printf "/%s/index.md" ($scratch.core)) }}{{ .RelPermalink }}{{ end }}{{ if eq hugo.Environment "offline" }}index.html{{ end }}"><span class="sup">{{ with $.GetPage (printf "/%s/index.md" ($scratch.core)) }}{{ substr .Title 0 1  }}</span><i>{{ substr .Title 1 }}</i></a>{{ end }}
    {{ end  }}

    {{ if eq $scratch.depth "mantle" }}
        <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" }}
        {{ $p := index $scratch.is_in 0 }}
          <span><i> » <a href="{{ $p.RelPermalink }}{{ if eq hugo.Environment "offline" }}index.html{{ end }}">{{ $p.Title }}</a></i></span>
        {{ end }}
          <span class="mantlebar"><i> » <a href="{{ .RelPermalink }}{{ if eq hugo.Environment "offline" }}index.html{{ end }}">{{ .Title }}</a></i></span>
    {{ end  }}
    </div>
</div>
