From bd28dd0d0a83dcac978d4002d7ee2a3f08d9fe56 Mon Sep 17 00:00:00 2001 From: Vincent Ogloblinsky Date: Wed, 9 Feb 2022 22:20:56 +0100 Subject: [PATCH] fix(menu): custom-logo links are broken for doc deployments with a path fix #1203 --- src/resources/js/menu.js | 10 ++++++---- src/templates/partials/menu.hbs | 2 +- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/src/resources/js/menu.js b/src/resources/js/menu.js index 1d2b1def..2c843934 100644 --- a/src/resources/js/menu.js +++ b/src/resources/js/menu.js @@ -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) !== '.') { @@ -115,7 +116,8 @@ document.addEventListener('DOMContentLoaded', function () { } } }; - processLogos(entityLogos); + processLogos(compodocLogos); + processLogos(customLogo); setTimeout(function () { document.getElementById('btn-menu').addEventListener('click', function () { diff --git a/src/templates/partials/menu.hbs b/src/templates/partials/menu.hbs index 316faa5a..fdee4575 100644 --- a/src/templates/partials/menu.hbs +++ b/src/templates/partials/menu.hbs @@ -17,7 +17,7 @@ customElements.define('compodoc-menu', class extends HTMLElement {
  • {{#if customLogo}} - + {{else}} {{documentationMainName}}