display rework
[kengrimes.com/theme.git] / layouts / _default / baseof.html
index 9837ab5..5455891 100644 (file)
   </head>
   <body>
     <header>
-      <figure>
-        {{- $ph := .Page.Resources.GetMatch "header.png" -}}
-        {{- if $ph }}
-        <img src="{{ $ph.RelPermalink }}"></img>
+      {{- $sp := .Site.GetPage "section" .Section }}
+      {{- $ph := .Page.Resources.GetMatch "header.png" -}}
+      {{- $ph := cond (not $ph) ($sp.Resources.GetMatch "header.png") $ph }}
+      {{- $ph := cond (not $ph) (relURL "/img/speedy.png") $ph.RelPermalink }}
+      <img src="{{ $ph }}">
+      <div>
+        {{ $caption := cond (not .Page.Params.caption) (cond (not $sp.Title) .Site.Title $sp.Title) .Page.Params.Caption }}
+        {{- if (eq (printf "%T" $caption) "string") }}
+        {{- .Page.Params.caption -}}
         {{- else }}
-        <img src="{{relURL `/img/speedy.png`}}"></img>
+        {{- index .Page.Params.caption 0 }}
+        {{- if (gt (len .Page.Params.caption) 1) }}
+        {{- range after 1 .Page.Params.caption -}}
+        <br>
+        {{ . }}
+        {{- end -}}
+        {{- end -}}
         {{- end }}
-      </figure>
-      <nav>
-        <header>{{ if .Page.Title }}{{ .Page.Title }}{{ else }}&nbsp;{{ end }}</header>
-        <nav>
-          {{- $pg := . }}
-          {{- range union (where .Site.Menus.main "Weight" 0).Reverse (where .Site.Menus.main "Weight" "!=" 0) }}
-          <a href="{{ .URL }}">
-            <summary>{{ .Name }}</summary>
-            <svg{{- if or ($pg.IsMenuCurrent "main" .) ($pg.HasMenuCurrent "main" .) }} class="selected"{{ end }}>
-              <use xlink:href="{{ relURL `/img/nav.svg` }}#{{ .Name }}"/>
-            </svg>
-          </a>
-          {{- end }}
-        </nav>
-        <footer>
-        {{- if isset .Page.Params "caption" -}}
-          {{- if (eq (printf "%T" .Page.Params.caption) "string") }}
-          {{- replaceRE "([&<>'])" "$1" .Page.Params.caption -}}
-          {{- else }}
-          {{ replaceRE "([&<>'])" "$1" (index .Page.Params.caption 0) }}
-          {{- range after 1 .Page.Params.caption -}}
-          <br>
-          {{ replaceRE "([&<>'])" "$1" . }}
-          {{- end }}
-          {{- end }}
-        {{- else }}
-          {{- .Site.Title -}}
-        {{- end }}
-        </footer>
-      </nav>
+      </div>
     </header>
+    <nav>
+      <div>
+        {{- $pg := . }}
+        {{- range union (where .Site.Menus.main "Weight" 0).Reverse (where .Site.Menus.main "Weight" "!=" 0) }}
+        <a href="{{ .URL }}">
+          <summary>{{ .Name }}</summary>
+          <svg{{- if or ($pg.InSection .Page) (eq .Page $sp) }} class="selected"{{ end }}>
+            <use xlink:href="{{ relURL `/img/nav.svg` }}#{{ .Name }}"/>
+          </svg>
+        </a>
+        {{- end }}
+      </div>
+      <footer>
+        {{ cond (not .Page.Title) .Page.Name .Page.Title }}
+      </footer>
+    </nav>
     <main>
       {{ block "main" . }}{{ end }}
     </main>