mirror of
https://github.com/thegeeklab/hugo-geekblog.git
synced 2024-11-25 06:20:40 +00:00
feat: add feature or thumbnail image to feeds (#194)
This commit is contained in:
parent
d8d211d6a5
commit
6f0cd03608
@ -19,7 +19,6 @@
|
|||||||
{{ partial "head/rel-me" . }}
|
{{ partial "head/rel-me" . }}
|
||||||
{{ partial "head/microformats" . }}
|
{{ partial "head/microformats" . }}
|
||||||
{{ partial "head/others" . }}
|
{{ partial "head/others" . }}
|
||||||
{{ partial "head/schema.html" . }}
|
|
||||||
{{ partial "head/custom" . }}
|
{{ partial "head/custom" . }}
|
||||||
</head>
|
</head>
|
||||||
|
|
||||||
|
@ -17,6 +17,7 @@
|
|||||||
{{- end -}}
|
{{- end -}}
|
||||||
{{- end }}
|
{{- end }}
|
||||||
<updated>{{ now.Format "2006-01-02T15:04:05-07:00" | safeHTML }}</updated>
|
<updated>{{ now.Format "2006-01-02T15:04:05-07:00" | safeHTML }}</updated>
|
||||||
|
<generator uri="https://gohugo.io" version="{{ hugo.Version }}">Hugo</generator>
|
||||||
{{ with .Site.Params.GeekblogAuthor -}}
|
{{ with .Site.Params.GeekblogAuthor -}}
|
||||||
{{ with index $.Site.Data.authors . }}
|
{{ with index $.Site.Data.authors . }}
|
||||||
<author>
|
<author>
|
||||||
@ -48,7 +49,12 @@
|
|||||||
{{- end }}
|
{{- end }}
|
||||||
<published>{{ .Date.Format "2006-01-02T15:04:05-07:00" | safeHTML }}</published>
|
<published>{{ .Date.Format "2006-01-02T15:04:05-07:00" | safeHTML }}</published>
|
||||||
<updated>{{ .Lastmod.Format "2006-01-02T15:04:05-07:00" | safeHTML }}</updated>
|
<updated>{{ .Lastmod.Format "2006-01-02T15:04:05-07:00" | safeHTML }}</updated>
|
||||||
{{ printf `<content type="html"><![CDATA[%s]]></content>` .Content | safeHTML }}
|
{{- $img := "" -}}
|
||||||
|
{{- with ($page.Resources.ByType "image").GetMatch "{*feature*,*cover*,*thumbnail*}" }}
|
||||||
|
{{- $featured := .Fill (printf "910x280 %s" (default "Smart" .Params.anchor)) -}}
|
||||||
|
{{- $img = printf `<img src="%s" width="%d" height="%d" alt="%s" /><br/>` $featured.Permalink $featured.Width $featured.Height (default (partial "utils/title" $page) .Params.description) -}}
|
||||||
|
{{- end }}
|
||||||
|
{{ printf `<content type="html"><![CDATA[%s%s]]></content>` $img .Content | safeHTML }}
|
||||||
{{ with .Site.Taxonomies }}
|
{{ with .Site.Taxonomies }}
|
||||||
{{ range $taxo,$_ := . }} <!-- Defaults taxos: "tags", "categories" -->
|
{{ range $taxo,$_ := . }} <!-- Defaults taxos: "tags", "categories" -->
|
||||||
{{ with $page.Param $taxo }}
|
{{ with $page.Param $taxo }}
|
||||||
|
@ -36,6 +36,10 @@
|
|||||||
"date_modified" : {{ (.Lastmod.Format "2006-01-02T15:04:05Z07:00") | jsonify }},
|
"date_modified" : {{ (.Lastmod.Format "2006-01-02T15:04:05Z07:00") | jsonify }},
|
||||||
"id" : "{{ .Permalink }}",
|
"id" : "{{ .Permalink }}",
|
||||||
"url" : "{{ .Permalink }}",
|
"url" : "{{ .Permalink }}",
|
||||||
|
{{- with ($page.Resources.ByType "image").GetMatch "{*feature*,*cover*,*thumbnail*}" }}
|
||||||
|
{{- $featured := .Fill (printf "910x280 %s" (default "Smart" .Params.anchor)) -}}
|
||||||
|
"image" : "{{ $featured.Permalink }}",
|
||||||
|
{{- end }}
|
||||||
{{- with .Params.authors -}}
|
{{- with .Params.authors -}}
|
||||||
"authors" : [
|
"authors" : [
|
||||||
{{- $authors := (sort .) }}
|
{{- $authors := (sort .) }}
|
||||||
|
@ -3,25 +3,25 @@
|
|||||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||||
{{ hugo.Generator }}
|
{{ hugo.Generator }}
|
||||||
|
|
||||||
{{ $keywords := default .Site.Params.Keywords .Keywords }}
|
{{- $keywords := default .Site.Params.Keywords .Keywords -}}
|
||||||
{{ $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" }}" />
|
<meta name="description" content="{{ trim (. | plainify) "\n" }}" />
|
||||||
{{ end }}
|
{{- end }}
|
||||||
{{ with $keywords }}
|
{{- with $keywords }}
|
||||||
<meta name="keywords" content="{{ delimit . "," }}" />
|
<meta name="keywords" content="{{ delimit . "," }}" />
|
||||||
{{ end }}
|
{{- end }}
|
||||||
{{ with $authors }}
|
{{- with $authors }}
|
||||||
{{ $list := slice }}
|
{{- $list := slice -}}
|
||||||
{{ range sort . }}
|
{{- range sort . }}
|
||||||
{{ with . }}
|
{{- with . }}
|
||||||
{{ $author := index $.Site.Data.authors . }}
|
{{- $author := index $.Site.Data.authors . -}}
|
||||||
{{ $list = $list | append $author.name }}
|
{{- $list = $list | append $author.name -}}
|
||||||
{{ end }}
|
{{- end }}
|
||||||
{{ end }}
|
{{- end }}
|
||||||
|
|
||||||
{{ with $list }}
|
{{- with $list }}
|
||||||
<meta name="author" content="{{ delimit . "," }}" />
|
<meta name="author" content="{{ delimit . "," }}" />
|
||||||
{{ end }}
|
{{- end }}
|
||||||
{{ end }}
|
{{- end }}
|
||||||
|
@ -1,2 +1,3 @@
|
|||||||
{{ partial "microformats/opengraph.html" . }}
|
{{ partial "microformats/opengraph.html" . }}
|
||||||
{{ partial "microformats/twitter_cards.html" . }}
|
{{ partial "microformats/twitter_cards.html" . }}
|
||||||
|
{{ partial "microformats/schema.html" . }}
|
||||||
|
@ -20,11 +20,11 @@
|
|||||||
<svg class="icon {{ .icon }}"><use xlink:href="#{{ .icon }}"></use></svg>
|
<svg class="icon {{ .icon }}"><use xlink:href="#{{ .icon }}"></use></svg>
|
||||||
{{ end }}
|
{{ end }}
|
||||||
<a
|
<a
|
||||||
href="{{ if .external }}
|
href="{{ if .external -}}
|
||||||
{{ .ref }}
|
{{ .ref }}
|
||||||
{{ else }}
|
{{- else -}}
|
||||||
{{ relref $current .ref }}
|
{{ relref $current .ref }}
|
||||||
{{ end }}"
|
{{- end }}"
|
||||||
class="gblog-footer__link"
|
class="gblog-footer__link"
|
||||||
>
|
>
|
||||||
{{ .name }}
|
{{ .name }}
|
||||||
@ -33,12 +33,12 @@
|
|||||||
{{ else if eq $target "header" }}
|
{{ else if eq $target "header" }}
|
||||||
<li>
|
<li>
|
||||||
<a
|
<a
|
||||||
href="{{ if .external }}
|
href="{{ if .external -}}
|
||||||
{{ .ref }}
|
{{ .ref }}
|
||||||
{{ else }}
|
{{- else -}}
|
||||||
{{ relref $current .ref }}
|
{{ relref $current .ref }}
|
||||||
{{ end }}"
|
{{- end }}"
|
||||||
class="gblog-nav__entry {{ if $isCurrent }}is-active{{ end }}"
|
class="gblog-nav__entry{{ if $isCurrent }}{{ printf " %s" "is-active" }}{{ end }}"
|
||||||
>
|
>
|
||||||
{{ if $icon }}
|
{{ if $icon }}
|
||||||
<svg class="icon {{ .icon }}"><use xlink:href="#{{ .icon }}"></use></svg>
|
<svg class="icon {{ .icon }}"><use xlink:href="#{{ .icon }}"></use></svg>
|
||||||
|
@ -1,67 +1,74 @@
|
|||||||
|
{{- if not (eq .Kind "home") }}
|
||||||
<meta property="og:title" content="{{ partial "utils/title" . }}" />
|
<meta property="og:title" content="{{ partial "utils/title" . }}" />
|
||||||
{{ with partial "utils/description" . }}
|
{{- end }}
|
||||||
|
{{- with .Site.Title }}
|
||||||
|
<meta property="og:site_name" content="{{ . }}" />
|
||||||
|
{{- end }}
|
||||||
|
{{- with partial "utils/description" . }}
|
||||||
<meta property="og:description" content="{{ trim (. | plainify) "\n" }}" />
|
<meta property="og:description" content="{{ trim (. | plainify) "\n" }}" />
|
||||||
{{ 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 }}" />
|
||||||
|
|
||||||
{{- with $.Params.images -}}
|
{{- with $.Params.images }}
|
||||||
{{- range first 6 . }}<meta property="og:image" content="{{ . | absURL }}" />{{ end -}}
|
{{- range first 6 . }}<meta property="og:image" content="{{ . | absURL }}" />{{ end -}}
|
||||||
{{- else -}}
|
{{- else }}
|
||||||
{{- $images := $.Resources.ByType "image" -}}
|
{{- $featured := ($.Resources.ByType "image").GetMatch "{*feature*,*cover*,*thumbnail*}" -}}
|
||||||
{{- $featured := $images.GetMatch "*feature*" -}}
|
{{- with $featured }}
|
||||||
{{- if not $featured }}{{ $featured = $images.GetMatch "{*cover*,*thumbnail*}" }}{{ end -}}
|
|
||||||
{{- with $featured -}}
|
|
||||||
<meta property="og:image" content="{{ $featured.Permalink }}" />
|
<meta property="og:image" content="{{ $featured.Permalink }}" />
|
||||||
{{- else -}}
|
{{- else }}
|
||||||
{{- with $.Site.Params.images }}
|
{{- with $.Site.Params.images }}
|
||||||
<meta property="og:image" content="{{ index . 0 | absURL }}" />
|
<meta property="og:image" content="{{ index . 0 | absURL }}" />
|
||||||
{{ end -}}
|
{{- end }}
|
||||||
{{- end -}}
|
{{- end }}
|
||||||
{{- end -}}
|
{{- end }}
|
||||||
|
|
||||||
{{- if .IsPage }}
|
{{- with .Params.audio }}
|
||||||
{{- $iso8601 := "2006-01-02T15:04:05-07:00" -}}
|
<meta property="og:audio" content="{{ . }}" />
|
||||||
<meta property="article:section" content="{{ .Section }}" />
|
{{- end }}
|
||||||
{{ with .PublishDate }}
|
{{- with .Params.locale }}
|
||||||
<meta
|
<meta property="og:locale" content="{{ . }}" />
|
||||||
property="article:published_time"
|
{{- end }}
|
||||||
{{ .Format $iso8601 | printf "content=%q" | safeHTMLAttr }}
|
|
||||||
/>
|
|
||||||
{{ end }}
|
|
||||||
{{ with .Lastmod }}
|
|
||||||
<meta
|
|
||||||
property="article:modified_time"
|
|
||||||
{{ .Format $iso8601 | printf "content=%q" | safeHTMLAttr }}
|
|
||||||
/>
|
|
||||||
{{ end }}
|
|
||||||
{{- end -}}
|
|
||||||
|
|
||||||
{{- with .Params.audio }}<meta property="og:audio" content="{{ . }}" />{{ end }}
|
|
||||||
{{- with .Params.locale }}<meta property="og:locale" content="{{ . }}" />{{ end }}
|
|
||||||
{{- with .Site.Params.title }}<meta property="og:site_name" content="{{ . }}" />{{ end }}
|
|
||||||
{{- with .Params.videos }}
|
{{- with .Params.videos }}
|
||||||
{{- range . }}
|
{{- 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 */}}
|
||||||
{{- if .Site.Taxonomies.series }}
|
{{- if .Site.Taxonomies.series }}
|
||||||
{{- $permalink := .Permalink }}
|
{{- $permalink := .Permalink -}}
|
||||||
{{- $siteSeries := .Site.Taxonomies.series }}
|
{{- $siteSeries := .Site.Taxonomies.series -}}
|
||||||
{{ with .Params.series }}
|
{{- with .Params.series }}
|
||||||
{{- range $name := . }}
|
{{- 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 }}
|
{{- if ne $page.Permalink $permalink }}
|
||||||
<meta property="og:see_also" content="{{ $page.Permalink }}" />
|
<meta property="og:see_also" content="{{ $page.Permalink }}" />
|
||||||
{{ end }}
|
|
||||||
{{- end }}
|
{{- end }}
|
||||||
{{ end }}
|
{{- end }}
|
||||||
{{ end }}
|
{{- end }}
|
||||||
|
{{- end }}
|
||||||
|
{{- end }}
|
||||||
|
|
||||||
|
{{ if .IsPage -}}
|
||||||
|
{{- $iso8601 := "2006-01-02T15:04:05-07:00" -}}
|
||||||
|
<meta property="article:section" content="{{ .Section }}" />
|
||||||
|
{{- with .PublishDate }}
|
||||||
|
<meta
|
||||||
|
property="article:published_time"
|
||||||
|
{{ .Format $iso8601 | printf "content=%q" | safeHTMLAttr }}
|
||||||
|
/>
|
||||||
|
{{- end }}
|
||||||
|
{{- with .Lastmod }}
|
||||||
|
<meta
|
||||||
|
property="article:modified_time"
|
||||||
|
{{ .Format $iso8601 | printf "content=%q" | safeHTMLAttr }}
|
||||||
|
/>
|
||||||
|
{{- end }}
|
||||||
{{- end }}
|
{{- end }}
|
||||||
|
|
||||||
{{- /* Facebook Page Admin ID for Domain Insights */}}
|
{{- /* Facebook Page Admin ID for Domain Insights */}}
|
||||||
{{- with .Site.Social.facebook_admin }}<meta property="fb:admins" content="{{ . }}" />{{ end }}
|
{{- with .Site.Social.facebook_admin }}
|
||||||
|
<meta property="fb:admins" content="{{ . }}" />
|
||||||
|
{{- end }}
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
{{ if eq .Kind "home" }}
|
{{- if eq .Kind "home" }}
|
||||||
{{ $thumbnail := default (default "brand.svg" .Site.Params.logo) (index (default slice .Site.Params.images) 0) | absURL }}
|
{{- $thumbnail := default (default "brand.svg" .Site.Params.logo) (index (default slice .Site.Params.images) 0) | absURL -}}
|
||||||
|
|
||||||
<script type="application/ld+json">
|
<script type="application/ld+json">
|
||||||
{
|
{
|
||||||
@ -19,10 +19,10 @@
|
|||||||
{{- end }}
|
{{- end }}
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
{{ else if .IsPage }}
|
{{- else if .IsPage }}
|
||||||
{{ $authors := default (slice .Site.Params.GeekblogAuthor) .Params.authors }}
|
{{- $authors := default (slice .Site.Params.GeekblogAuthor) .Params.authors -}}
|
||||||
{{ $ac := 0 }}
|
{{- $ac := 0 -}}
|
||||||
{{ $ac_max := default 0 (len $authors) }}
|
{{- $ac_max := default 0 (len $authors) -}}
|
||||||
|
|
||||||
<script type="application/ld+json">
|
<script type="application/ld+json">
|
||||||
{
|
{
|
||||||
@ -87,4 +87,4 @@
|
|||||||
{{- end }}
|
{{- end }}
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
{{- end -}}
|
{{- end }}
|
@ -1,21 +1,23 @@
|
|||||||
{{- with $.Params.images -}}
|
{{- with $.Params.images -}}
|
||||||
<meta name="twitter:card" content="summary_large_image" />
|
<meta name="twitter:card" content="summary_large_image" />
|
||||||
<meta name="twitter:image" content="{{ index . 0 | absURL }}" />
|
<meta name="twitter:image" content="{{ index . 0 | absURL }}" />
|
||||||
{{ else -}}
|
{{- else }}
|
||||||
{{- $images := $.Resources.ByType "image" -}}
|
{{- $images := $.Resources.ByType "image" -}}
|
||||||
{{- $featured := $images.GetMatch "*feature*" -}}
|
{{- $featured := $images.GetMatch "*feature*" -}}
|
||||||
{{- if not $featured }}{{ $featured = $images.GetMatch "{*cover*,*thumbnail*}" }}{{ end -}}
|
{{- if not $featured }}
|
||||||
{{- with $featured -}}
|
{{- $featured = $images.GetMatch "{*cover*,*thumbnail*}" -}}
|
||||||
|
{{- end }}
|
||||||
|
{{- with $featured }}
|
||||||
<meta name="twitter:card" content="summary_large_image" />
|
<meta name="twitter:card" content="summary_large_image" />
|
||||||
<meta name="twitter:image" content="{{ $featured.Permalink }}" />
|
<meta name="twitter:image" content="{{ $featured.Permalink }}" />
|
||||||
{{- else -}}
|
{{- else }}
|
||||||
{{- with $.Site.Params.images -}}
|
{{- with $.Site.Params.images }}
|
||||||
<meta name="twitter:card" content="summary_large_image" />
|
<meta name="twitter:card" content="summary_large_image" />
|
||||||
<meta name="twitter:image" content="{{ index . 0 | absURL }}" />
|
<meta name="twitter:image" content="{{ index . 0 | absURL }}" />
|
||||||
{{ else -}}
|
{{- else }}
|
||||||
<meta name="twitter:card" content="summary" />
|
<meta name="twitter:card" content="summary" />
|
||||||
{{- end -}}
|
{{- end }}
|
||||||
{{- end -}}
|
{{- end }}
|
||||||
{{- end }}
|
{{- end }}
|
||||||
<meta name="twitter:title" content="{{ partial "utils/title" . }}" />
|
<meta name="twitter:title" content="{{ partial "utils/title" . }}" />
|
||||||
{{- with partial "utils/description" . }}
|
{{- with partial "utils/description" . }}
|
||||||
|
Loading…
Reference in New Issue
Block a user