Add cover image support and improve meta tags

HEAD
Elnu 2 years ago
parent 5787b8d114
commit cdc7e072f2

@ -0,0 +1 @@
{{ .Format "2006-01-02T15:04:05Z07:00" -}}

@ -1,6 +1,46 @@
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
{{ $title := cond .IsHome .Site.Title (printf "%s" .Title | printf "%s%s" (cond (and (eq .Kind "term") (eq .Data.Singular "tag")) "#" "") | printf "%s") }}
<meta property="og:title" content="{{ $title }}">
{{ with .Resources.GetMatch "{cover.*,*.jpg,*.png,*.jpeg}" }}
<meta property="og:image" content="{{ .Permalink | absURL }}">
{{ end }}
{{ with .Params.description }}
<meta property="og:description" content="{{ . }}">
<meta name="description" content="{{ . }}">
{{ end }}
<meta property="og:type" content="{{ cond (eq .Kind "page") "article" "website" }}">
{{ if eq .Kind "page" }}
{{ with .PublishDate }}
<meta property="og:article:published_time" content="{{ partial "datestamp.html" . }}">
{{ end }}
{{ with .Lastmod }}
<meta property="og:article:modified_time" content="{{ partial "datestamp.html" . }}">
{{ end }}
{{ with .ExpiryDate }}
<meta property="og:article:expiration_time" content="{{ partial "datestamp.html" . }}">
{{ end }}
{{ with .Params.tags }}
{{ range . }}
<meta property="og:article:tag" content="{{ . }}">
{{ end }}
{{ end }}
{{ with .Site.Params.AuthorProfile }}
<meta property="og:article:author" content="{{ . }}">
{{ end }}
{{ end }}
{{ with .Site.Params.Author }}
<meta name="author" content="{{ . }}">
{{ end }}
<meta property="og:url" content="{{ .Permalink }}">
<meta name="twitter:card" content="summary">
{{ with .Site.Params.SiteTwitter }}
<meta name="twitter:site" content="@{{ . }}">
{{ end }}
{{ with .Site.Params.AuthorTwitter }}
<meta name="twitter:creator" content="@{{ . }}">
{{ end }}
<link rel="stylesheet" href="/css/normalize.css">
<link rel="stylesheet" href="/css/sakura{{ if isset .Site.Params "theme" }}-{{ .Site.Params.Theme }}{{ end }}.css">
{{ if isset .Site.Params "matomositeid" }}
@ -18,5 +58,5 @@
})();
</script>
{{ end }}
<title>{{ if and (eq .Kind "term") (eq .Data.Singular "tag") }}#{{ end }}{{ .Title }}{{ if not .IsHome }} - {{ .Site.Title }}{{ end }}</title>
<title>{{ $title }}{{ if not .IsHome }} - {{ .Site.Title }}{{ end }}</title>
</head>

@ -1,7 +1,9 @@
{{ with .Resources.GetMatch "{cover.*,*.jpg,*.png,*.jpeg}" }}
<img src="{{ .Permalink }}">
{{ end }}
Posted by {{ .Site.Params.author }} on {{ partial "time.html" . }}
<p>
<br>
{{ range $i, $e := .Params.tags -}}
{{- if $i -}}, {{ end -}}
<a href="{{ "/tags/" | relLangURL }}{{ . | urlize }}" rel="tag">#{{ $e }}</a>
{{- if $i -}}, {{ end -}}
<a href="{{ "/tags/" | relLangURL }}{{ . | urlize }}" rel="tag">#{{ $e }}</a>
{{- end -}}
</p>

@ -1 +1 @@
<time datetime="{{ .Date.Format " 2006-01-02T15:04:05Z07:00" }}">{{ .Date.Format "2006/01/02 15:04" }}</time>
<time datetime="{{ partial "datestamp.html" .Date }}">{{ .Date.Format "2006/01/02 15:04" }}</time>