Skip to content

Commit

Permalink
add logo image in doc homepage
Browse files Browse the repository at this point in the history
  • Loading branch information
CunliangGeng committed Nov 18, 2024
1 parent b61c242 commit 8fd8f7f
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 1 deletion.
3 changes: 2 additions & 1 deletion docs/index.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# NPLinker
#
<img src="images/NPLinker_standard_black.svg" class="theme-toggle-image">

NPLinker is a python framework for data mining microbial natural products by integrating genomics and metabolomics data.

Expand Down
21 changes: 21 additions & 0 deletions docs/scripts/extra.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
document.addEventListener("DOMContentLoaded", function () {
const img = document.querySelector(".theme-toggle-image");

if (!img) return; // Exit if no image is found

// Function to update the image based on the current theme
function updateImage() {
const theme = document.body.getAttribute("data-md-color-scheme");
img.src = theme === "slate" ? "images/NPLinker_standard_white.svg" : "images/NPLinker_standard_black.svg";
}

// Initial update
updateImage();

// Observe changes to the `data-md-color-scheme` attribute
const observer = new MutationObserver(updateImage);
observer.observe(document.body, {
attributes: true,
attributeFilter: ["data-md-color-scheme"], // Monitor changes to the theme attribute
});
});
3 changes: 3 additions & 0 deletions mkdocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,9 @@ extra:
extra_css:
- css/extra.css

extra_javascript:
- scripts/extra.js

# https://www.mkdocs.org/user-guide/configuration/#validation
validation:
omitted_files: warn
Expand Down

0 comments on commit 8fd8f7f

Please sign in to comment.