Hugo theme.
No puede seleccionar más de 25 temas Los temas deben comenzar con una letra o número, pueden incluir guiones ('-') y pueden tener hasta 35 caracteres de largo.

43 líneas
2.3 KiB

  1. <!-- From: https://gitlab.com/kaushalmodi/hugo-theme-refined/blob/b627ec997ad83e058b4cc817397fa1a3f0ce0b74/layouts/partials/twitter_cards.html
  2. via: https://discourse.gohugo.io/t/links-for-images-videos-audio-in-internal-templates-twitter-cards-and-opengraph/10464 -->
  3. {{ $permalink := .Permalink }}
  4. {{- with $.Params.images -}}
  5. <meta name="twitter:card" content="summary_large_image"/>
  6. <!-- As per https://developer.twitter.com/en/docs/tweets/optimize-with-cards/overview/summary-card-with-large-image,
  7. the required card property is "twitter:image", not "twitter:image:src". -->
  8. {{- $image := (index . 0) -}}
  9. {{- $image_link_absolute := (findRE "^/" $image) -}}
  10. {{- if $image_link_absolute -}}
  11. <meta name="twitter:image" content="{{- $image | absURL -}}"/>
  12. {{- else -}}
  13. <meta name="twitter:image" content="{{- (printf "%s%s" $permalink $image) -}}"/>
  14. {{- end -}}
  15. {{ else -}}
  16. {{- $images := $.Resources.ByType "image" -}}
  17. {{- $featured := $images.GetMatch "*feature*" -}}
  18. {{- $featured := cond (ne $featured nil) $featured ($images.GetMatch "{*cover*,*thumbnail*}") -}}
  19. {{- with $featured -}}
  20. <meta name="twitter:card" content="summary_large_image"/>
  21. <meta name="twitter:image" content="{{ $featured.Permalink }}"/>
  22. {{- else -}}
  23. {{- with $.Site.Params.images -}}
  24. <meta name="twitter:card" content="summary_large_image"/>
  25. {{- $image := (index . 0) -}}
  26. {{- $image_link_absolute := (findRE "^/" $image) -}}
  27. {{- if $image_link_absolute -}}
  28. <meta name="twitter:image" content="{{- $image | absURL -}}"/>
  29. {{- else -}}
  30. <meta name="twitter:image" content="{{- (printf "%s%s" $permalink $image) -}}"/>
  31. {{- end -}}
  32. {{ else -}}
  33. <meta name="twitter:card" content="summary"/>
  34. {{- end -}}
  35. {{- end -}}
  36. {{- end }}
  37. <meta name="twitter:title" content="{{ .Title }}"/>
  38. <meta name="twitter:description" content="{{ with .Description }}{{ . }}{{ else }}{{if .IsPage}}{{ .Summary }}{{ else }}{{ with .Site.Params.description }}{{ . }}{{ end }}{{ end }}{{ end -}}"/>
  39. {{ with .Site.Social.twitter -}}
  40. <meta name="twitter:site" content="@{{ . }}"/>
  41. <meta name="twitter:creator" content="@{{ . }}"/>
  42. {{ end -}}