lowtechmag-solar_v2/layouts/partials/opengraph.html

65 wiersze
3.1 KiB
HTML

<meta property="og:title" content="{{ if not .IsHome }}{{ .Title }}{{ else }}{{ .Site.Title }}{{end }}" />
<meta name="twitter:title" content="{{ if not .IsHome }}{{ .Title }}{{ else }}{{ .Site.Title }}{{end }}"/>
<meta property="og:description" content="{{ with .Description }}{{ . }}{{ else }}{{if .IsPage}}{{ .Summary }}{{ else }}{{ with site.Params.description }}{{ . }}{{ end }}{{ end }}{{ end }}" />
<meta name="twitter:description" content="{{ with .Description }}{{ . }}{{ else }}{{if .IsPage}}{{ .Summary }}{{ else }}{{ with .Site.Params.description }}{{ . }}{{ end }}{{ end }}{{ end -}}"/>
<meta property="og:type" content="{{ if .IsPage }}article{{ else }}website{{ end }}" />
<meta property="og:url" content="{{ .Permalink }}" />
{{- if .Params.featured_image -}}
{{ $img := strings.TrimSuffix (path.Ext .Params.featured_image) .Params.featured_image }}
{{ $dithered := (print "images/dithers/" $img "_dithered.png") }}
<meta property="og:image" itemprop="image" content="{{ (path.Join .RelPermalink $dithered ) | absURL }}" />
<meta property="og:image:secure_url" content="{{ (path.Join .RelPermalink $dithered ) | absURL }}" />
<meta property="og:image:type" content="image/png">
<meta name="twitter:card" content="summary_large_image"/>
<meta name="twitter:image" content="{{ (path.Join .RelPermalink $dithered ) | absURL }}"/>
{{ else }}
<meta property="og:image" content="{{ .Site.BaseURL }}icons/sun.svg" />
<meta property="og:image:secure_url" content="{{ .Site.BaseURL }}icons/sun.svg" />
<meta property="og:image:type" content="image/svg+xml">
<meta property="og:image:width" content="300" />
<meta property="og:image:height" content="300" />
<meta name="twitter:card" content="summary"/>
{{- end}}
{{- if .IsPage }}
{{- $iso8601 := "2006-01-02T15:04:05-07:00" -}}
<meta property="article:section" content="{{ .Section }}" />
{{ with .PublishDate }}<meta property="article:published_time" {{ .Format $iso8601 | printf "content=%q" | safeHTMLAttr }} />{{ end }}
{{ with .Lastmod }}<meta property="article:modified_time" {{ .Format $iso8601 | printf "content=%q" | safeHTMLAttr }} />{{ end }}
{{- end -}}
{{- with .Site.Title }}<meta property="og:site_name" content="{{ . }}" />{{ end }}
{{- /* If it is part of a series, link to related articles */}}
{{- $permalink := .Permalink }}
{{- $siteSeries := site.Taxonomies.series }}
{{ with .Params.series }}{{- range $name := . }}
{{- $series := index $siteSeries ($name | urlize) }}
{{- range $page := first 6 $series.Pages }}
{{- if ne $page.Permalink $permalink }}<meta property="og:see_also" content="{{ $page.Permalink }}" />{{ end }}
{{- end }}
{{ end }}{{ end }}
{{- if .IsPage }}
{{ if .Params.authors }}
{{- range .Params.authors}}
<meta property="article:author" content="{{ . }}" />
<meta name="citation_author" content="{{ . }}">
{{ end }}
{{ else }}
<meta property="article:author" content="{{ .Site.Params.Author }}" />
<meta name="citation_author" content="{{ .Site.Params.Author }}">
{{ end }}
{{- with .Params.tags }}{{ range first 6 . }}
<meta property="article:tag" content="{{ . }}" />{{ end }}
{{- end }}{{ end }}