docs: Don't hide the version selector when scrolling down

This commit is contained in:
Emily 2024-12-16 23:45:52 +01:00
parent 25117d7d01
commit 5c5f03ac56
2 changed files with 25 additions and 0 deletions

22
docs/extra.js Normal file
View file

@ -0,0 +1,22 @@
document$.subscribe(function () {
// Stop mkdocs-material from hiding the version selector when scrolling down;
// this is done by removing the --active class when mkdocs-material adds it.
// (--active = scrolled down)
const title = document.querySelector('*[data-md-component="header-title"]');
const observer = new MutationObserver((mutations) => {
mutations.forEach((mutation) => {
if (mutation.attributeName === "class") {
const classList = title.className.split(" ");
classList.forEach((className) => {
if (className.endsWith("--active")) {
title.classList.remove(className);
}
});
}
});
});
observer.observe(title, { attributes: true });
});

View file

@ -84,6 +84,9 @@ markdown_extensions:
emoji_index: !!python/name:material.extensions.emoji.twemoji
emoji_generator: !!python/name:material.extensions.emoji.to_svg
extra_javascript:
- extra.js
# This lists all the files that become part of the documentation
nav:
- 'Home': 'index.md'