article.html 1.4 KB

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