diff options
| author | Reorx <novoreorx@gmail.com> | 2022-05-08 22:42:23 +0800 |
|---|---|---|
| committer | Reorx <novoreorx@gmail.com> | 2022-05-08 22:42:23 +0800 |
| commit | ff8b16b19416c2187ad935c1c3d5392ec0b870a7 (patch) | |
| tree | bcc028be614a9a2576542c3b5040b784c8b67d6f | |
| parent | 7cb2efee6bb1cb602cd022031369a5f8c821db42 (diff) | |
remove shits from opengraph
| -rw-r--r-- | layouts/partials/head.html | 6 | ||||
| -rw-r--r-- | layouts/partials/templates/opengraph.html | 64 |
2 files changed, 32 insertions, 38 deletions
diff --git a/layouts/partials/head.html b/layouts/partials/head.html index 36775ce..cdae3e5 100644 --- a/layouts/partials/head.html +++ b/layouts/partials/head.html @@ -78,7 +78,11 @@ {{- /* https://developer.twitter.com/en/docs/twitter-for-websites/cards/guides/getting-started */}} {{- if .Params.cover.image }} <meta name="twitter:image" content="{{ (path.Join .RelPermalink .Params.cover.image ) | absURL }}" /> -{{- end -}} +{{- else }} + {{- with site.Params.images -}} + <meta name="twitter:image" content="{{ index . 0 | absURL }}" /> + {{- end }} +{{- end }} <meta name="twitter:card" property="twitter:card" content="summary_large_image" /> <meta name="twitter:title" content="{{ $pageTitle }}" /> <meta name="twitter:description" content="{{ with .Description }}{{ . }}{{ else }}{{if .IsPage}}{{ .Summary }}{{ else }}{{ with site.Params.description }}{{ . }}{{ end }}{{ end }}{{ end -}}" /> diff --git a/layouts/partials/templates/opengraph.html b/layouts/partials/templates/opengraph.html index 4a1de00..23477ca 100644 --- a/layouts/partials/templates/opengraph.html +++ b/layouts/partials/templates/opengraph.html @@ -4,52 +4,42 @@ <meta property="og:type" content="{{ if .IsPage }}article{{ else }}website{{ end }}" /> <meta property="og:url" content="{{ .Permalink }}" /> {{- if .Params.cover.image -}} -{{- if (eq .Params.cover.absolute true) }} -<meta property="og:image" content="{{ .Params.cover.image | absURL }}" /> -{{- else}} -<meta property="og:image" content="{{ (path.Join .RelPermalink .Params.cover.image ) | absURL }}" /> -{{- end}} + {{- if (eq .Params.cover.absolute true) }} + <meta property="og:image" content="{{ .Params.cover.image | absURL }}" /> + {{- else}} + <meta property="og:image" content="{{ (path.Join .RelPermalink .Params.cover.image ) | absURL }}" /> + {{- end}} {{- else }} - -{{- with $.Params.images -}} -{{- range first 6 . }}<meta property="og:image" content="{{ . | absURL }}" />{{ end -}} -{{- else -}} -{{- $images := $.Resources.ByType "image" -}} -{{- $featured := $images.GetMatch "*feature*" -}} -{{- if not $featured }}{{ $featured = $images.GetMatch "{*cover*,*thumbnail*}" }}{{ end -}} -{{- with $featured -}} -<meta property="og:image" content="{{ $featured.Permalink }}"/> -{{- else -}} -{{- with site.Params.images }}<meta property="og:image" content="{{ index . 0 | absURL }}"/>{{ end -}} -{{- end -}} -{{- end -}} -{{- end }} + {{- range site.Params.images }} + <meta property="og:image" content="{{ . | absURL }}"/> + {{- end }} +{{ end }} {{- if .IsPage }} -{{- $iso8601 := "2006-01-02T15:04:05-07:00" -}} -<meta property="article:section" content="{{ .Section }}" /> -{{ with .PublishDate }}<meta property="article:published_time" content="{{ .Format $iso8601 }}" />{{ end }} -{{ with .Lastmod }}<meta property="article:modified_time" content="{{ .Format $iso8601 }}" />{{ end }} + {{- $iso8601 := "2006-01-02T15:04:05-07:00" -}} + <meta property="article:section" content="{{ .Section }}" /> + {{ with .PublishDate }}<meta property="article:published_time" content="{{ .Format $iso8601 }}" />{{ end }} + {{ with .Lastmod }}<meta property="article:modified_time" content="{{ .Format $iso8601 }}" />{{ end }} {{- end -}} {{- with .Params.audio }}<meta property="og:audio" content="{{ . }}" />{{ end }} {{- with .Params.locale }}<meta property="og:locale" content="{{ . }}" />{{ end }} {{- with site.Params.title }}<meta property="og:site_name" content="{{ . }}" />{{ end }} -{{- with .Params.videos }}{{- range . }} -<meta property="og:video" content="{{ . | absURL }}" /> -{{ end }}{{ end }} +{{- with .Params.videos }} + {{- range . }} + <meta property="og:video" content="{{ . | absURL }}" /> + {{- end }} +{{- 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 }} - -{{- /* Facebook Page Admin ID for Domain Insights */}} -{{- with site.Social.facebook_admin }}<meta property="fb:admins" content="{{ . }}" />{{ end }} - -{{- end }} +{{- 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 -}} +{{- end -}} |
