From 93146c9dc3bad709794962b33580dac715e194ad Mon Sep 17 00:00:00 2001
From: Jimmy Cai <jimmehcai@gmail.com>
Date: Fri, 18 Sep 2020 00:12:26 +0200
Subject: [PATCH] fix: add .Type as second cache key for helper/image

closes https://github.com/CaiJimmy/hugo-theme-stack/issues/12
---
 layouts/_default/archives.html                            | 2 +-
 layouts/_default/term.html                                | 2 +-
 layouts/partials/article-list/compact.html                | 3 +--
 layouts/partials/article-list/default.html                | 2 +-
 layouts/partials/article-list/tile.html                   | 2 +-
 layouts/partials/article/components/details.html          | 2 +-
 layouts/partials/article/components/header.html           | 3 +--
 layouts/partials/article/components/related-contents.html | 2 +-
 layouts/partials/head/opengraph/provider/base.html        | 2 +-
 layouts/partials/head/opengraph/provider/twitter.html     | 2 +-
 10 files changed, 10 insertions(+), 12 deletions(-)

diff --git a/layouts/_default/archives.html b/layouts/_default/archives.html
index 18b3f6c..cf9ef94 100644
--- a/layouts/_default/archives.html
+++ b/layouts/_default/archives.html
@@ -7,7 +7,7 @@
         <div class="category-list">
             <div class="article-list--tile">
                 {{ range $categories }}
-                    {{ partial "article-list/tile" (dict "context" . "size" "250x150") }}
+                    {{ partial "article-list/tile" (dict "context" . "size" "250x150" "Type" "taxonomy") }}
                 {{ end }}
             </div>
         </div>
diff --git a/layouts/_default/term.html b/layouts/_default/term.html
index 91021c4..3189e9a 100644
--- a/layouts/_default/term.html
+++ b/layouts/_default/term.html
@@ -9,7 +9,7 @@
             {{ end }}
         </div>
 
-        {{ $image := partialCached "helper/image" (dict "Context" . "Type" "taxonomy") .RelPermalink }}
+        {{- $image := partialCached "helper/image" (dict "Context" . "Type" "taxonomy") .RelPermalink "taxonomy" -}}
         {{ if $image.exists }}
             <div class="taxonomy-image">
                 {{ if $image.resource }}   
diff --git a/layouts/partials/article-list/compact.html b/layouts/partials/article-list/compact.html
index 344086e..e9fa77d 100644
--- a/layouts/partials/article-list/compact.html
+++ b/layouts/partials/article-list/compact.html
@@ -12,8 +12,7 @@
         </footer>
     </div>
 
-    {{ $image := partialCached "helper/image" (dict "Context" . "Type" "articleList") .RelPermalink }}
-    
+    {{- $image := partialCached "helper/image" (dict "Context" . "Type" "articleList") .RelPermalink "articleList" -}}
     {{ if $image.exists }}
         <div class="article-image">
             {{ if $image.resource }}
diff --git a/layouts/partials/article-list/default.html b/layouts/partials/article-list/default.html
index 92c82b6..106d8d6 100644
--- a/layouts/partials/article-list/default.html
+++ b/layouts/partials/article-list/default.html
@@ -1,4 +1,4 @@
-{{ $image := partialCached "helper/image" (dict "Context" . "Type" "articleList") .RelPermalink }}
+{{ $image := partialCached "helper/image" (dict "Context" . "Type" "articleList") .RelPermalink "articleList" }}
 <article class="{{ if $image.exists }}has-image{{ end }}">
     {{ if $image.exists }}
         <div class="article-image">
diff --git a/layouts/partials/article-list/tile.html b/layouts/partials/article-list/tile.html
index b846681..0edf2e5 100644
--- a/layouts/partials/article-list/tile.html
+++ b/layouts/partials/article-list/tile.html
@@ -1,4 +1,4 @@
-{{ $image := partialCached "helper/image" (dict "Context" .context "Type" .Type) .context.RelPermalink }}
+{{ $image := partialCached "helper/image" (dict "Context" .context "Type" .Type) .context.RelPermalink .Type }}
 <article class="{{ if $image.exists }}has-image{{ end }}">
     <a href="{{ .context.Permalink }}">
         
diff --git a/layouts/partials/article/components/details.html b/layouts/partials/article/components/details.html
index 89d5554..fd053a8 100644
--- a/layouts/partials/article/components/details.html
+++ b/layouts/partials/article/components/details.html
@@ -1,4 +1,4 @@
-{{ $image := partialCached "helper/image" (dict "Context" .) .RelPermalink }}
+{{ $image := partialCached "helper/image" (dict "Context" . "Type" "article") .RelPermalink "article" }}
 {{ $context := . }}
 <div class="article-details">
     {{ with $categories := .Params.categories }}
diff --git a/layouts/partials/article/components/header.html b/layouts/partials/article/components/header.html
index 94b5950..7707b1d 100644
--- a/layouts/partials/article/components/header.html
+++ b/layouts/partials/article/components/header.html
@@ -1,6 +1,5 @@
 <header class="article-header">
-    {{ $image := partialCached "helper/image" (dict "Context" . "Type" "article") .RelPermalink }}
-
+    {{- $image := partialCached "helper/image" (dict "Context" . "Type" "article") .RelPermalink "article" -}}
     {{ if $image.exists }}
         <div class="article-image">
             {{ if $image.resource }}
diff --git a/layouts/partials/article/components/related-contents.html b/layouts/partials/article/components/related-contents.html
index 2f3b52c..b06fce6 100644
--- a/layouts/partials/article/components/related-contents.html
+++ b/layouts/partials/article/components/related-contents.html
@@ -5,7 +5,7 @@
         <div class="related-contents">
             <div class="flex article-list--tile">
                 {{ range . }}
-                    {{ partial "article-list/tile" (dict "context" . "size" "250x150") }}
+                    {{ partial "article-list/tile" (dict "context" . "size" "250x150" "Type" "articleList") }}
                 {{ end }}
             </div>
         </div>
diff --git a/layouts/partials/head/opengraph/provider/base.html b/layouts/partials/head/opengraph/provider/base.html
index 10dddb9..8e90a45 100644
--- a/layouts/partials/head/opengraph/provider/base.html
+++ b/layouts/partials/head/opengraph/provider/base.html
@@ -37,7 +37,7 @@
 	{{- end -}}
 {{- end -}}
 
-{{ $image := partialCached "helper/image" (dict "Context" . "Type" "opengraph") .RelPermalink }}
+{{ $image := partialCached "helper/image" (dict "Context" . "Type" "opengraph") .RelPermalink "opengraph" }}
 {{- if $image.exists -}}
     <meta property='og:image' content='{{ absURL $image.permalink }}' />
 {{- end -}}
\ No newline at end of file
diff --git a/layouts/partials/head/opengraph/provider/twitter.html b/layouts/partials/head/opengraph/provider/twitter.html
index a33757b..ecb6680 100644
--- a/layouts/partials/head/opengraph/provider/twitter.html
+++ b/layouts/partials/head/opengraph/provider/twitter.html
@@ -8,7 +8,7 @@
 <meta name="twitter:title" content="{{ $title }}">
 <meta name="twitter:description" content="{{ $description }}">
 
-{{- $image := partialCached "helper/image" (dict "Context" . "Type" "opengraph") .RelPermalink -}}
+{{- $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 }}' />