1
0
mirror of https://github.com/cotes2020/jekyll-theme-chirpy.git synced 2025-12-19 14:14:17 +00:00

feat: change TOC plugin to tocbot (#774)

This commit is contained in:
Cotes Chung
2023-03-16 02:56:54 +08:00
parent 474b4ba681
commit 02b7bd5095
13 changed files with 115 additions and 72 deletions

View File

@@ -0,0 +1,11 @@
export function toc() {
// see: https://github.com/tscanlin/tocbot#usage
tocbot.init({
tocSelector: '#toc',
contentSelector: '.post-content',
ignoreSelector: '[data-toc-skip]',
headingSelector: 'h2, h3',
orderedList: false,
scrollSmooth: false
});
}

View File

@@ -4,3 +4,4 @@ export { imgExtra } from './components/img-extra';
export { initLocaleDatetime } from './components/locale-datetime';
export { initPageviews } from './components/pageviews';
export { smoothScroll } from './components/smooth-scroll';
export { toc } from './components/toc';

View File

@@ -4,7 +4,8 @@ import {
initLocaleDatetime,
initClipboard,
smoothScroll,
initPageviews
initPageviews,
toc
} from './modules/plugins';
basic();
@@ -13,5 +14,6 @@ initTopbar();
imgExtra();
initLocaleDatetime();
initClipboard();
smoothScroll();
toc();
smoothScroll(); // must be called after toc is created
initPageviews();