Move mobile topbar title creation entirely into JS

This commit is contained in:
Guillaume Gomez 2023-09-18 15:22:40 +02:00
parent 078eb1120a
commit 354397f04d
2 changed files with 6 additions and 5 deletions

View File

@ -49,10 +49,12 @@ window.currentCrate = getVar("current-crate");
function setMobileTopbar() { function setMobileTopbar() {
// FIXME: It would be nicer to generate this text content directly in HTML, // FIXME: It would be nicer to generate this text content directly in HTML,
// but with the current code it's hard to get the right information in the right place. // but with the current code it's hard to get the right information in the right place.
const mobileLocationTitle = document.querySelector(".mobile-topbar h2"); const mobileTopbar = document.querySelector(".mobile-topbar");
const locationTitle = document.querySelector(".sidebar h2.location"); const locationTitle = document.querySelector(".sidebar h2.location");
if (mobileLocationTitle && locationTitle) { if (mobileTopbar && locationTitle) {
mobileLocationTitle.innerHTML = locationTitle.innerHTML; const mobileTitle = document.createElement("h2");
mobileTitle.innerHTML = locationTitle.innerHTML;
mobileTopbar.appendChild(mobileTitle);
} }
} }

View File

@ -84,8 +84,7 @@
<img class="rust-logo" src="{{static_root_path|safe}}{{files.rust_logo_svg}}" alt="logo"> {# #} <img class="rust-logo" src="{{static_root_path|safe}}{{files.rust_logo_svg}}" alt="logo"> {# #}
{% endif %} {% endif %}
</a> {# #} </a> {# #}
<h2></h2> {# #} </nav>
</nav> {# #}
{% endif %} {% endif %}
<nav class="sidebar"> {# #} <nav class="sidebar"> {# #}
{% if page.css_class != "src" %} {% if page.css_class != "src" %}