From 33e006dbcae7451a18bcc64a4372dcde495acb28 Mon Sep 17 00:00:00 2001 From: jeffreytse Date: Mon, 31 Aug 2020 19:46:13 +0800 Subject: feat: auto collapsed menu by heading amount --- _includes/sidebar/article-menu.html | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to '_includes/sidebar') diff --git a/_includes/sidebar/article-menu.html b/_includes/sidebar/article-menu.html index 215e808..2e273de 100644 --- a/_includes/sidebar/article-menu.html +++ b/_includes/sidebar/article-menu.html @@ -36,8 +36,13 @@ // The header element var header = document.querySelector('header.site-header'); - function doMenuCollapse(index) { + function doMenuCollapse(index, over_items=20) { var items = menuContent.firstChild.children; + + if (items.length < over_items) { + return; + } + var activeItem = items[index]; var beginItem = activeItem var endItem = activeItem -- cgit v1.2.3