Skip to content

Commit

Permalink
fix(menu): custom-logo links are broken for doc deployments with a path
Browse files Browse the repository at this point in the history
fix #1203
  • Loading branch information
vogloblinsky committed Feb 9, 2022
1 parent 06dad8c commit bd28dd0
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
10 changes: 6 additions & 4 deletions src/resources/js/menu.js
Expand Up @@ -77,15 +77,16 @@ document.addEventListener('DOMContentLoaded', function () {
processMenuLinks(entityLinks);
var indexLinks = document.querySelectorAll('[data-type="index-link"]');
processMenuLinks(indexLinks, true);
var entityLogos = document.querySelectorAll('[data-type="compodoc-logo"]');
var processLogos = function (entityLogo) {
var compodocLogos = document.querySelectorAll('[data-type="compodoc-logo"]');
var customLogo = document.querySelectorAll('[data-type="custom-logo"]');
var processLogos = function (entityLogos) {
for (var i = 0; i < entityLogos.length; i++) {
var entityLogo = entityLogos[i];
if (entityLogo) {
var url = entityLogo.getAttribute('data-src');
// Dark mode + logo
let isDarkMode = window.matchMedia('(prefers-color-scheme: dark)').matches;
if (isDarkMode) {
if (isDarkMode && url.indexOf('compodoc') !== -1) {
url = 'images/compodoc-vectorise-inverted.png';
}
if (url.charAt(0) !== '.') {
Expand Down Expand Up @@ -115,7 +116,8 @@ document.addEventListener('DOMContentLoaded', function () {
}
}
};
processLogos(entityLogos);
processLogos(compodocLogos);
processLogos(customLogo);

setTimeout(function () {
document.getElementById('btn-menu').addEventListener('click', function () {
Expand Down
2 changes: 1 addition & 1 deletion src/templates/partials/menu.hbs
Expand Up @@ -17,7 +17,7 @@ customElements.define('compodoc-menu', class extends HTMLElement {
<li class="title">
{{#if customLogo}}
<a href="index.html" data-type="index-link">
<img alt="" class="img-responsive" data-type="custom-logo" src={{strip-url "/images/" customLogo}}>
<img alt="" class="img-responsive" data-type="custom-logo" data-src="{{strip-url "images/" customLogo}}">
</a>
{{else}}
<a href="index.html" data-type="index-link">{{documentationMainName}}</a>
Expand Down

0 comments on commit bd28dd0

Please sign in to comment.