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.
|
# If true, all level of TOC in a post will be displayed, rather than the activated part of it.
|
||||||
expand_all: false
|
expand_all: false
|
||||||
|
|
||||||
|
# If true, open TOC every time when you enter the article page
|
||||||
|
init_open: false
|
||||||
|
|
||||||
|
|
||||||
# ---------------------------------------------------------------------------------------
|
# ---------------------------------------------------------------------------------------
|
||||||
# Post copyright info
|
# Post copyright info
|
||||||
|
|
|
@ -67,13 +67,26 @@ function initTOC() {
|
||||||
},
|
},
|
||||||
|
|
||||||
showPageAsideWhenHasTOC() {
|
showPageAsideWhenHasTOC() {
|
||||||
const styleStatus = KEEP.getStyleStatus();
|
|
||||||
const key = 'isOpenPageAside';
|
const openHandle = () => {
|
||||||
if (styleStatus && styleStatus.hasOwnProperty(key)) {
|
const styleStatus = KEEP.getStyleStatus();
|
||||||
KEEP.utils.leftSideToggle.pageAsideHandleOfTOC(styleStatus[key]);
|
const key = 'isOpenPageAside';
|
||||||
} else {
|
if (styleStatus && styleStatus.hasOwnProperty(key)) {
|
||||||
KEEP.utils.leftSideToggle.pageAsideHandleOfTOC(true);
|
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();
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue