2020-09-09 16:28:38 +02:00
|
|
|
/*!
|
|
|
|
|
* Hugo Theme Stack
|
|
|
|
|
*
|
|
|
|
|
* @author: Jimmy Cai
|
|
|
|
|
* @website: https://jimmycai.com
|
|
|
|
|
* @link: https://github.com/CaiJimmy/hugo-theme-stack
|
|
|
|
|
*/
|
2026-01-25 23:13:34 +01:00
|
|
|
import menu from './menu';
|
|
|
|
|
import createElement from './createElement';
|
|
|
|
|
import StackColorScheme from './colorScheme';
|
|
|
|
|
import { setupScrollspy } from './scrollspy';
|
|
|
|
|
import { setupSmoothAnchors } from './smoothAnchors';
|
2026-04-26 18:41:31 +08:00
|
|
|
import { setupPaginationJump } from './pagination';
|
2026-04-26 13:40:46 +02:00
|
|
|
import { setupCodeCopy } from './code-copy';
|
2020-08-22 13:20:08 +02:00
|
|
|
|
|
|
|
|
let Stack = {
|
|
|
|
|
init: () => {
|
|
|
|
|
/**
|
|
|
|
|
* Bind menu event
|
|
|
|
|
*/
|
|
|
|
|
menu();
|
|
|
|
|
|
2020-12-22 19:35:37 +01:00
|
|
|
const articleContent = document.querySelector('.article-content') as HTMLElement;
|
|
|
|
|
if (articleContent) {
|
2022-01-22 10:35:08 +01:00
|
|
|
setupSmoothAnchors();
|
|
|
|
|
setupScrollspy();
|
2026-04-26 13:40:46 +02:00
|
|
|
setupCodeCopy();
|
2020-08-22 13:20:08 +02:00
|
|
|
}
|
|
|
|
|
|
2026-04-26 18:41:31 +08:00
|
|
|
setupPaginationJump();
|
|
|
|
|
|
2026-01-25 23:13:34 +01:00
|
|
|
new StackColorScheme(document.getElementById('dark-mode-toggle')!);
|
2020-08-22 13:20:08 +02:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
window.addEventListener('load', () => {
|
|
|
|
|
setTimeout(function () {
|
|
|
|
|
Stack.init();
|
|
|
|
|
}, 0);
|
|
|
|
|
})
|
|
|
|
|
|
2020-11-06 11:12:48 +01:00
|
|
|
declare global {
|
|
|
|
|
interface Window {
|
|
|
|
|
createElement: any;
|
|
|
|
|
Stack: any
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
window.Stack = Stack;
|
|
|
|
|
window.createElement = createElement;
|