Skip to content

Commit 459a9f4

Browse files
committed
fix: replace RSS feed scheme with feed on Safari only
1 parent ef883fa commit 459a9f4

File tree

2 files changed

+16
-1
lines changed

2 files changed

+16
-1
lines changed
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
export const isSafari = (): boolean => {
2+
const ua = navigator.userAgent.toLowerCase();
3+
return ua.indexOf("safari") !== -1 && ua.indexOf("chrome") === -1;
4+
};
5+
6+
(() => {
7+
if (isSafari()) {
8+
document
9+
.querySelectorAll<HTMLLinkElement>("a[data-rss-feed]")
10+
.forEach((link) => {
11+
link.href = "feed:" + link.href;
12+
});
13+
}
14+
})()

layouts/partials/hb/modules/socials/link.html

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@
6363
{{- $url = printf .url $.id }}
6464
{{- else if eq $.name "rss" }}
6565
{{- with site.Home.OutputFormats.Get "rss" }}
66-
{{- $url = .Permalink | printf "feed:%s" }}
66+
{{- $url = .Permalink }}
6767
{{- end }}
6868
{{- end }}
6969
{{- end }}
@@ -84,6 +84,7 @@
8484
{{ printf `href="%s"` $url | safeHTMLAttr }}
8585
target="_blank"
8686
rel="nofollow me"
87+
{{ if eq .name "rss" }}data-rss-feed{{ end }}
8788
title="{{ $title }}">
8889
{{- partial "icons/icon" (dict
8990
"vendor" $iconVendor

0 commit comments

Comments
 (0)