diff options
author | jeffreytse <jeffreytse.mail@gmail.com> | 2020-08-31 19:46:13 +0800 |
---|---|---|
committer | jeffreytse <jeffreytse.mail@gmail.com> | 2020-09-01 10:55:01 +0800 |
commit | 33e006dbcae7451a18bcc64a4372dcde495acb28 (patch) | |
tree | 80e60356eb2613e637f9faba9fa80f0449842182 /_includes/sidebar/article-menu.html | |
parent | 663b1e567f88cbed3e923337470c9522caf9f0c6 (diff) |
feat: auto collapsed menu by heading amount
Diffstat (limited to '_includes/sidebar/article-menu.html')
-rw-r--r-- | _includes/sidebar/article-menu.html | 7 |
1 files changed, 6 insertions, 1 deletions
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 |