Skip to content

Commit

Permalink
Fix dynamic favicon path handling for subdirectory pages
Browse files Browse the repository at this point in the history
- 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
  • Loading branch information
vidipsingh committed Jan 10, 2025
1 parent 15f9065 commit 245ea8c
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
2 changes: 1 addition & 1 deletion _layouts/base.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<link id="defaultIcon1" rel="shortcut icon" href="{{ site.baseurl }}assets/favicon_06.png" />
<link id="defaultIcon1" rel="shortcut icon" href="{{ site.baseurl }}/assets/favicon_06.png" />
<title>{{ page.title }}</title>
<link href="{{ site.baseurl }}/css/googleFonts.css" rel="stylesheet" type="text/css" >
<meta name="robots" content="index,follow,NOODP" />
Expand Down
8 changes: 7 additions & 1 deletion js/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,13 @@ $(document).ready(function () {
if (logoID < 10) {
logoID = "0" + logoID;
}
defaultIcon.href = 'assets/favicon_' + logoID + '.png';

// Extract the base path from the current favicon href
var currentHref = defaultIcon.getAttribute('href');
var basePath = currentHref.substring(0, currentHref.lastIndexOf('/') + 1);

// Update only the filename portion while keeping the original path
defaultIcon.href = basePath + 'favicon_' + logoID + '.png';
}

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

0 comments on commit 245ea8c

Please sign in to comment.