turned hero into a partial

This commit is contained in:
Nuno Coração 2022-10-15 21:53:19 +01:00
parent 80425321f3
commit e9a17706ae
4 changed files with 12 additions and 13 deletions

View file

@ -40,4 +40,4 @@ The you just need to add an image like explain earlier. If you want to see a sam
## Hero Images
Thumbnails will be used by default as hero images withing each article. Use the global `article.showHero` or the front-matter parameter `showHero` to control this feature across the entire site or for each specific post.
Thumbnails will be used by default as hero images withing each article. Use the global `article.showHero` or the front-matter parameter `showHero` to control this feature across the entire site or for each specific post. If you want to override the style of the hero image you can create a file called `hero.html` in `./layouts/partials/` that will override the original partial from the theme.

View file

@ -1,17 +1,6 @@
{{ define "main" }}
<article>
{{ if .Params.showHero | default (.Site.Params.article.showHero | default false) }}
{{- $images := .Resources.ByType "image" -}}
{{- $featured := $images.GetMatch "*feature*" -}}
{{- if not $featured }}{{ $featured = $images.GetMatch "{*cover*,*thumbnail*}" }}{{ end -}}
{{- with $featured -}}
{{ with .Resize "600x" }}
<div class="w-full h-36 md:h-56 lg:h-72 single_hero nozoom" style="background-image:url({{ .RelPermalink }});"></div>
{{ end }}
{{- end -}}
{{- end -}}
{{ partial "hero.html" . }}
<header class="mt-5 max-w-prose">
{{ if .Params.showBreadcrumbs | default (.Site.Params.article.showBreadcrumbs | default false) }}
{{ partial "breadcrumbs.html" . }}

View file

@ -0,0 +1,10 @@
{{ if .Params.showHero | default (.Site.Params.article.showHero | default false) }}
{{- $images := .Resources.ByType "image" -}}
{{- $featured := $images.GetMatch "*feature*" -}}
{{- if not $featured }}{{ $featured = $images.GetMatch "{*cover*,*thumbnail*}" }}{{ end -}}
{{- with $featured -}}
{{ with .Resize "600x" }}
<div class="w-full h-36 md:h-56 lg:h-72 single_hero nozoom" style="background-image:url({{ .RelPermalink }});"></div>
{{ end }}
{{- end -}}
{{- end -}}