mirror of
https://github.com/CaiJimmy/hugo-theme-stack.git
synced 2024-11-23 10:21:46 +01:00
refactor(opengraph): add default value for twitter:card (#72)
This commit is contained in:
parent
d205753323
commit
25a72940b8
3 changed files with 24 additions and 21 deletions
|
@ -62,7 +62,10 @@ params:
|
|||
|
||||
opengraph:
|
||||
twitter:
|
||||
# Your Twitter username
|
||||
site:
|
||||
|
||||
# Available values: summary, summary_large_image
|
||||
card: summary_large_image
|
||||
|
||||
defaultImage:
|
||||
|
|
|
@ -6,35 +6,35 @@
|
|||
<meta property='og:url' content='{{ .Permalink }}'>
|
||||
<meta property='og:site_name' content='{{ .Site.Title }}'>
|
||||
<meta property='og:type' content='
|
||||
{{- if .IsPage -}}
|
||||
article
|
||||
{{- else -}}
|
||||
website
|
||||
{{- end -}}
|
||||
{{- if .IsPage -}}
|
||||
article
|
||||
{{- else -}}
|
||||
website
|
||||
{{- end -}}
|
||||
'>
|
||||
|
||||
{{- with .Params.locale -}}
|
||||
<meta property='og:locale' content='{{ . }}'>
|
||||
<meta property='og:locale' content='{{ . }}'>
|
||||
{{- end -}}
|
||||
|
||||
{{- if .IsPage -}}
|
||||
<meta property='article:section' content='{{ .Section | title }}' />
|
||||
{{- range .Params.tags -}}
|
||||
<meta property='article:tag' content='{{ . }}' />
|
||||
{{- end -}}
|
||||
<meta property='article:section' content='{{ .Section | title }}' />
|
||||
{{- range .Params.tags -}}
|
||||
<meta property='article:tag' content='{{ . }}' />
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
|
||||
{{- if .IsPage -}}
|
||||
{{- 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 -}}
|
||||
{{- 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 .Site.LastChange.IsZero -}}
|
||||
<meta property='og:updated_time' content='{{ .Site.LastChange.Format " 2006-01-02T15:04:05-07:00 " | safeHTML }}'/>
|
||||
{{- end -}}
|
||||
{{- if not .Site.LastChange.IsZero -}}
|
||||
<meta property='og:updated_time' content='{{ .Site.LastChange.Format " 2006-01-02T15:04:05-07:00 " | safeHTML }}'/>
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
|
||||
{{ $image := partialCached "helper/image" (dict "Context" . "Type" "opengraph") .RelPermalink "opengraph" }}
|
||||
|
|
|
@ -10,6 +10,6 @@
|
|||
|
||||
{{- $image := partialCached "helper/image" (dict "Context" . "Type" "opengraph") .RelPermalink "opengraph" -}}
|
||||
{{- if $image.exists -}}
|
||||
<meta name="twitter:card" content="{{ .Site.Params.opengraph.twitter.card }}">
|
||||
<meta name="twitter:image" content='{{ absURL $image.permalink }}' />
|
||||
<meta name="twitter:card" content="{{ default `summary_large_image` .Site.Params.opengraph.twitter.card }}">
|
||||
<meta name="twitter:image" content='{{ absURL $image.permalink }}' />
|
||||
{{- end -}}
|
Loading…
Reference in a new issue