Clean up the partials directory
Sort partials into base and site directories
This commit is contained in:
parent
d73c779508
commit
4327d34827
8 changed files with 86 additions and 10 deletions
5
layouts/partials/base/head.html
Normal file
5
layouts/partials/base/head.html
Normal file
|
@ -0,0 +1,5 @@
|
|||
<meta charset="utf-8">
|
||||
<meta name="viewport" content="width=device-width">
|
||||
<title>{{ if .IsHome }}{{ site.Title }}{{ else }}{{ printf "%s | %s" .Title site.Title }}{{ end }}</title>
|
||||
{{ partialCached "base/head/css.html" . }}
|
||||
{{ partialCached "base/head/js.html" . }}
|
9
layouts/partials/base/head/css.html
Normal file
9
layouts/partials/base/head/css.html
Normal file
|
@ -0,0 +1,9 @@
|
|||
{{- with (partial "base/css.html" .) }}
|
||||
{{- if eq hugo.Environment "development" }}
|
||||
<link rel="stylesheet" href="{{ .RelPermalink }}">
|
||||
{{- else }}
|
||||
{{- with . | minify | fingerprint }}
|
||||
<link rel="stylesheet" href="{{ .RelPermalink }}" integrity="{{ .Data.Integrity }}" crossorigin="anonymous">
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
{{- end }}
|
12
layouts/partials/base/head/js.html
Normal file
12
layouts/partials/base/head/js.html
Normal file
|
@ -0,0 +1,12 @@
|
|||
{{- with resources.Get "js/main.js" }}
|
||||
{{- if eq hugo.Environment "development" }}
|
||||
{{- with . | js.Build }}
|
||||
<script src="{{ .RelPermalink }}"></script>
|
||||
{{- end }}
|
||||
{{- else }}
|
||||
{{- $opts := dict "minify" true }}
|
||||
{{- with . | js.Build $opts | fingerprint }}
|
||||
<script src="{{ .RelPermalink }}" integrity="{{- .Data.Integrity }}" crossorigin="anonymous"></script>
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
{{- end }}
|
51
layouts/partials/menu.html
Normal file
51
layouts/partials/menu.html
Normal file
|
@ -0,0 +1,51 @@
|
|||
{{- /*
|
||||
Renders a menu for the given menu ID.
|
||||
|
||||
@context {page} page The current page.
|
||||
@context {string} menuID The menu ID.
|
||||
|
||||
@example: {{ partial "menu.html" (dict "menuID" "main" "page" .) }}
|
||||
*/}}
|
||||
|
||||
{{- $page := .page }}
|
||||
{{- $menuID := .menuID }}
|
||||
|
||||
{{- with index site.Menus $menuID }}
|
||||
<nav class="site-header__nav">
|
||||
<ul>
|
||||
{{- partial "inline/menu/walk.html" (dict "page" $page "menuEntries" .) }}
|
||||
</ul>
|
||||
</nav>
|
||||
{{- end }}
|
||||
|
||||
{{- define "partials/inline/menu/walk.html" }}
|
||||
{{- $page := .page }}
|
||||
{{- range .menuEntries }}
|
||||
{{- $attrs := dict "href" .URL }}
|
||||
{{- if $page.IsMenuCurrent .Menu . }}
|
||||
{{- $attrs = merge $attrs (dict "class" "active" "aria-current" "page") }}
|
||||
{{- else if $page.HasMenuCurrent .Menu .}}
|
||||
{{- $attrs = merge $attrs (dict "class" "ancestor" "aria-current" "true") }}
|
||||
{{- end }}
|
||||
{{- $name := .Name }}
|
||||
{{- with .Identifier }}
|
||||
{{- with T . }}
|
||||
{{- $name = . }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
<li>
|
||||
<a
|
||||
{{- range $k, $v := $attrs }}
|
||||
{{- with $v }}
|
||||
{{- printf " %s=%q" $k $v | safeHTMLAttr }}
|
||||
{{- end }}
|
||||
{{- end -}}
|
||||
>{{ $name }}</a>
|
||||
{{- with .Children }}
|
||||
<ul>
|
||||
{{- partial "inline/menu/walk.html" (dict "page" $page "menuEntries" .) }}
|
||||
</ul>
|
||||
{{- end }}
|
||||
</li>
|
||||
{{- end }}
|
||||
{{- end }}
|
5
layouts/partials/site/footer.html
Normal file
5
layouts/partials/site/footer.html
Normal file
|
@ -0,0 +1,5 @@
|
|||
<div class="site-footer__container">
|
||||
<aside class="site-footer__copyright">
|
||||
<small>Copyright © {{ now.Year }} <a href="mailto:eryn@erynwells.me">Eryn Wells</a>. All rights reserved.<small>
|
||||
</aside>
|
||||
</div>
|
4
layouts/partials/site/header.html
Normal file
4
layouts/partials/site/header.html
Normal file
|
@ -0,0 +1,4 @@
|
|||
<div class="site-header__container">
|
||||
<aside class="site-header__title"><a href="{{ ($.Site.GetPage "/").Permalink }}">{{ site.Title }}</a></aside>
|
||||
{{ partial "menu.html" (dict "menuID" "main" "page" .) }}
|
||||
</div>
|
|
@ -1,10 +0,0 @@
|
|||
{{- $scale := slice
|
||||
(dict "Name" "xxs" "Value" -3)
|
||||
(dict "Name" "xs" "Value" -2)
|
||||
(dict "Name" "s" "Value" -1)
|
||||
(dict "Name" "m" "Value" 0)
|
||||
(dict "Name" "l" "Value" 1)
|
||||
(dict "Name" "xl" "Value" 2)
|
||||
(dict "Name" "xxl" "Value" 3)
|
||||
-}}
|
||||
{{ return $scale }}
|
Loading…
Add table
Add a link
Reference in a new issue