hugo-theme-relearn/layouts/partials/header.html

198 lines
9.7 KiB
HTML
Raw Normal View History

<!DOCTYPE html>
2022-11-17 21:12:18 +00:00
{{- $format := partial "get-format.hugo" . }}
{{- $outputFormat := partial "output-format.hugo" (dict "page" . "format" $format) }}
{{- $basename := "index" }}
{{- if eq $outputFormat "searchpage" }}
{{- $basename = partial "BaseName.hugo" $format.RelPermalink }}
2022-11-17 21:12:18 +00:00
{{- end }}
<html lang="{{ .Page.Language | default "en" }}" dir="{{ T "Reading-direction" | default "ltr" }}">
<head>
{{- partial "meta.html" . }}
{{- $page := . }}
2022-07-07 19:42:45 +00:00
{{- $link := "<link href=\"%s\" rel=\"%s\" type=\"%s\" title=\"%s\">" }}
{{- $title := .Title }}
{{- if eq $outputFormat "searchpage" }}
{{- $title = T "Search" }}
{{- else if eq .Kind "term" }}
{{- $title = i18n .Data.Singular }}
{{- if not $title }}
{{- $title = .Data.Singular | humanize }}
{{- end }}
{{- $title = printf "%s %s %s" .Title (default "::" .Site.Params.titleSeparator) $title }}
{{- end }}
{{- if and $title .Site.Title (not (eq $title .Site.Title)) }}
{{- $title = printf "%s %s %s" $title (default "::" .Site.Params.titleSeparator) .Site.Title }}
{{- end }}
<title>{{ $title }}</title>
2018-02-19 16:09:45 +00:00
{{- if .IsTranslated -}}
{{- range $index, $trans := .AllTranslations }}
{{- if eq $index 0 }}
<link href="{{ partial "relLangPrettyUglyURL.hugo" (dict "to" . "abs" true "basename" $basename) }}" rel="alternate" hreflang="x-default">
{{- end }}
<link href="{{ partial "relLangPrettyUglyURL.hugo" (dict "to" . "abs" true "basename" $basename) }}" rel="alternate" hreflang="{{ .Language.Lang }}">
{{- end }}
{{- end }}
{{- if not (and .Title (or (ne (.Scratch.Get "relearnIsHiddenStem") true) (ne .Site.Params.disableSeoHiddenPages true) ) ) }}
{{- else }}
{{- range .AlternativeOutputFormats }}
{{- if eq .Rel "canonical" }}
2022-11-17 21:12:18 +00:00
{{ (printf $link (partial "relLangPrettyUglyURL.hugo" (dict "to" . "abs" true "basename" $basename)) .Rel .MediaType.Type ($title | htmlEscape)) | safeHTML }}
{{- else if eq $outputFormat "searchpage" }}
{{- else if eq .Name "SEARCHPAGE" }}
{{- else if and (ne .Name "JSON") (ne .Name "SEARCH") }}
{{ (printf $link (partial "relLangPrettyUglyURL.hugo" (dict "to" .)) .Rel .MediaType.Type ($title | htmlEscape)) | safeHTML }}
{{- end }}
{{- end }}
{{- end }}
{{- if and (ne .Site.Params.disableSeoHiddenPages true) (ne .Site.Params.disableSearchHiddenPages true) }}
{{- range .AlternativeOutputFormats }}
{{- if eq .Name "SEARCHPAGE" }}
{{- else if eq .Name "JSON" }}
{{ (printf $link (.Permalink | relURL) .Rel .MediaType.Type ($title | htmlEscape)) | safeHTML }}
{{- end }}
{{- end }}
2021-11-24 11:03:11 +00:00
{{- end }}
2022-11-12 14:16:53 +00:00
{{- partialCached "favicon.html" . }}
{{- partialCached "stylesheet.html" (dict "page" . "outputFormat" $outputFormat) $outputFormat }}
{{- partial "custom-header.html" . }}
</head>
<body class="mobile-support {{ $outputFormat }}{{- if .Site.Params.disableInlineCopyToClipBoard }} disableInlineCopyToClipboard{{ end }}" data-url="{{ partial "relLangPrettyUglyURL.hugo" (dict "to" .) }}">
2022-02-13 00:53:23 +00:00
<div id="body" class="default-animation">
<div id="sidebar-overlay"></div>
2022-02-28 00:19:32 +00:00
<div id="toc-overlay"></div>
<nav id="topbar" class="highlightable">
<div>
2022-11-17 21:12:18 +00:00
{{- $File := .File }}
{{- $Site := .Site }}
2022-02-17 23:09:06 +00:00
{{- $showPrevNext := (and (not .Params.disableNextPrev) (not .Site.Params.disableNextPrev)) }}
2022-11-17 21:12:18 +00:00
{{- if and (or (eq $outputFormat "html") (eq $outputFormat "searchpage")) $showPrevNext }}
{{- $parent := .Parent }}
{{- $ispublished := true }}
{{- if $parent }}
{{- $ispublished = gt (int (len $parent.Permalink)) 0 }}
{{- end }}
{{- $startarrow := "&#129104;" }}
{{- $endarrow := "&#129106;" }}
{{- if eq (T "Reading-direction" | default "ltr") "rtl" }}
{{- $startarrow = "&#129106;" }}
{{- $endarrow = "&#129104;" }}
{{- end }}
2022-02-17 23:09:06 +00:00
<div class="navigation">
2022-11-17 21:12:18 +00:00
{{- if or (ne $outputFormat "html") (not (and $ispublished ($.Scratch.Get "relearnNextPage"))) }}
<span class="nav nav-next topbar-link"><i class="fa fa-chevron-right fa-fw"></i></span>
2022-11-17 21:12:18 +00:00
{{- else }}
2022-02-17 23:09:06 +00:00
{{- with ($.Scratch.Get "relearnNextPage") }}
<a class="nav nav-next topbar-link" href="{{ partial "relLangPrettyUglyURL.hugo" (dict "to" .) }}" title="{{.Title}} ({{ $endarrow | safeHTML }})"><i class="fas fa-chevron-right fa-fw"></i></a>
2022-02-17 23:09:06 +00:00
{{- end }}
{{- end }}
</div>
<div class="navigation">
2022-11-17 21:12:18 +00:00
{{- if and (eq .RelPermalink .Site.Home.RelPermalink) (eq $outputFormat "html") }}
<span class="nav nav-prev topbar-link"><i class="fa fa-chevron-left fa-fw"></i></span>
2022-11-17 21:12:18 +00:00
{{- else if or (ne $outputFormat "html") (eq .Page.Kind "taxonomy") (eq .Page.Kind "term") (not (and $ispublished ($.Scratch.Get "relearnPrevPage"))) }}
{{- with .Site.Home }}
<a class="nav nav-prev topbar-link" href="{{ partial "relLangPrettyUglyURL.hugo" (dict "to" .) }}" title="{{.Title}} ({{ $startarrow | safeHTML }})"><i class="fas fa-chevron-left fa-fw"></i></a>
2022-11-17 21:12:18 +00:00
{{- end }}
{{- else }}
2022-02-17 23:09:06 +00:00
{{- with ($.Scratch.Get "relearnPrevPage") }}
<a class="nav nav-prev topbar-link" href="{{ partial "relLangPrettyUglyURL.hugo" (dict "to" .) }}" title="{{.Title}} ({{ $startarrow | safeHTML }})"><i class="fas fa-chevron-left fa-fw"></i></a>
2022-02-17 23:09:06 +00:00
{{- end}}
{{- end}}
</div>
{{- end }}
2022-11-17 21:12:18 +00:00
{{- with and (eq $outputFormat "html") (.OutputFormats.Get "PRINT") }}
<div id="top-print-link">
2023-02-04 15:01:42 +00:00
<a class="print-link topbar-link" title='{{ T "Print-this-chapter" }} (CTRL+ALT+p)' href="{{ .RelPermalink }}">
<i class="fas fa-print fa-fw"></i>
</a>
</div>
{{- end -}}
2022-11-17 21:12:18 +00:00
{{- if and (eq $outputFormat "html") .Site.Params.editURL $File }}
{{- with $File.Path }}
<div id="top-github-link">
2023-02-04 15:01:42 +00:00
<a class="github-link topbar-link" title='{{ T "Edit-this-page" }} (CTRL+ALT+w)' href="{{ $Site.Params.editURL }}{{ strings.TrimLeft "/" (replace $File.Dir "\\" "/") }}{{ $File.LogicalName }}" target="_blank">
<i class="fas fa-pen fa-fw"></i>
</a>
</div>
{{- end }}
{{- end }}
{{- $defaultDisableToc := .Site.Params.disableToc | default false }}
{{- $currentDisableToc := .Params.disableToc | default $defaultDisableToc }}
{{- $toc_content := partial "toc.html" . }}
2023-02-10 16:15:48 +00:00
{{- $hastoc := not (eq 0 (int (len (trim ($toc_content | plainify) "\n\t ")))) }}
2022-11-17 21:12:18 +00:00
{{- $toc := and $hastoc (not $currentDisableToc) (eq $outputFormat "html") }}
<div id="breadcrumbs">
<span id="sidebar-toggle-span">
2023-02-04 15:01:42 +00:00
<a href="#" id="sidebar-toggle" class="topbar-link" title='{{ T "Navigation-toggle" }} (CTRL+ALT+n)'><i class="fas fa-bars fa-fw"></i></a>
</span>
{{- if $toc }}
<span id="toc-menu" title='{{ T "Toc-toggle" }} (CTRL+ALT+t)'><i class="fas fa-list-alt fa-fw"></i></span>
{{- end }}
{{- $showBreadcrumb := (and (not .Params.disableBreadcrumb) (not .Site.Params.disableBreadcrumb)) }}
{{- if $showBreadcrumb }}
<ol class="links" itemscope itemtype="http://schema.org/BreadcrumbList">
{{- template "breadcrumb" dict "page" . "to" . }}
</ol>
{{- else }}
<span class="links">
{{ .Title }}
</span>
{{- end }}
2021-09-13 17:39:20 +00:00
</div>
{{- if $toc }}
{{ $toc_content }}
{{- end }}
</div>
2022-02-28 00:19:32 +00:00
</nav>
2022-11-13 10:31:46 +00:00
{{- $hook := "styleclass" }}
<main id="body-inner" class="highlightable {{ partialCached "archetype.hugo" (dict "hook" $hook "page" . "parameter" . "outputFormat" $outputFormat) .RelPermalink $outputFormat $hook }}" tabindex="-1">
2022-02-28 00:19:32 +00:00
<div class="flex-block-wrapper">
<div id="head-tags">
{{- partial "tags.html" . }}
2022-02-28 00:19:32 +00:00
</div>
{{- define "breadcrumb" }}
{{- $breadcrumb := slice }}
{{- $page := .page }}
{{- $to := .to }}
{{- $breadcrumb = $breadcrumb | append $to }}
{{- $depth := int (partial "get-page-depth.hugo" (dict "page" $page)) }}
{{- range seq $depth }}
{{- $to = $to.Parent }}
{{- if $to }}
{{- $breadcrumb = $breadcrumb | append $to }}
{{- else }}
{{- break }}
{{- end }}
{{- end }}
{{- $len := len $breadcrumb -}}
{{- $breadcrumbReversed := slice }}
{{- range seq $len }}
{{- $breadcrumbReversed = $breadcrumbReversed | append (index $breadcrumb (sub $len .)) }}
{{- end }}
{{- $remaining := $len }}
{{- $depth := 0 }}
{{- range $i, $e := $breadcrumbReversed }}
{{- $to := $e }}
{{- $ispublished := gt (int (len $to.Permalink)) 0 }}
{{- $remaining = sub $remaining 1 }}
{{- if $ispublished }}
{{- $depth = add $depth 1 }}
{{- $title := $to.Title }}
{{- if eq .Kind "term" }}
{{- $title = i18n .Data.Singular }}
{{- if not $title }}
{{- $title = .Data.Singular | humanize }}
{{- end }}
{{- $title = printf "%s %s %s" $title (default "::" .Site.Params.titleSeparator) $to.Title }}
{{- end }}
{{- if not $title }}
{{- $title = $to.Site.Title }}
{{- end }}
<li itemscope itemtype="https://schema.org/ListItem" itemprop="itemListElement">{{ if $remaining }}<a itemprop="item" href="{{ partial "relLangPrettyUglyURL.hugo" (dict "to" $to) }}">{{end}}<span itemprop="name">{{ $title }}</span>{{ if $remaining }}</a>{{ end }}<meta itemprop="position" content="{{ $depth }}">{{ if $remaining }} {{ default ">" .Site.Params.breadcrumbSeparator }} {{ end }}</li>
{{- end }}
{{- end }}
{{- end }}