Hugo-theme-stack/assets/ts/main.ts

47 lines
1.1 KiB
TypeScript
Raw Normal View History

/*!
* Hugo Theme Stack
*
* @author: Jimmy Cai
* @website: https://jimmycai.com
* @link: https://github.com/CaiJimmy/hugo-theme-stack
*/
import StackCodeBlock from "ts/codeblock";
import menu from 'ts/menu';
import createElement from 'ts/createElement';
import StackColorScheme from 'ts/colorScheme';
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();
const articleContent = document.querySelector('.article-content') as HTMLElement;
if (articleContent) {
setupSmoothAnchors();
setupScrollspy();
2020-08-22 07:20:08 -04:00
}
new StackColorScheme(document.getElementById('dark-mode-toggle'));
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;