Files
hugo-theme-stack/assets/ts/main.ts
T

47 lines
1.1 KiB
TypeScript
Raw Normal View History

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
*/
2022-10-29 17:02:24 +02:00
import StackCodeBlock from "ts/codeblock";
import menu from 'ts/menu';
import createElement from 'ts/createElement';
2020-12-23 19:03:40 +01:00
import StackColorScheme from 'ts/colorScheme';
import { setupScrollspy } from 'ts/scrollspy';
import { setupSmoothAnchors } from "ts/smoothAnchors";
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) {
setupSmoothAnchors();
setupScrollspy();
2020-08-22 13:20:08 +02:00
}
2020-12-23 19:03:40 +01:00
new StackColorScheme(document.getElementById('dark-mode-toggle'));
2022-10-29 17:02:24 +02:00
StackCodeBlock();
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;