event.html 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  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}}{{if $page.Params.address}},
  30. "address": {
  31. "@type": "PostalAddress",
  32. "streetAddress": {{$page.Params.address.street | default ""}},
  33. "addressLocality": {{$page.Params.address.city | default ""}},
  34. "postalCode": {{$page.Params.address.postcode | default ""}},
  35. "addressRegion": {{$page.Params.address.region | default ""}},
  36. "addressCountry": {{$page.Params.address.country | default ""}}
  37. }
  38. {{end}}
  39. },
  40. {{end}}
  41. {{ if $featured_image }}
  42. "image": [
  43. {{$featured_image.Permalink}}
  44. ],
  45. {{end}}
  46. "startDate": {{ $page.Date.Format "2006-01-02T15:04:05Z07:00" }},
  47. {{with $page.Params.date_end}}
  48. "endDate": {{ (time .).Format "2006-01-02T15:04:05Z07:00" }},
  49. {{end}}
  50. {{with $author}}
  51. "performer": {
  52. "@type": "Person",
  53. "name": {{.}}
  54. },
  55. {{end}}
  56. "description": {{$summary}}
  57. }
  58. </script>