Skip to content

Commit 8225174

Browse files
committed
fix(deps): tocbot has no initialization detection (#957)
Resolves #957
1 parent 8b4f99c commit 8225174

File tree

1 file changed

+11
-9
lines changed
  • _javascript/modules/components

1 file changed

+11
-9
lines changed
Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
11
export function toc() {
2-
// see: https://github.com/tscanlin/tocbot#usage
3-
tocbot.init({
4-
tocSelector: '#toc',
5-
contentSelector: '.post-content',
6-
ignoreSelector: '[data-toc-skip]',
7-
headingSelector: 'h2, h3',
8-
orderedList: false,
9-
scrollSmooth: false
10-
});
2+
if (document.querySelector('#core-wrapper h2,#core-wrapper h3')) {
3+
// see: https://github.com/tscanlin/tocbot#usage
4+
tocbot.init({
5+
tocSelector: '#toc',
6+
contentSelector: '.post-content',
7+
ignoreSelector: '[data-toc-skip]',
8+
headingSelector: 'h2, h3',
9+
orderedList: false,
10+
scrollSmooth: false
11+
});
12+
}
1113
}

0 commit comments

Comments
 (0)