feat: add toc.init_open configuration item in theme _config.yml
This commit is contained in:
parent
f8e3d6a65a
commit
06d8444c54
|
@ -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
|
||||
|
|
|
@ -67,6 +67,8 @@ function initTOC() {
|
|||
},
|
||||
|
||||
showPageAsideWhenHasTOC() {
|
||||
|
||||
const openHandle = () => {
|
||||
const styleStatus = KEEP.getStyleStatus();
|
||||
const key = 'isOpenPageAside';
|
||||
if (styleStatus && styleStatus.hasOwnProperty(key)) {
|
||||
|
@ -75,6 +77,17 @@ function initTOC() {
|
|||
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();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
KEEP.utils.showPageAsideWhenHasTOC();
|
||||
|
|
Loading…
Reference in New Issue