event.html 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. {{ $page := .page }}
  2. {{ $summary := .summary }}
  3. {{ $featured_image := ($page.Resources.ByType "image").GetMatch "*featured*" }}
  4. {{/* Get author name. */}}
  5. {{ $author_username := "" }}
  6. {{ if and (not $page.Params.authors) ($page.Scratch.Get "superuser_username") }}
  7. {{ $author_username = $page.Scratch.Get "superuser_username" }}
  8. {{ else if $page.Params.authors }}
  9. {{ $author_username = index $page.Params.authors 0 }}
  10. {{ end }}
  11. {{ $author := "" }}
  12. {{ $taxonomy := "authors" }}
  13. {{ $profile_page := site.GetPage (printf "/%s/%s" $taxonomy $author_username) }}
  14. {{ with $profile_page }}
  15. {{ $author = .Params.name | default .Title }}
  16. {{ end }}
  17. <script type="application/ld+json">
  18. {
  19. "@context": "https://schema.org",
  20. "@type": "Event",
  21. "mainEntityOfPage": {
  22. "@type": "WebPage",
  23. "@id": {{$page.Permalink}}
  24. },
  25. "name": {{$page.Title}},
  26. {{ with $page.Params.location }}
  27. "location": {
  28. "@type": "Place",
  29. "name": {{. | plainify}}
  30. },
  31. {{end}}
  32. {{ if $featured_image }}
  33. "image": [
  34. {{$featured_image.Permalink}}
  35. ],
  36. {{end}}
  37. "startDate": {{ $page.Date.Format "2006-01-02T15:04:05Z07:00" }},
  38. {{with $page.Params.date_end}}
  39. "endDate": {{ (time .).Format "2006-01-02T15:04:05Z07:00" }},
  40. {{end}}
  41. {{with $author}}
  42. "performer": {
  43. "@type": "Person",
  44. "name": {{.}}
  45. },
  46. {{end}}
  47. "description": {{$summary}}
  48. }
  49. </script>