chore: cleanup meta tags (#208)

This commit is contained in:
Robert Kaussow 2022-02-14 22:58:34 +01:00 committed by GitHub
parent e27b8db64a
commit 0000409601
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 26 additions and 23 deletions

View File

@ -5,9 +5,9 @@
{{- if not (eq .Kind "home") }} {{- if not (eq .Kind "home") }}
{{- $title = printf `%s on %s` (partial "utils/title" .) $title -}} {{- $title = printf `%s on %s` (partial "utils/title" .) $title -}}
{{- end }} {{- end }}
<title>{{ trim ($title | plainify) "\n" | safeHTML }}</title> <title>{{ $title }}</title>
{{- with .Site.Params.subtitle }} {{- with .Site.Params.subtitle }}
<subtitle>{{ trim (. | plainify) "\n" | safeHTML }}</subtitle> <subtitle>{{ . }}</subtitle>
{{- end }} {{- end }}
{{- $output_formats := .OutputFormats -}} {{- $output_formats := .OutputFormats -}}
{{- range $output_formats -}} {{- range $output_formats -}}
@ -34,7 +34,7 @@
{{- end -}} {{- end -}}
{{- range $page := $pages }} {{- range $page := $pages }}
<entry> <entry>
<title>{{ trim (partial "utils/title" . | plainify) "\n" | safeHTML }}</title> <title>{{ partial "utils/title" . }}</title>
<link href="{{ .Permalink }}" rel="alternate" type="text/html" {{ with .Site.Language.Lang }} hreflang="{{ . }}"{{ end }} /> <link href="{{ .Permalink }}" rel="alternate" type="text/html" {{ with .Site.Language.Lang }} hreflang="{{ . }}"{{ end }} />
<id>{{ .Permalink }}</id> <id>{{ .Permalink }}</id>
{{- with .Params.authors }} {{- with .Params.authors }}

View File

@ -7,7 +7,7 @@
{{- $authors := default (slice .Site.Params.GeekblogAuthor) .Params.authors -}} {{- $authors := default (slice .Site.Params.GeekblogAuthor) .Params.authors -}}
{{- with partial "utils/description" . }} {{- with partial "utils/description" . }}
<meta name="description" content="{{ trim (. | plainify) "\n" | safeHTMLAttr }}" /> <meta name="description" content="{{ . | plainify | htmlUnescape | chomp }}" />
{{- end }} {{- end }}
{{- with $keywords }} {{- with $keywords }}
<meta name="keywords" content="{{ delimit . "," }}" /> <meta name="keywords" content="{{ delimit . "," }}" />

View File

@ -1,14 +1,17 @@
{{- if not (eq .Kind "home") }} {{- if not (eq .Kind "home") }}
<meta property="og:title" content="{{ partial "utils/title" . }}" /> <meta
property="og:title"
{{ partial "utils/title" . | printf "content=%q" | safeHTMLAttr }}
/>
{{- end }} {{- end }}
{{- with .Site.Title }} {{- with .Site.Title }}
<meta property="og:site_name" content="{{ . }}" /> <meta property="og:site_name" {{ . | printf "content=%q" | safeHTMLAttr }} />
{{- end }} {{- end }}
{{- with partial "utils/featured" . }} {{- with partial "utils/featured" . }}
<meta property="og:image" content="{{ . }}" /> <meta property="og:image" content="{{ . }}" />
{{- end }} {{- end }}
{{- with partial "utils/description" . }} {{- with partial "utils/description" . }}
<meta property="og:description" content="{{ trim (. | plainify) "\n" | safeHTMLAttr }}" /> <meta property="og:description" content="{{ . | plainify | htmlUnescape | chomp }}" />
{{- end }} {{- end }}
<meta property="og:type" content="{{ if .IsPage }}article{{ else }}website{{ end }}" /> <meta property="og:type" content="{{ if .IsPage }}article{{ else }}website{{ end }}" />
<meta property="og:url" content="{{ .Permalink }}" /> <meta property="og:url" content="{{ .Permalink }}" />

View File

@ -6,13 +6,13 @@
{{ with .Site.Params.GeekblogAuthor -}} {{ with .Site.Params.GeekblogAuthor -}}
{{ with index $.Site.Data.authors . }}"author": "{{ .name }}",{{ end }} {{ with index $.Site.Data.authors . }}"author": "{{ .name }}",{{ end }}
{{- end }} {{- end }}
"name": "{{ .Site.Title }}", "name": {{ .Site.Title }},
"url": {{ .Site.BaseURL | jsonify | safeJS }}, "url": {{ .Site.BaseURL }},
{{- with partial "utils/description" . }} {{- with partial "utils/description" . }}
"description": {{ trim (. | plainify) "\n" | jsonify | safeJS }}, "description": "{{ . | plainify | htmlUnescape | chomp }}",
{{- end }} {{- end }}
{{- with partial "utils/featured" . }} {{- with partial "utils/featured" . }}
"thumbnailUrl": {{ . | jsonify | safeJS }}, "thumbnailUrl": {{ . }},
{{- end }} {{- end }}
{{- with .Site.Params.GeekblogContentLicense }} {{- with .Site.Params.GeekblogContentLicense }}
"license": "{{ .name }}", "license": "{{ .name }}",
@ -30,17 +30,17 @@
"@context": "http://schema.org", "@context": "http://schema.org",
"@type": "BlogPosting", "@type": "BlogPosting",
"articleSection": "{{ .Section | humanize | title }}", "articleSection": "{{ .Section | humanize | title }}",
"name": "{{ (partial "utils/title" .) | safeJS }}", "name": {{ partial "utils/title" . }},
"url" : {{ .Permalink | jsonify | safeJS }}, "url" : {{ .Permalink }},
"headline": "{{ (partial "utils/title" .) | safeJS }}", "headline": {{ partial "utils/title" . }},
{{- with .Params.lead }} {{- with .Params.lead }}
"alternativeHeadline": "{{ . }}", "alternativeHeadline": {{ . }},
{{- end }} {{- end }}
{{- with partial "utils/description" . }} {{- with .Summary }}
"description": {{ trim (. | plainify) "\n" | jsonify | safeJS }}, "description": "{{ . | plainify | htmlUnescape | chomp }}",
{{- end }} {{- end }}
{{- with partial "utils/featured" . }} {{- with partial "utils/featured" . }}
"thumbnailUrl": {{ . | jsonify | safeJS }}, "thumbnailUrl": {{ . }},
{{- end }} {{- end }}
"wordCount" : "{{ .WordCount }}", "wordCount" : "{{ .WordCount }}",
{{- with .Site.Params.GeekblogContentLicense }} {{- with .Site.Params.GeekblogContentLicense }}
@ -50,7 +50,7 @@
"isFamilyFriendly": "true", "isFamilyFriendly": "true",
"mainEntityOfPage": { "mainEntityOfPage": {
"@type": "WebPage", "@type": "WebPage",
"@id": {{ .Permalink | jsonify | safeJS }} "@id": {{ .Permalink }}
}, },
{{- with $tags := .Params.tags }} {{- with $tags := .Params.tags }}
"keywords" : [ {{ range $i, $tag := $tags }}{{ if $i }}, {{ end }}"{{ $tag }}" {{ end }}], "keywords" : [ {{ range $i, $tag := $tags }}{{ if $i }}, {{ end }}"{{ $tag }}" {{ end }}],
@ -77,10 +77,10 @@
"publisher":{ "publisher":{
"@type":"Organization", "@type":"Organization",
"name": {{ .Site.Title }}, "name": {{ .Site.Title }},
"url": {{ .Site.BaseURL | jsonify | safeJS }}, "url": {{ .Site.BaseURL }},
"logo": { "logo": {
"@type": "ImageObject", "@type": "ImageObject",
"url": {{ (default "brand.svg" .Site.Params.logo) | absURL | jsonify | safeJS }}, "url": {{ (default "brand.svg" .Site.Params.logo) | absURL }},
"width":"32", "width":"32",
"height":"32" "height":"32"
} }

View File

@ -3,12 +3,12 @@
{{- else }} {{- else }}
<meta name="twitter:card" content="summary" /> <meta name="twitter:card" content="summary" />
{{- end }} {{- end }}
<meta name="twitter:title" content="{{ partial "utils/title" . }}" /> <meta name="twitter:title" {{ partial "utils/title" . | printf "content=%q" | safeHTMLAttr }} />
{{- with partial "utils/featured" . }} {{- with partial "utils/featured" . }}
<meta property="twitter:image" content="{{ . }}" /> <meta property="twitter:image" content="{{ . }}" />
{{- end }} {{- end }}
{{- with partial "utils/description" . }} {{- with partial "utils/description" . }}
<meta name="twitter:description" content="{{ trim (. | plainify) "\n" | safeHTMLAttr }}" /> <meta name="twitter:description" content="{{ . | plainify | htmlUnescape | chomp }}" />
{{- end }} {{- end }}
{{- with .Site.Social.twitter -}} {{- with .Site.Social.twitter -}}
<meta name="twitter:site" content="@{{ . }}" /> <meta name="twitter:site" content="@{{ . }}" />