mirror of
https://github.com/CaiJimmy/hugo-theme-stack.git
synced 2025-02-06 20:03:31 +08:00
de08e29b00
Now it can have i18n support
49 lines
1.1 KiB
TypeScript
49 lines
1.1 KiB
TypeScript
/*!
|
|
* Hugo Theme Stack
|
|
*
|
|
* @author: Jimmy Cai
|
|
* @website: https://jimmycai.com
|
|
* @link: https://github.com/CaiJimmy/hugo-theme-stack
|
|
*/
|
|
import StackGallery from "ts/gallery";
|
|
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";
|
|
|
|
let Stack = {
|
|
init: () => {
|
|
/**
|
|
* Bind menu event
|
|
*/
|
|
menu();
|
|
|
|
const articleContent = document.querySelector('.article-content') as HTMLElement;
|
|
if (articleContent) {
|
|
new StackGallery(articleContent);
|
|
setupSmoothAnchors();
|
|
setupScrollspy();
|
|
}
|
|
|
|
new StackColorScheme(document.getElementById('dark-mode-toggle'));
|
|
StackCodeBlock();
|
|
}
|
|
}
|
|
|
|
window.addEventListener('load', () => {
|
|
setTimeout(function () {
|
|
Stack.init();
|
|
}, 0);
|
|
})
|
|
|
|
declare global {
|
|
interface Window {
|
|
createElement: any;
|
|
Stack: any
|
|
}
|
|
}
|
|
|
|
window.Stack = Stack;
|
|
window.createElement = createElement; |