2020-09-09 10:28:38 -04:00
|
|
|
/*!
|
|
|
|
* Hugo Theme Stack
|
|
|
|
*
|
|
|
|
* @author: Jimmy Cai
|
|
|
|
* @website: https://jimmycai.com
|
|
|
|
* @link: https://github.com/CaiJimmy/hugo-theme-stack
|
|
|
|
*/
|
2022-10-29 11:02:24 -04:00
|
|
|
import StackCodeBlock from "ts/codeblock";
|
2020-12-21 16:34:54 -05:00
|
|
|
import menu from 'ts/menu';
|
|
|
|
import createElement from 'ts/createElement';
|
2020-12-23 13:03:40 -05:00
|
|
|
import StackColorScheme from 'ts/colorScheme';
|
2022-01-22 04:35:08 -05:00
|
|
|
import { setupScrollspy } from 'ts/scrollspy';
|
|
|
|
import { setupSmoothAnchors } from "ts/smoothAnchors";
|
2020-08-22 07:20:08 -04:00
|
|
|
|
|
|
|
let Stack = {
|
|
|
|
init: () => {
|
|
|
|
/**
|
|
|
|
* Bind menu event
|
|
|
|
*/
|
|
|
|
menu();
|
|
|
|
|
2020-12-22 13:35:37 -05:00
|
|
|
const articleContent = document.querySelector('.article-content') as HTMLElement;
|
|
|
|
if (articleContent) {
|
2022-01-22 04:35:08 -05:00
|
|
|
setupSmoothAnchors();
|
|
|
|
setupScrollspy();
|
2020-08-22 07:20:08 -04:00
|
|
|
}
|
|
|
|
|
2020-12-23 13:03:40 -05:00
|
|
|
new StackColorScheme(document.getElementById('dark-mode-toggle'));
|
2022-10-29 11:02:24 -04:00
|
|
|
StackCodeBlock();
|
2020-08-22 07:20:08 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
window.addEventListener('load', () => {
|
|
|
|
setTimeout(function () {
|
|
|
|
Stack.init();
|
|
|
|
}, 0);
|
|
|
|
})
|
|
|
|
|
2020-11-06 05:12:48 -05:00
|
|
|
declare global {
|
|
|
|
interface Window {
|
|
|
|
createElement: any;
|
|
|
|
Stack: any
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
window.Stack = Stack;
|
|
|
|
window.createElement = createElement;
|