diff --git a/_config.yml b/_config.yml index 99f63b5..74a2509 100644 --- a/_config.yml +++ b/_config.yml @@ -110,6 +110,9 @@ toc: # If true, all level of TOC in a post will be displayed, rather than the activated part of it. expand_all: false + # If true, open TOC every time when you enter the article page + init_open: false + # --------------------------------------------------------------------------------------- # Post copyright info diff --git a/source/js/toc.js b/source/js/toc.js index fbbc66f..ceef590 100644 --- a/source/js/toc.js +++ b/source/js/toc.js @@ -67,13 +67,26 @@ function initTOC() { }, showPageAsideWhenHasTOC() { - const styleStatus = KEEP.getStyleStatus(); - const key = 'isOpenPageAside'; - if (styleStatus && styleStatus.hasOwnProperty(key)) { - KEEP.utils.leftSideToggle.pageAsideHandleOfTOC(styleStatus[key]); - } else { - KEEP.utils.leftSideToggle.pageAsideHandleOfTOC(true); + + const openHandle = () => { + const styleStatus = KEEP.getStyleStatus(); + const key = 'isOpenPageAside'; + if (styleStatus && styleStatus.hasOwnProperty(key)) { + KEEP.utils.leftSideToggle.pageAsideHandleOfTOC(styleStatus[key]); + } else { + KEEP.utils.leftSideToggle.pageAsideHandleOfTOC(true); + } } + + const initOpenKey = 'init_open'; + + if (KEEP.theme_config.toc.hasOwnProperty(initOpenKey)) { + KEEP.theme_config.toc[initOpenKey] ? openHandle() : KEEP.utils.leftSideToggle.pageAsideHandleOfTOC(false); + + } else { + openHandle(); + } + } }