Skip to content

Commit 245ea8c

Browse files
committed
Fix dynamic favicon path handling for subdirectory pages
- Fixed issue with favicon path on subdirectory pages by dynamically extracting and updating favicon filename. - Problem traced to previous commit 15f9065 which introduced static favicon path. - Ensured favicon loads correctly across all pages in firefox. Fixes sugarlabs#507
1 parent 15f9065 commit 245ea8c

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

_layouts/base.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
<meta charset="utf-8">
55
<meta name="viewport" content="width=device-width, initial-scale=1">
66
<meta http-equiv="X-UA-Compatible" content="IE=edge">
7-
<link id="defaultIcon1" rel="shortcut icon" href="{{ site.baseurl }}assets/favicon_06.png" />
7+
<link id="defaultIcon1" rel="shortcut icon" href="{{ site.baseurl }}/assets/favicon_06.png" />
88
<title>{{ page.title }}</title>
99
<link href="{{ site.baseurl }}/css/googleFonts.css" rel="stylesheet" type="text/css" >
1010
<meta name="robots" content="index,follow,NOODP" />

js/main.js

+7-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,13 @@ $(document).ready(function () {
2323
if (logoID < 10) {
2424
logoID = "0" + logoID;
2525
}
26-
defaultIcon.href = 'assets/favicon_' + logoID + '.png';
26+
27+
// Extract the base path from the current favicon href
28+
var currentHref = defaultIcon.getAttribute('href');
29+
var basePath = currentHref.substring(0, currentHref.lastIndexOf('/') + 1);
30+
31+
// Update only the filename portion while keeping the original path
32+
defaultIcon.href = basePath + 'favicon_' + logoID + '.png';
2733
}
2834

2935
var h = document.querySelector('.logo1').innerHTML;

0 commit comments

Comments
 (0)