remove shits from opengraph

This commit is contained in:
Reorx 2022-05-08 22:42:23 +08:00
parent 7cb2efee6b
commit ff8b16b194
2 changed files with 32 additions and 38 deletions

View File

@ -78,7 +78,11 @@
{{- /* https://developer.twitter.com/en/docs/twitter-for-websites/cards/guides/getting-started */}} {{- /* https://developer.twitter.com/en/docs/twitter-for-websites/cards/guides/getting-started */}}
{{- if .Params.cover.image }} {{- if .Params.cover.image }}
<meta name="twitter:image" content="{{ (path.Join .RelPermalink .Params.cover.image ) | absURL }}" /> <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:card" property="twitter:card" content="summary_large_image" />
<meta name="twitter:title" content="{{ $pageTitle }}" /> <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 -}}" /> <meta name="twitter:description" content="{{ with .Description }}{{ . }}{{ else }}{{if .IsPage}}{{ .Summary }}{{ else }}{{ with site.Params.description }}{{ . }}{{ end }}{{ end }}{{ end -}}" />

View File

@ -10,20 +10,10 @@
<meta property="og:image" content="{{ (path.Join .RelPermalink .Params.cover.image ) | absURL }}" /> <meta property="og:image" content="{{ (path.Join .RelPermalink .Params.cover.image ) | absURL }}" />
{{- end}} {{- end}}
{{- else }} {{- else }}
{{- range site.Params.images }}
{{- with $.Params.images -}} <meta property="og:image" content="{{ . | absURL }}"/>
{{- 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 }} {{- end }}
{{ end }}
{{- if .IsPage }} {{- if .IsPage }}
{{- $iso8601 := "2006-01-02T15:04:05-07:00" -}} {{- $iso8601 := "2006-01-02T15:04:05-07:00" -}}
@ -35,21 +25,21 @@
{{- with .Params.audio }}<meta property="og:audio" content="{{ . }}" />{{ end }} {{- with .Params.audio }}<meta property="og:audio" content="{{ . }}" />{{ end }}
{{- with .Params.locale }}<meta property="og:locale" content="{{ . }}" />{{ end }} {{- with .Params.locale }}<meta property="og:locale" content="{{ . }}" />{{ end }}
{{- with site.Params.title }}<meta property="og:site_name" content="{{ . }}" />{{ end }} {{- with site.Params.title }}<meta property="og:site_name" content="{{ . }}" />{{ end }}
{{- with .Params.videos }}{{- range . }} {{- with .Params.videos }}
{{- range . }}
<meta property="og:video" content="{{ . | absURL }}" /> <meta property="og:video" content="{{ . | absURL }}" />
{{ end }}{{ end }} {{- end }}
{{- end }}
{{- /* If it is part of a series, link to related articles */}} {{- /* If it is part of a series, link to related articles */}}
{{- $permalink := .Permalink }} {{- $permalink := .Permalink }}
{{- $siteSeries := site.Taxonomies.series }} {{- $siteSeries := site.Taxonomies.series }}
{{ with .Params.series }}{{- range $name := . }} {{- with .Params.series }}
{{- range $name := . }}
{{- $series := index $siteSeries ($name | urlize) }} {{- $series := index $siteSeries ($name | urlize) }}
{{- range $page := first 6 $series.Pages }} {{- range $page := first 6 $series.Pages }}
{{- if ne $page.Permalink $permalink }}<meta property="og:see_also" content="{{ $page.Permalink }}" />{{ end }} {{- if ne $page.Permalink $permalink }}<meta property="og:see_also" content="{{ $page.Permalink }}" />{{ end }}
{{- end }} {{- end -}}
{{ end }}{{ end }} {{- end -}}
{{- end -}}
{{- /* Facebook Page Admin ID for Domain Insights */}} {{- end -}}
{{- with site.Social.facebook_admin }}<meta property="fb:admins" content="{{ . }}" />{{ end }}
{{- end }}