From fb64abbe0669691f54109f759dcf1493ddd8b9f2 Mon Sep 17 00:00:00 2001 From: Jake Howard Date: Fri, 3 Nov 2017 21:50:41 +0000 Subject: [PATCH] Hide small ToCs --- static/src/js/index.js | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/static/src/js/index.js b/static/src/js/index.js index cb21cfd..a72d3cb 100644 --- a/static/src/js/index.js +++ b/static/src/js/index.js @@ -29,10 +29,12 @@ $(document).ready(function () { }); // HACK: ToC has blank li if no initial header - $('#TableOfContents > ul > li').each(function () { + $('#TableOfContents').each(function () { var ele = $(this); - if (ele.children('a').length === 0) { - ele.parent().replaceWith(ele.find('ul').eq(0)); + if (ele.find('a').length <= 3) { + ele.remove(); + } else if (ele.children('ul').children('li').length === 1) { + ele.children('ul').replaceWith(ele.children('ul').children('li').children('ul')); } }); });