Skip to content

Commit bd28dd0

Browse files
committed
fix(menu): custom-logo links are broken for doc deployments with a path
fix #1203
1 parent 06dad8c commit bd28dd0

File tree

2 files changed

+7
-5
lines changed

2 files changed

+7
-5
lines changed

src/resources/js/menu.js

+6-4
Original file line numberDiff line numberDiff line change
@@ -77,15 +77,16 @@ document.addEventListener('DOMContentLoaded', function () {
7777
processMenuLinks(entityLinks);
7878
var indexLinks = document.querySelectorAll('[data-type="index-link"]');
7979
processMenuLinks(indexLinks, true);
80-
var entityLogos = document.querySelectorAll('[data-type="compodoc-logo"]');
81-
var processLogos = function (entityLogo) {
80+
var compodocLogos = document.querySelectorAll('[data-type="compodoc-logo"]');
81+
var customLogo = document.querySelectorAll('[data-type="custom-logo"]');
82+
var processLogos = function (entityLogos) {
8283
for (var i = 0; i < entityLogos.length; i++) {
8384
var entityLogo = entityLogos[i];
8485
if (entityLogo) {
8586
var url = entityLogo.getAttribute('data-src');
8687
// Dark mode + logo
8788
let isDarkMode = window.matchMedia('(prefers-color-scheme: dark)').matches;
88-
if (isDarkMode) {
89+
if (isDarkMode && url.indexOf('compodoc') !== -1) {
8990
url = 'images/compodoc-vectorise-inverted.png';
9091
}
9192
if (url.charAt(0) !== '.') {
@@ -115,7 +116,8 @@ document.addEventListener('DOMContentLoaded', function () {
115116
}
116117
}
117118
};
118-
processLogos(entityLogos);
119+
processLogos(compodocLogos);
120+
processLogos(customLogo);
119121

120122
setTimeout(function () {
121123
document.getElementById('btn-menu').addEventListener('click', function () {

src/templates/partials/menu.hbs

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ customElements.define('compodoc-menu', class extends HTMLElement {
1717
<li class="title">
1818
{{#if customLogo}}
1919
<a href="index.html" data-type="index-link">
20-
<img alt="" class="img-responsive" data-type="custom-logo" src={{strip-url "/images/" customLogo}}>
20+
<img alt="" class="img-responsive" data-type="custom-logo" data-src="{{strip-url "images/" customLogo}}">
2121
</a>
2222
{{else}}
2323
<a href="index.html" data-type="index-link">{{documentationMainName}}</a>

0 commit comments

Comments
 (0)