Odoc plugins for jon.recoil.org
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

Hide empty sidebar container on non-reference pages

Only render the sidebar <nav> element for pages within the reference/
hierarchy. Non-reference pages (blog, notebooks) no longer get the
empty 260px sidebar container. The JS also skips fetching sidebar.json
on non-reference pages, and the :empty CSS rule provides a fallback.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

+39 -28
+26 -20
src/odoc_jons_plugins.ml
··· 167 167 Html.head (Html.title (Html.txt title_string)) meta_elements 168 168 in 169 169 170 - (* Always render the sidebar container — JS will populate it from sidebar.json *) 170 + (* Only render the sidebar container for reference pages — 171 + JS will populate it from sidebar.json *) 171 172 let sidebar_nav = 172 - [ 173 - Html.nav 174 - ~a: 175 - [ 176 - Html.a_class [ "jon-shell-sidebar"; "odoc-global-toc" ]; 177 - Html.a_id "sidebar-content"; 178 - ] 179 - []; 180 - ] 173 + if Astring.String.is_prefix ~affix:"reference/" current_url then 174 + [ 175 + Html.nav 176 + ~a: 177 + [ 178 + Html.a_class [ "jon-shell-sidebar"; "odoc-global-toc" ]; 179 + Html.a_id "sidebar-content"; 180 + ] 181 + []; 182 + ] 183 + else [] 181 184 in 182 185 183 186 let body = ··· 281 284 Html.head (Html.title (Html.txt title_string)) meta_elements 282 285 in 283 286 284 - (* Always render the sidebar container — JS will populate it from sidebar.json *) 287 + (* Only render the sidebar container for reference pages — 288 + JS will populate it from sidebar.json *) 285 289 let sidebar_nav = 286 - [ 287 - Html.nav 288 - ~a: 289 - [ 290 - Html.a_class [ "jon-shell-sidebar"; "odoc-global-toc" ]; 291 - Html.a_id "sidebar-content"; 292 - ] 293 - []; 294 - ] 290 + if Astring.String.is_prefix ~affix:"reference/" current_url then 291 + [ 292 + Html.nav 293 + ~a: 294 + [ 295 + Html.a_class [ "jon-shell-sidebar"; "odoc-global-toc" ]; 296 + Html.a_id "sidebar-content"; 297 + ] 298 + []; 299 + ] 300 + else [] 295 301 in 296 302 297 303 let body =
+3
src/odoc_jons_plugins_css.ml
··· 148 148 max-height: calc(100vh - 48px); 149 149 overflow-y: auto; 150 150 } 151 + .jon-shell-sidebar:empty { 152 + display: none; 153 + } 151 154 152 155 /* Collapse the top two wrapper levels so content aligns with header */ 153 156 .jon-shell-sidebar > ul > li > ul,
+10 -8
src/odoc_jons_plugins_js.ml
··· 385 385 // Set initial history state 386 386 history.replaceState({ url: CURRENT_URL }, '', window.location.href); 387 387 388 - // Load sidebar data from sidebar.json 389 - fetch(ROOT_URL + 'sidebar.json') 390 - .then(function(r) { 391 - if (!r.ok) throw new Error('sidebar.json: ' + r.status); 392 - return r.json(); 393 - }) 394 - .then(function(data) { initSidebar(data); }) 395 - .catch(function(e) { console.warn('Failed to load sidebar:', e); }); 388 + // Load sidebar data only for reference pages 389 + if (CURRENT_URL.indexOf('reference/') === 0) { 390 + fetch(ROOT_URL + 'sidebar.json') 391 + .then(function(r) { 392 + if (!r.ok) throw new Error('sidebar.json: ' + r.status); 393 + return r.json(); 394 + }) 395 + .then(function(data) { initSidebar(data); }) 396 + .catch(function(e) { console.warn('Failed to load sidebar:', e); }); 397 + } 396 398 397 399 initSidebarToggle(); 398 400 })();