hugo-geekdoc/layouts/partials/page-header.html

40 lines
1.7 KiB
HTML
Raw Permalink Normal View History

2020-01-12 14:33:02 +00:00
{{ $geekdocRepo := default (default false .Site.Params.GeekdocRepo) .Page.Params.GeekdocRepo }}
{{ $geekdocEditPath := default (default false .Site.Params.GeekdocEditPath) .Page.Params.GeekdocEditPath }}
{{ if .File }}
{{ $.Scratch.Set "geekdocFilePath" (default .File.Path .Page.Params.geekdocFilePath) }}
{{ else }}
{{ $.Scratch.Set "geekdocFilePath" false }}
{{ end }}
2020-02-05 08:40:05 +00:00
{{ define "breadcrumb" }}
2020-01-12 14:33:02 +00:00
{{$parent := .page.Parent }}
{{ if $parent }}
{{ $value := (printf "<a href='%s'>%s</a> / %s" $parent.RelPermalink $parent.Title .value) }}
{{ template "breadcrumb" dict "page" $parent "value" $value }}
2020-02-05 08:40:05 +00:00
{{ else }}
{{ .value | safeHTML }}
{{ end }}
{{ end }}
2020-01-12 14:33:02 +00:00
2020-02-05 09:13:04 +00:00
{{ $showBreadcrumb := (and (default true .Page.Params.geekdocBreadcrumb) (default true .Site.Params.geekdocBreadcrumb)) }}
{{ $showEdit := (and ($.Scratch.Get "geekdocFilePath") $geekdocRepo $geekdocEditPath) }}
<div class="gdoc-page__header flex flex-wrap justify-between{{ if not $showEdit }} hidden-mobile{{ end }}{{ if (and (not $showBreadcrumb) (not $showEdit)) }} hidden {{ end }}" itemscope itemtype="http://data-vocabulary.org/Breadcrumb">
2020-01-12 14:33:02 +00:00
<span>
2020-02-05 08:40:05 +00:00
{{if $showBreadcrumb }}
2020-01-12 14:33:02 +00:00
<span class="breadcrumb">
<svg class="icon path"><use xlink:href="#path"></use></svg>
{{ $name := (partial "title" .) }}
{{ template "breadcrumb" dict "page" . "value" $name }}
</span>
{{ end }}
</span>
<span>
2020-02-05 09:13:04 +00:00
{{ if $showEdit }}
2020-01-12 14:33:02 +00:00
<svg class="icon code"><use xlink:href="#code"></use></svg>
<a href="{{ $geekdocRepo }}/{{ $geekdocEditPath }}/{{ $.Scratch.Get "geekdocFilePath" }}">
Edit this page
</a>
{{ end }}
</span>
</div>