Skip to content

Commit 40e94ee

Browse files
committed
feat(header): Implement dynamic RSS icon link
Dynamically links RSS icon to the most relevant RSS feed available for the current page context. Signed-off-by: Khusika Dhamar Gusti <[email protected]>
1 parent 4df61b5 commit 40e94ee

File tree

1 file changed

+13
-5
lines changed

1 file changed

+13
-5
lines changed

layouts/_partials/header.html

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -76,8 +76,12 @@
7676
</span>
7777
</span>
7878
{{- end -}}
79-
{{- with .Site.Params.header.title.rss -}}
80-
<a class="menu-item" href="/index.xml" title="RSS"><i class="fa-solid fa-rss fa-fw" title="RSS"></i> </a>
79+
{{- if .Site.Params.header.title.rss -}}
80+
{{- $home := .Site.GetPage "home" -}}
81+
{{- $rss := .OutputFormats.Get "RSS" | default ($home.OutputFormats.Get "RSS") -}}
82+
{{- with $rss -}}
83+
<a class="menu-item" href="{{ .RelPermalink }}" title="RSS" target="_blank"><i class="fa-solid fa-rss fa-fw" title="RSS"></i></a>
84+
{{- end -}}
8185
{{- end -}}
8286
<a href="#" onclick="return false;" class="menu-item theme-switch" title="{{ T "switchTheme" }}">
8387
<i class="fa-solid fa-adjust fa-fw"></i>
@@ -150,9 +154,13 @@
150154
</a>
151155
{{- end -}}
152156
<div class="menu-item">
153-
{{- with .Site.Params.header.title.rss -}}
154-
<a href="/index.xml" title="RSS"><i class="fa-solid fa-rss fa-fw" title="RSS"></i> </a>
155-
<span>&nbsp;|&nbsp;</span>
157+
{{- if .Site.Params.header.title.rss -}}
158+
{{- $home := .Site.GetPage "home" -}}
159+
{{- $rss := .OutputFormats.Get "RSS" | default ($home.OutputFormats.Get "RSS") -}}
160+
{{- with $rss -}}
161+
<a href="{{ .RelPermalink }}" title="RSS" target="_blank"><i class="fa-solid fa-rss fa-fw" title="RSS"></i></a>
162+
<span>&nbsp;|&nbsp;</span>
163+
{{- end -}}
156164
{{- end -}}
157165
<a href="#" onclick="return false;" class="theme-switch" title="{{ T "switchTheme" }}">
158166
<i class="fa-solid fa-adjust fa-fw"></i>

0 commit comments

Comments
 (0)