page_header.html 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  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 "talk" }}
  10. {{ $title = i18n "talks" }}
  11. {{ else if eq .Type "publication" }}
  12. {{ $title = i18n "publications" }}
  13. {{end}}
  14. {{end}}
  15. {{/* Header image */}}
  16. {{ if and .Params.header.image (not (and $featured (not .Params.image.preview_only))) }}
  17. <div class="article-header">
  18. {{ $img_src := urls.Parse .Params.header.image }}
  19. {{ if $img_src.Scheme }}
  20. <img src="{{ .Params.header.image }}" class="article-banner" itemprop="image" alt="">
  21. {{ else }}
  22. <img src="{{ (printf "/img/%s" .Params.header.image) | relURL }}" class="article-banner" itemprop="image" alt="">
  23. {{ end }}
  24. {{ with .Params.header.caption }}<span class="article-header-caption">{{ . | markdownify | emojify }}</span>{{ end }}
  25. </div>
  26. {{end}}
  27. {{/* Featured image */}}
  28. {{ if and $featured (not .Params.image.preview_only) }}
  29. {{ $image := $featured.Resize "800x" }}
  30. <div class="article-header d-xl-none">
  31. <div class="featured-image" style="background-image: url('{{ $image.RelPermalink }}');"></div>
  32. {{ with $.Params.image.caption }}<span class="article-header-caption">{{ . | markdownify | emojify }}</span>{{ end }}
  33. </div>
  34. {{ $image := $featured.Fill (printf "680x500 q90 %s" $anchor) }}
  35. <div class="container-fluid split-header d-none d-xl-block">
  36. <div class="row">
  37. <div class="col-6">
  38. <div class="split-header-content">
  39. <h1 itemprop="name">{{ $title }}</h1>
  40. {{ with $page.Params.subtitle }}
  41. <p class="page-subtitle">{{ . | markdownify | emojify }}</p>
  42. {{end}}
  43. {{ partial "page_metadata" (dict "content" $page "is_list" 0) }}
  44. {{ partial "page_links_div.html" $page }}
  45. {{ partial "share.html" $page }}
  46. </div>
  47. </div>
  48. <div class="col-6">
  49. <div class="split-header-image">
  50. <img src="{{ $image.RelPermalink }}" itemprop="image" alt="">
  51. {{ with $.Params.image.caption }}<span class="article-header-caption">{{ . | markdownify | emojify }}</span>{{ end }}
  52. </div>
  53. </div>
  54. </div>
  55. </div>
  56. <div class="article-container d-xl-none">
  57. <h1 itemprop="name">{{ $title }}</h1>
  58. {{ with $page.Params.subtitle }}
  59. <p class="page-subtitle">{{ . | markdownify | emojify }}</p>
  60. {{end}}
  61. {{ partial "page_metadata" (dict "content" $page "is_list" 0 "share" true) }}
  62. {{ partial "page_links_div.html" $page }}
  63. </div>
  64. {{else}}
  65. {{/* Case when page has no image */}}
  66. {{/* Wider container for nodes */}}
  67. {{ $ctnr := "article-container" }}
  68. {{ if $page.IsNode }}
  69. {{ $ctnr = "universal-wrapper" }}
  70. {{end}}
  71. <div class="{{$ctnr}} pt-3">
  72. <h1 itemprop="name">{{ $title }}</h1>
  73. {{ with $page.Params.subtitle }}
  74. <p class="page-subtitle">{{ . | markdownify | emojify }}</p>
  75. {{end}}
  76. {{ if not .IsNode }}
  77. {{ partial "page_metadata" (dict "content" $page "is_list" 0 "share" true) }}
  78. {{ partial "page_links_div.html" $page }}
  79. {{end}}
  80. </div>
  81. {{end}}