diff options
author | Oscar Najera <hi@oscarnajera.com> | 2023-10-21 19:09:25 +0200 |
---|---|---|
committer | Oscar Najera <hi@oscarnajera.com> | 2023-10-21 19:09:25 +0200 |
commit | 6a583db0ac533d88f551fbe4d15a10f4b038da98 (patch) | |
tree | c7c9b005b80a572d01f0a3ea6f3f21a070f897ab | |
parent | 0090c439d77726308b92ab77c650d03abb779053 (diff) | |
download | hugo-minimalist-theme-6a583db0ac533d88f551fbe4d15a10f4b038da98.tar.gz hugo-minimalist-theme-6a583db0ac533d88f551fbe4d15a10f4b038da98.tar.bz2 hugo-minimalist-theme-6a583db0ac533d88f551fbe4d15a10f4b038da98.zip |
Hero avoid duplication
-rw-r--r-- | layouts/_default/about.html | 37 | ||||
-rw-r--r-- | layouts/partials/hero.html | 44 |
2 files changed, 39 insertions, 42 deletions
diff --git a/layouts/_default/about.html b/layouts/_default/about.html index 3aaa361..a88a9b1 100644 --- a/layouts/_default/about.html +++ b/layouts/_default/about.html @@ -1,40 +1,5 @@ {{ define "hero" }} - <div - style="background: linear-gradient( rgba(0, 0, 0, 0.25), rgba(0, 0, 0, 0.15) ){{ with resources.Get (index .Params.images 0) }} - , url('{{ .RelPermalink }}') - {{ end }}; background-position: center;" - class="pv5" - > - <div id="hero" class="mw7 center ph2 near-white lh-copy tc"> - {{ $avatar := index .Params.images 1 }} - {{ if hasPrefix $avatar "http" }} - {{ $avatar = resources.GetRemote $avatar }} - {{ else }} - {{ $avatar = resources.Get $avatar }} - {{ end }} - {{ with $avatar }} - <img src="{{ .RelPermalink }}" class="br-100 w5" /> - {{ end }} - <h1 class="f1 mv1"> - {{ .Title }} - </h1> - - {{ with .Params.Subtitle }} - <h2 class="f3 fw3 mv1"> - {{ . | markdownify }} - </h2> - {{ end }} - - - <div class="f2 mt3"> - {{ if .Params.personal }} - {{ partial "social_links" .Site.Author }} - {{ else }} - {{ partial "social_links" .Site.Params }} - {{ end }} - </div> - </div> - </div> + {{ partial "hero.html" . }} {{ end }} {{ define "main" }} diff --git a/layouts/partials/hero.html b/layouts/partials/hero.html index 5acafde..93edc74 100644 --- a/layouts/partials/hero.html +++ b/layouts/partials/hero.html @@ -1,11 +1,43 @@ <div - style="background: linear-gradient( rgba(0, 0, 0, 0.25), rgba(0, 0, 0, 0.15) ){{ with resources.Get (index .Params.images 0) }} - , url('{{ .RelPermalink }}') - {{ end }}; background-position: center;" + id="hero" class="pv5" + style="background: linear-gradient( rgba(0, 0, 0, 0.25), rgba(0, 0, 0, 0.15) ){{ with resources.Get (index .Params.images 0) }} + , url('{{ .RelPermalink }}') center + {{ end }};" > - <div id="hero" class="mw7 center ph2 near-white lh-copy"> - <h1 class="f1 tc title berkshire-swash">{{ .Title }}</h1> - {{ .Content }} + <div class="mw7 center ph2 near-white lh-copy"> + {{ if eq .Type "about" }} + {{ $avatar := index .Params.images 1 }} + {{ if hasPrefix $avatar "http" }} + {{ $avatar = resources.GetRemote $avatar }} + {{ else }} + {{ $avatar = resources.Get $avatar }} + {{ end }} + {{ with $avatar }} + <img src="{{ .RelPermalink }}" class="br-100 w5 db center" /> + {{ end }} + <h1 class="f1 tc mv1"> + {{ .Title }} + </h1> + + {{ with .Params.Subtitle }} + <h2 class="f3 tc fw3 mv1"> + {{ . | markdownify }} + </h2> + {{ end }} + + + <div class="f2 mt3 tc"> + {{ if .Params.personal }} + {{ partial "social_links" .Site.Author }} + {{ else }} + {{ partial "social_links" .Site.Params }} + {{ end }} + </div> + {{ else }} + + <h1 class="f1 tc berkshire-swash">{{ .Title }}</h1> + {{ .Content }} + {{ end }} </div> </div> |