Skip to content

Commit

Permalink
Fix favicon path
Browse files Browse the repository at this point in the history
Fix favicon gets "not found" error on non-homepage pages.

Set the path based on the root URL.

Fixes #507
  • Loading branch information
vidipsingh authored Jan 20, 2025
1 parent 71f985c commit b71fa69
Show file tree
Hide file tree
Showing 2 changed files with 20 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
20 changes: 19 additions & 1 deletion js/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,25 @@ $(document).ready(function () {
if (logoID < 10) {
logoID = "0" + logoID;
}
document.querySelector('#defaultIcon1').href = 'https://www.sugarlabs.org/assets/favicon_' + logoID + '.png';

var defaultIcon = document.querySelector('#defaultIcon1');
if (defaultIcon) {
var logoID = colorIndex + 1;
if (logoID < 10) {
logoID = "0" + logoID;
}

var rootUrl = '';
var baseTag = document.querySelector('base');
if (baseTag && baseTag.href) {
rootUrl = baseTag.href;
} else {
rootUrl = window.location.protocol + '//' + window.location.host + '/';
}

defaultIcon.href = rootUrl + 'assets/favicon_' + logoID + '.png';
}

var h = document.querySelector('.logo1').innerHTML;
h = h.replace(/033cd2/g, selectedColors[0]);
h = h.replace(/78e600/g, selectedColors[1]);
Expand Down

0 comments on commit b71fa69

Please sign in to comment.