refactor(head/opengraph): split code into modules
This commit is contained in:
parent
03f91c36b2
commit
5f7e818b92
@ -40,6 +40,7 @@ DefaultContentLanguage = "en" # Theme i18n support
|
|||||||
[params.opengraph]
|
[params.opengraph]
|
||||||
[params.opengraph.twitter]
|
[params.opengraph.twitter]
|
||||||
site = ""
|
site = ""
|
||||||
|
card = "summary_large_image"
|
||||||
[params.defaultImage]
|
[params.defaultImage]
|
||||||
[params.defaultImage.article]
|
[params.defaultImage.article]
|
||||||
enabled = false
|
enabled = false
|
||||||
|
@ -9,7 +9,7 @@
|
|||||||
{{ partial "head/style.html" . }}
|
{{ partial "head/style.html" . }}
|
||||||
{{ partial "head/script.html" . }}
|
{{ partial "head/script.html" . }}
|
||||||
|
|
||||||
{{ partial "head/opengraph.html" . }}
|
{{ partial "head/opengraph/include.html" . }}
|
||||||
|
|
||||||
{{ range .AlternativeOutputFormats -}}
|
{{ range .AlternativeOutputFormats -}}
|
||||||
<link rel="{{ .Rel }}" type="{{ .MediaType.Type }}" href="{{ .Permalink | safeURL }}">
|
<link rel="{{ .Rel }}" type="{{ .MediaType.Type }}" href="{{ .Permalink | safeURL }}">
|
||||||
|
2
layouts/partials/head/opengraph/include.html
Normal file
2
layouts/partials/head/opengraph/include.html
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
{{ partial "head/opengraph/provider/base" . }}
|
||||||
|
{{ partial "head/opengraph/provider/twitter" . }}
|
@ -10,12 +10,6 @@
|
|||||||
{{- end -}}
|
{{- end -}}
|
||||||
'>
|
'>
|
||||||
|
|
||||||
{{ with .Site.Params.opengraph.twitter.site }}
|
|
||||||
<meta name="twitter:site" content="{{ . }}">
|
|
||||||
{{ end }}
|
|
||||||
<meta name="twitter:title" content="{{ partial "data/title" . }}">
|
|
||||||
<meta name="twitter:description" content="{{ chomp (partial "data/description" . | plainify ) }}">
|
|
||||||
|
|
||||||
{{- with .Params.locale -}}
|
{{- with .Params.locale -}}
|
||||||
<meta property='og:locale' content='{{ . }}'>
|
<meta property='og:locale' content='{{ . }}'>
|
||||||
{{- end -}}
|
{{- end -}}
|
||||||
@ -42,7 +36,5 @@
|
|||||||
|
|
||||||
{{ $image := partial "helper/image" (dict "Context" . "Type" "opengraph") }}
|
{{ $image := partial "helper/image" (dict "Context" . "Type" "opengraph") }}
|
||||||
{{- if $image.exists -}}
|
{{- if $image.exists -}}
|
||||||
<meta name="twitter:card" content="summary_large_image">
|
|
||||||
<meta property='og:image' content='{{ absURL $image.permalink }}' />
|
<meta property='og:image' content='{{ absURL $image.permalink }}' />
|
||||||
<meta name="twitter:image" content='{{ absURL $image.permalink }}' />
|
|
||||||
{{- end -}}
|
{{- end -}}
|
12
layouts/partials/head/opengraph/provider/twitter.html
Normal file
12
layouts/partials/head/opengraph/provider/twitter.html
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
{{- with .Site.Params.opengraph.twitter.site -}}
|
||||||
|
<meta name="twitter:site" content="{{ . }}">
|
||||||
|
{{- end -}}
|
||||||
|
|
||||||
|
<meta name="twitter:title" content="{{ partial "data/title" . }}">
|
||||||
|
<meta name="twitter:description" content="{{ chomp (partial "data/description" . | plainify ) }}">
|
||||||
|
|
||||||
|
{{- $image := partial "helper/image" (dict "Context" . "Type" "opengraph") -}}
|
||||||
|
{{- if $image.exists -}}
|
||||||
|
<meta name="twitter:card" content="{{ .Site.Params.opengraph.twitter.card }}">
|
||||||
|
<meta name="twitter:image" content='{{ absURL $image.permalink }}' />
|
||||||
|
{{- end -}}
|
Loading…
Reference in New Issue
Block a user