page_header.html 3.4 KB

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