summaryrefslogtreecommitdiff
path: root/static
diff options
context:
space:
mode:
authorxAlpharax <42233094+xAlpharax@users.noreply.github.com>2023-11-18 12:15:16 +0200
committerxAlpharax <42233094+xAlpharax@users.noreply.github.com>2023-11-18 12:15:16 +0200
commit8628a4ae2e7c8998c8d2ffe2ecc51f2624aa66b1 (patch)
treebd4bfbb9a9a77dfca3f3849f567fae45155b10b8 /static
parentd0a72793fffc208323292430bbbd8a0c7c2b6a2d (diff)
Massive changes - migrating to Hermit with a few tweaks.
Changes to be committed: new file: .gitignore modified: .gitmodules modified: config.toml new file: content/about.md deleted: content/blog/_index.md deleted: content/blog/first.md deleted: content/blog/second.md new file: content/posts/_index.md new file: content/posts/code_test.md new file: content/posts/good_first_post.md new file: content/posts/later_posts.md new file: content/posts/typography.md deleted: description deleted: index.html deleted: public/blog/first/index.html deleted: public/blog/index.html deleted: public/blog/second/index.html deleted: public/elasticlunr.min.js deleted: public/search_index.en.js deleted: public/typography.css new file: sass/_animate.scss new file: sass/_icons.scss new file: sass/_normalize.scss new file: sass/_predefined.scss new file: sass/_syntax.scss new file: sass/style.scss new file: static/favicon-32x32.png new file: static/favicon.ico new file: static/js/main.js modified: templates/404.html deleted: templates/base.html deleted: templates/blog-page.html deleted: templates/blog.html new file: templates/index.html new file: templates/macros.html new file: templates/page.html new file: templates/section.html new file: templates/tags/list.html new file: templates/tags/single.html new file: themes/404.html new file: themes/config.toml deleted: themes/hermit_zola
Diffstat (limited to 'static')
-rw-r--r--static/favicon-32x32.pngbin0 -> 4575 bytes
-rw-r--r--static/favicon.icobin0 -> 4575 bytes
-rw-r--r--static/js/main.js98
3 files changed, 98 insertions, 0 deletions
diff --git a/static/favicon-32x32.png b/static/favicon-32x32.png
new file mode 100644
index 0000000..b57e2b8
--- /dev/null
+++ b/static/favicon-32x32.png
Binary files differ
diff --git a/static/favicon.ico b/static/favicon.ico
new file mode 100644
index 0000000..b57e2b8
--- /dev/null
+++ b/static/favicon.ico
Binary files differ
diff --git a/static/js/main.js b/static/js/main.js
new file mode 100644
index 0000000..a40c504
--- /dev/null
+++ b/static/js/main.js
@@ -0,0 +1,98 @@
+/**
+ * Utils
+ */
+
+// Throttle
+//
+const throttle = (callback, limit) => {
+ let timeoutHandler = null;
+ return () => {
+ if (timeoutHandler == null) {
+ timeoutHandler = setTimeout(() => {
+ callback();
+ timeoutHandler = null;
+ }, limit);
+ }
+ };
+};
+
+// addEventListener Helper
+//
+const listen = (ele, e, callback) => {
+ if (document.querySelector(ele) !== null) {
+ document.querySelector(ele).addEventListener(e, callback);
+ }
+};
+
+/**
+ * Functions
+ */
+
+// Auto Hide Header
+//
+let header = document.getElementById('site-header');
+let lastScrollPosition = window.pageYOffset;
+
+const autoHideHeader = () => {
+ let currentScrollPosition = window.pageYOffset;
+ if (currentScrollPosition > lastScrollPosition) {
+ header.classList.remove('slideInUp');
+ header.classList.add('slideOutDown');
+ } else {
+ header.classList.remove('slideOutDown');
+ header.classList.add('slideInUp');
+ }
+ lastScrollPosition = currentScrollPosition;
+};
+
+// Mobile Menu Toggle
+//
+let mobileMenuVisible = false;
+
+const toggleMobileMenu = () => {
+ let mobileMenu = document.getElementById('mobile-menu');
+ if (mobileMenuVisible == false) {
+ mobileMenu.style.animationName = 'bounceInRight';
+ mobileMenu.style.webkitAnimationName = 'bounceInRight';
+ mobileMenu.style.display = 'block';
+ mobileMenuVisible = true;
+ } else {
+ mobileMenu.style.animationName = 'bounceOutRight';
+ mobileMenu.style.webkitAnimationName = 'bounceOutRight';
+ mobileMenuVisible = false;
+ }
+};
+
+// Featured Image Toggle
+//
+const showImg = () => {
+ document.querySelector('.bg-img').classList.add('show-bg-img');
+};
+
+const hideImg = () => {
+ document.querySelector('.bg-img').classList.remove('show-bg-img');
+};
+
+// ToC Toggle
+//
+const toggleToc = () => {
+ document.getElementById('toc').classList.toggle('show-toc');
+};
+
+if (header !== null) {
+ listen('#menu-btn', 'click', toggleMobileMenu);
+ listen('#toc-btn', 'click', toggleToc);
+ listen('#img-btn', 'click', showImg);
+ listen('.bg-img', 'click', hideImg);
+
+ window.addEventListener(
+ 'scroll',
+ throttle(() => {
+ autoHideHeader();
+
+ if (mobileMenuVisible == true) {
+ toggleMobileMenu();
+ }
+ }, 250)
+ );
+}