Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[DRAFT] Fix/favicon and active tab #6

Closed
wants to merge 17 commits into from
6 changes: 6 additions & 0 deletions docs/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,14 @@
extensions = [
"myst_parser",
"sphinx_copybutton",
'sphinx_favicon',
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this is correct! And the only thing missing is adding "sphinx-favicon" to pyproject.toml as was done in https://github.com/kedro-org/kedro/pull/3547/files

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ah great, thanks for the suggestion, let me try that

]

favicons = [
"https://kedro.org/images/favicon.ico",
]


templates_path = ["_templates"]

exclude_patterns = [
Expand Down
38 changes: 35 additions & 3 deletions src/kedro_sphinx_theme/theme/kedro-sphinx-theme/layout.html
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@
</div>

<div class="wy-main-nav">
<a href="/" class="active">Kedro</a>
<a href="https://docs.kedro.org/projects/kedro-viz/en/stable/">Kedro-Viz</a>
<a href="https://docs.kedro.org/projects/kedro-datasets">Kedro-Datasets</a>
<a class="wy-main-nav-link" href="/" class="active">Kedro</a>
<a class="wy-main-nav-link" href="https://docs.kedro.org/projects/kedro-viz/en/stable/">Kedro-Viz</a>
<a class="wy-main-nav-link" href="https://docs.kedro.org/projects/kedro-datasets">Kedro-Datasets</a>
</div>

{%- include "searchbox.html" %}
Expand Down Expand Up @@ -65,6 +65,38 @@
openBtn.dataset.toggle = 'wy-nav-top';
openBtn.classList.add('wy-nav-top-open');
document.querySelector('.wy-nav-top').prepend(openBtn);

// Select all navigation links within the .wy-main-nav container
var navLinks = document.querySelectorAll('.wy-main-nav .wy-main-nav-link');

// Define paths to check against the current URL
var paths = ['kedro-viz', 'kedro-datasets'];
var currentPath = window.location.pathname;

// Function to remove 'active' class from all links
function removeActiveClass() {
navLinks.forEach(function(link) {
link.classList.remove('active');
});
}


// Check each path for a match with the current URL
paths.forEach(function(path) {
if (currentPath.includes(path)) {
navLinks.forEach(function(link) {
if (link.getAttribute('href').includes(path)) {
removeActiveClass(); // Ensure only one link is active
link.classList.add('active'); // Add 'active' class to the matching link
}
});
}
});
});
</script>
{% endblock %}


https://docs.kedro.org/en/stable/
https://docs.kedro.org/projects/kedro-viz/en/stable/
https://docs.kedro.org/projects/kedro-datasets/en/stable/
Loading