You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

81 lines
3.3 KiB

4 years ago
  1. {{/*
  2. Copyright (C) 2019 Josh Habdas <jhabdas@protonmail.com>
  3. This file is part of After Dark.
  4. After Dark is free software: you can redistribute it and/or modify
  5. it under the terms of the GNU Affero General Public License as published by
  6. the Free Software Foundation, either version 3 of the License, or
  7. (at your option) any later version.
  8. After Dark is distributed in the hope that it will be useful,
  9. but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  11. GNU Affero General Public License for more details.
  12. You should have received a copy of the GNU Affero General Public License
  13. along with this program. If not, see <https://www.gnu.org/licenses/>.
  14. */}}
  15. {{ with $.Resources.GetMatch "*header*" }}
  16. {{ $meta_sameas := .Params.meta.sameas }}
  17. {{ $meta_license := .Params.meta.license }}
  18. {{ $meta_creator := .Params.meta.creator }}
  19. {{ $meta_description := .Params.meta.description }}
  20. {{ $meta_keywords := .Params.meta.keywords }}
  21. {{ $meta_contentlocation := .Params.meta.contentlocation }}
  22. {{ $image300 := .Fill "300x169 q20 Center" }}
  23. {{ $image600 := .Fill "600x338 q60 Center" }}
  24. {{ $image900 := .Fill "900x506 q70 Center" }}
  25. {{ $image1200 := .Fill "1200x675 q80 Center" }}
  26. {{ $image1600 := .Fill "1600x900 q90 Center" }}
  27. <figure class="ratio-container" aria-hidden="true" itemscope itemtype="https://schema.org/ImageObject">
  28. <link itemprop="contentUrl" href="{{ .RelPermalink }}">
  29. <meta itemprop="encodingFormat" content="{{ .MediaType }}">
  30. <meta itemprop="name" content="{{ .Name | plainify }}">
  31. {{ if (urls.Parse $meta_sameas).Host }}
  32. <link itemprop="sameAs" href="{{ $meta_sameas }}">
  33. {{ end }}
  34. {{ if (urls.Parse $meta_license).Host }}
  35. <link itemprop="license" href="{{ $meta_license }}">
  36. {{ end }}
  37. {{ with $meta_keywords }}
  38. <meta itemprop="keywords" content="{{ delimit . ", " }}">
  39. {{ end }}
  40. {{ with $meta_contentlocation }}
  41. <meta itemprop="contentLocation" content="{{ . | plainify }}">
  42. {{ end }}
  43. {{ with $meta_description }}
  44. <meta itemprop="description" content="{{ . | plainify }}">
  45. {{ end }}
  46. <img
  47. itemprop="thumbnailUrl"
  48. alt="{{ with $meta_description }}{{ . }}{{ else }}{{ .Name | plainify }}{{ end }}"
  49. class="lazyload blur-up"
  50. src="{{ $image600.RelPermalink }}"
  51. srcset="{{ $image300.RelPermalink }}"
  52. data-srcset="{{ $image300.RelPermalink }} 300w, {{ $image600.RelPermalink }} 600w, {{ $image900.RelPermalink }} 900w, {{ $image1200.RelPermalink }} 1200w, {{ $image1600.RelPermalink }} 1600w"
  53. data-sizes="auto"
  54. >
  55. {{ if or (not (path.Ext .Title)) (or $meta_creator $meta_sameas) }}
  56. <figcaption itemprop="caption">
  57. {{ if not (path.Ext .Title) }}
  58. <span itemprop="headline">{{ .Title | plainify }}</span>.
  59. {{ end }}
  60. {{ if or $meta_creator $meta_sameas }}
  61. Photo
  62. {{ if $meta_creator }}
  63. by
  64. <span itemprop="creator">
  65. {{ $meta_creator | plainify -}}
  66. </span>
  67. {{- end }}
  68. {{- with (urls.Parse $meta_sameas).Host }}
  69. on
  70. {{ (strings.TrimSuffix (path.Ext .) .) | title }}
  71. {{- end }}.
  72. {{ end }}
  73. </figcaption>
  74. {{ end }}
  75. </figure>
  76. {{ end }}