mirror of
https://gitlab.com/ansol/web-ansol.org.git
synced 2024-11-25 07:33:16 +00:00
48 lines
2.5 KiB
HTML
48 lines
2.5 KiB
HTML
{{- $scr := .Scratch -}}
|
|
{{- $featured_image := (.Resources.ByType "image").GetMatch "*cover*" -}}
|
|
{{- $avatar_image := (.Resources.ByType "image").GetMatch "avatar*" -}}
|
|
{{- $has_logo := fileExists "assets/images/logo.png" | or (fileExists "assets/images/logo.svg") -}}
|
|
{{- $og_image := "" -}}
|
|
{{- $twitter_card := "summary_large_image" -}}
|
|
{{- if (and (eq .Kind "taxonomy") $avatar_image) -}}
|
|
{{- $og_image = ($avatar_image.Fill "270x270 Center").Permalink -}}
|
|
{{- $twitter_card = "summary" -}}
|
|
{{- else if $featured_image -}}
|
|
{{- $og_image = $featured_image.Permalink -}}
|
|
{{- else if .Params.header.image -}}
|
|
{{- $og_image = printf "images/%s" .Params.header.image | absURL -}}
|
|
{{- else if site.Params.sharing_image -}}
|
|
{{- $og_image = printf "img/%s" site.Params.sharing_image | absURL -}}
|
|
{{- else if $has_logo -}}
|
|
{{- $og_image = (partial "functions/get_logo" (dict "constraint" "fit" "size" 300)).Permalink -}}
|
|
{{- $twitter_card = "summary" -}}
|
|
{{- else -}}
|
|
{{- $og_image = (partial "functions/get_icon" 512).Permalink -}}
|
|
{{- $twitter_card = "summary" -}}
|
|
{{- end -}}
|
|
{{- $scr.Set "og_image" $og_image -}}
|
|
<meta property="twitter:card" content="{{ $twitter_card }}">
|
|
{{ with site.Params.twitter -}}
|
|
<meta property="twitter:site" content="@{{ . }}">
|
|
<meta property="twitter:creator" content="@{{ . }}">
|
|
{{ end -}}
|
|
<meta property="og:site_name" content="{{ site.Title }}">
|
|
<meta property="og:url" content="{{ .Permalink }}">
|
|
<meta property="og:title" content="{{ if not .IsHome }}{{ .Title }} | {{ end }}{{ site.Title }}">
|
|
<meta property="og:description" content="{{ $scr.Get "desc" }}">
|
|
{{ with $og_image -}}
|
|
<meta property="og:image" content="{{.}}">
|
|
<meta property="twitter:image" content="{{.}}">
|
|
{{ end -}}
|
|
<meta property="og:locale" content="{{ site.LanguageCode | default "en-us" }}">
|
|
{{ if .IsPage }}
|
|
{{ if not .PublishDate.IsZero }}
|
|
<meta property="article:published_time" content="{{ .PublishDate.Format "2006-01-02T15:04:05-07:00" | safeHTML }}">
|
|
{{ else if not .Date.IsZero }}
|
|
<meta property="article:published_time" content="{{ .Date.Format "2006-01-02T15:04:05-07:00" | safeHTML }}">
|
|
{{ end }}
|
|
{{ if not .Lastmod.IsZero }}<meta property="article:modified_time" content="{{ .Lastmod.Format "2006-01-02T15:04:05-07:00" | safeHTML }}">{{ end }}
|
|
{{ else if not .Date.IsZero -}}
|
|
<meta property="og:updated_time" content="{{ .Date.Format "2006-01-02T15:04:05-07:00" | safeHTML }}">
|
|
{{ end -}}
|