feat: add partialCached to helper/image invocation

Using .RelPermalink as key for cache
This commit is contained in:
Jimmy Cai 2020-09-17 21:52:06 +02:00
parent 9a64b7a6f1
commit cf6502c311
No known key found for this signature in database
GPG Key ID: 3EA408E527F37B18
8 changed files with 8 additions and 8 deletions

View File

@ -9,7 +9,7 @@
{{ end }} {{ end }}
</div> </div>
{{ $image := partial "helper/image" (dict "Context" . "Type" "taxonomy") }} {{ $image := partialCached "helper/image" (dict "Context" . "Type" "taxonomy") .RelPermalink }}
{{ if $image.exists }} {{ if $image.exists }}
<div class="taxonomy-image"> <div class="taxonomy-image">
{{ if $image.resource }} {{ if $image.resource }}

View File

@ -12,7 +12,7 @@
</footer> </footer>
</div> </div>
{{ $image := partial "helper/image" (dict "Context" . "Type" "articleList") }} {{ $image := partialCached "helper/image" (dict "Context" . "Type" "articleList") .RelPermalink }}
{{ if $image.exists }} {{ if $image.exists }}
<div class="article-image"> <div class="article-image">

View File

@ -1,4 +1,4 @@
{{ $image := partial "helper/image" (dict "Context" . "Type" "articleList") }} {{ $image := partialCached "helper/image" (dict "Context" . "Type" "articleList") .RelPermalink }}
<article class="{{ if $image.exists }}has-image{{ end }}"> <article class="{{ if $image.exists }}has-image{{ end }}">
{{ if $image.exists }} {{ if $image.exists }}
<div class="article-image"> <div class="article-image">

View File

@ -1,4 +1,4 @@
{{ $image := partial "helper/image" (dict "Context" .context "Type" .Type) }} {{ $image := partialCached "helper/image" (dict "Context" .context "Type" .Type) .context.RelPermalink }}
<article class="{{ if $image.exists }}has-image{{ end }}"> <article class="{{ if $image.exists }}has-image{{ end }}">
<a href="{{ .context.Permalink }}"> <a href="{{ .context.Permalink }}">

View File

@ -1,4 +1,4 @@
{{ $image := partial "helper/image" (dict "Context" .) }} {{ $image := partialCached "helper/image" (dict "Context" .) .RelPermalink }}
{{ $context := . }} {{ $context := . }}
<div class="article-details"> <div class="article-details">
{{ with $categories := .Params.categories }} {{ with $categories := .Params.categories }}

View File

@ -1,5 +1,5 @@
<header class="article-header"> <header class="article-header">
{{ $image := partial "helper/image" (dict "Context" . "Type" "article") }} {{ $image := partialCached "helper/image" (dict "Context" . "Type" "article") .RelPermalink }}
{{ if $image.exists }} {{ if $image.exists }}
<div class="article-image"> <div class="article-image">

View File

@ -37,7 +37,7 @@
{{- end -}} {{- end -}}
{{- end -}} {{- end -}}
{{ $image := partial "helper/image" (dict "Context" . "Type" "opengraph") }} {{ $image := partialCached "helper/image" (dict "Context" . "Type" "opengraph") .RelPermalink }}
{{- if $image.exists -}} {{- if $image.exists -}}
<meta property='og:image' content='{{ absURL $image.permalink }}' /> <meta property='og:image' content='{{ absURL $image.permalink }}' />
{{- end -}} {{- end -}}

View File

@ -8,7 +8,7 @@
<meta name="twitter:title" content="{{ $title }}"> <meta name="twitter:title" content="{{ $title }}">
<meta name="twitter:description" content="{{ $description }}"> <meta name="twitter:description" content="{{ $description }}">
{{- $image := partial "helper/image" (dict "Context" . "Type" "opengraph") -}} {{- $image := partialCached "helper/image" (dict "Context" . "Type" "opengraph") .RelPermalink -}}
{{- if $image.exists -}} {{- if $image.exists -}}
<meta name="twitter:card" content="{{ .Site.Params.opengraph.twitter.card }}"> <meta name="twitter:card" content="{{ .Site.Params.opengraph.twitter.card }}">
<meta name="twitter:image" content='{{ absURL $image.permalink }}' /> <meta name="twitter:image" content='{{ absURL $image.permalink }}' />