← hugo-clarity

Hide duplicated posts

f61fcfff8565577a1777387e39281aa5caee99fa · Luke Hong · Jul 26, 2022 00:20

Signed-off-by: Luke Hong <luke0724@hotmail.com>

+7 −6 · 1 file changed

  • layouts/partials/sidebar.html +7 −6
diff --git a/layouts/partials/sidebar.html b/layouts/partials/sidebar.html
index 30fd676..5d8970c 100644
--- a/layouts/partials/sidebar.html
+++ b/layouts/partials/sidebar.html
@@ -34,11 +34,11 @@
     {{- end }}
 
     {{ if .Site.Params.sidebardisclaimer }}
-      <div class="sidebardisclaimer"> 
-        <h2 class="mt-4">Disclaimer</h2> 
+      <div class="sidebardisclaimer">
+        <h2 class="mt-4">Disclaimer</h2>
         {{ .Site.Params.disclaimerText }}
-      </div> 
-    {{ end }}  
+      </div>
+    {{ end }}
 
     {{- $relatedInSidebar := true }}
     {{- if eq $s.showRelatedInSidebar false }}
@@ -58,7 +58,8 @@
 
     {{- $posts := where (where .Site.RegularPages "Permalink" "!=" .Permalink) "Type" "in" $s.mainSections }}
     {{- $featured := default 8 $s.numberOfFeaturedPosts }}
-    {{- with first $featured (where $posts "Params.featured" true)}}
+    {{- $featured_posts := first $featured (where $posts "Params.featured" true)}}
+    {{- with $featured_posts }}
     <h2 class="mt-4">{{ T "featured_posts" }}</h2>
     <ul>
       {{- range . }}
@@ -71,7 +72,7 @@
     <h2 class="mt-4">{{ T "recent_posts" }}</h2>
     <ul class="flex-column">
       {{- $recent := default 8 $s.numberOfRecentPosts }}
-      {{- range first $recent $posts }}
+      {{- range first $recent $posts | symdiff $featured_posts }}
       <li>
         <a href="{{ .Permalink }}" class="nav-link" title="{{ .Title }}">{{ .Title | markdownify }}</a>
       </li>