Skip to content

Commit 6fc267a

Browse files
committed
designed a new home page for comet, added Home section in the header, edited the footer to less content/noise,
1 parent d2d5c6e commit 6fc267a

5 files changed

Lines changed: 1170 additions & 165 deletions

File tree

docs/source/_static/comet-ux.js

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@
1919

2020
/*
2121
* Comet docs UX enhancements layered on top of pydata_sphinx_theme:
22+
* - "Home" tab injected at the start of the top navbar (toctree can't
23+
* self-reference, so the landing page link lives here)
2224
* - Click-to-toggle expand/collapse arrows on sidebar nav groups
2325
* - In-sidebar search filter with character highlighting (replaces the
2426
* default Sphinx redirect-to-/search.html flow)
@@ -172,6 +174,38 @@
172174
});
173175
}
174176

177+
// ── Inject "Home" link into the top navbar ─────────────────────────
178+
// The toctree can't self-reference, so we add the Home tab via JS.
179+
// It's prepended to the desktop nav AND the mobile drawer. The link
180+
// is computed from the navbar logo's href so it stays correct at any
181+
// page depth.
182+
function initHomeNavLink() {
183+
var logo = document.querySelector('a.navbar-brand');
184+
var homeHref = logo ? logo.getAttribute('href') : null;
185+
if (!homeHref) return;
186+
187+
var isHomePage = !!document.querySelector('.comet-hero');
188+
189+
document
190+
.querySelectorAll('.bd-navbar-elements.navbar-nav')
191+
.forEach(function (nav) {
192+
if (nav.querySelector('.comet-home-nav-item')) return;
193+
194+
var li = document.createElement('li');
195+
li.className = 'nav-item comet-home-nav-item';
196+
if (isHomePage) li.classList.add('active', 'current');
197+
198+
var a = document.createElement('a');
199+
a.className = 'nav-link nav-internal';
200+
a.setAttribute('href', homeHref);
201+
if (isHomePage) a.setAttribute('aria-current', 'page');
202+
a.textContent = 'Home';
203+
204+
li.appendChild(a);
205+
nav.insertBefore(li, nav.firstChild);
206+
});
207+
}
208+
175209
// ── Breadcrumb trim ────────────────────────────────────────────────
176210
// "Comet 0.16.0-SNAPSHOT User Guide" reads as noise in a breadcrumb
177211
// when the section is already shown in the top nav. Trim to "0.16.0-
@@ -204,6 +238,7 @@
204238
}
205239

206240
function bootstrap() {
241+
initHomeNavLink();
207242
initSidebarToggle();
208243
initSidebarSearch();
209244
initSecondaryTocVisibility();

0 commit comments

Comments
 (0)