|
| 1 | +{{ $page := . }} |
| 2 | +{{ $featured := partial "blox-core/functions/get_featured_image.html" $page }} |
| 3 | + |
| 4 | +{{ $anchor := $page.Params.image.focal_point | default "Smart" }} |
| 5 | + |
| 6 | +{{/* Set default titles for node pages */}} |
| 7 | +{{ $title := .Title }} |
| 8 | +{{ if and (not $title) .IsNode }} |
| 9 | + {{ if eq .Type "post" }} |
| 10 | + {{ $title = i18n "posts" }} |
| 11 | + {{ else if eq .Type "event" }} |
| 12 | + {{ $title = i18n "talks" }} |
| 13 | + {{ else if eq .Type "publication" }} |
| 14 | + {{ $title = i18n "publications" }} |
| 15 | + {{end}} |
| 16 | +{{end}} |
| 17 | + |
| 18 | +{{/* Banner image */}} |
| 19 | +{{ if and .Params.banner.image (not (and $featured (not .Params.image.preview_only))) }} |
| 20 | +<div class="article-header"> |
| 21 | + {{- $img := "" -}} |
| 22 | + {{ $alt := (.Params.banner.caption | default "") | plainify }} |
| 23 | + {{ $destination := .Params.banner.image }} |
| 24 | + {{ $is_remote := strings.HasPrefix $destination "http" }} |
| 25 | + {{- if not $is_remote -}} |
| 26 | + {{- $img = (.Page.Resources.ByType "image").GetMatch $destination -}} |
| 27 | + {{- if not $img -}} |
| 28 | + {{- $img = resources.Get (path.Join "media" $destination) -}} |
| 29 | + {{- end -}} |
| 30 | + {{- end -}} |
| 31 | + {{ if $img }} |
| 32 | + <img src="{{$img.RelPermalink}}" width="{{$img.Width}}" height="{{$img.Height}}" class="article-banner" alt="{{$alt}}"> |
| 33 | + {{ else }} |
| 34 | + <img src="{{ .Params.banner.image }}" class="article-banner" alt="{{$alt}}"> |
| 35 | + {{ end }} |
| 36 | + |
| 37 | + {{ with .Params.banner.caption }}<span class="article-header-caption">{{ . | markdownify | emojify }}</span>{{ end }} |
| 38 | +</div> |
| 39 | +{{end}} |
| 40 | + |
| 41 | +{{/* Featured image layout */}} |
| 42 | +{{ if and $featured (not .Params.image.preview_only) }} |
| 43 | + |
| 44 | +{{/* Fit image within max size. */}} |
| 45 | +{{ $image := $featured }} |
| 46 | + |
| 47 | +{{/* Determine image placement. */}} |
| 48 | +{{ $placement := .Params.image.placement | default 1 }}{{/* Default to full column width. */}} |
| 49 | +{{/* Fit image to container's max width */}} |
| 50 | +{{ $image_container := "" }} |
| 51 | +{{ if eq $placement 2}} |
| 52 | + {{ $image_container = "container" }} |
| 53 | + {{ $image = $featured.Fit "1200x2500" }} |
| 54 | +{{else if eq $placement 3}} |
| 55 | + {{ $image_container = "container-fluid" }} |
| 56 | + {{ $image := $featured.Fit "2560x2560" }} |
| 57 | +{{else}} |
| 58 | + {{ $image_container = "article-container" }} |
| 59 | + {{ $image = $featured.Fit "720x2500" }} |
| 60 | +{{end}} |
| 61 | +{{ if ne $image.MediaType.SubType "gif" }}{{ $image = $image.Process "webp" }}{{ end }} |
| 62 | + |
| 63 | +<div class="article-container pt-3" style="text-align: center;"> |
| 64 | + <h1>{{ $title }}</h1> |
| 65 | + |
| 66 | + {{ with $page.Params.subtitle }} |
| 67 | + <p class="page-subtitle">{{ . | markdownify | emojify }}</p> |
| 68 | + {{end}} |
| 69 | + |
| 70 | + {{ partial "page_metadata" (dict "page" $page "is_list" 0 "share" true) }} |
| 71 | + {{ partial "page_links_div.html" $page }} |
| 72 | +</div> |
| 73 | + |
| 74 | +{{/* Featured image */}} |
| 75 | + |
| 76 | +{{else}} |
| 77 | + {{/* Case when page has no image */}} |
| 78 | + |
| 79 | + {{/* Wider container for nodes */}} |
| 80 | + {{ $ctnr := "article-container" }} |
| 81 | + {{ if $page.IsNode }} |
| 82 | + {{ $ctnr = "universal-wrapper" }} |
| 83 | + {{end}} |
| 84 | +<div class="{{$ctnr}} pt-3" style="text-align: center;"> |
| 85 | + <h1>{{ $title }}</h1> |
| 86 | + |
| 87 | + {{ with $page.Params.subtitle }} |
| 88 | + <p class="page-subtitle">{{ . | markdownify | emojify }}</p> |
| 89 | + {{end}} |
| 90 | + |
| 91 | + {{ if not .IsNode }} |
| 92 | + {{ partial "page_metadata" (dict "page" $page "is_list" 0 "share" true) }} |
| 93 | + {{ partial "page_links_div.html" $page }} |
| 94 | + {{end}} |
| 95 | +</div> |
| 96 | +{{end}} |
0 commit comments