wip(js): add head.html and assets/js

This commit is contained in:
geekifan
2025-04-21 17:35:52 +08:00
parent 33048ab200
commit f5b2c028da
29 changed files with 1243 additions and 0 deletions

View File

@ -0,0 +1,7 @@
import { back2top, loadTooptip, modeWatcher } from '../components';
export function basic() {
modeWatcher();
back2top();
loadTooptip();
}

View File

@ -0,0 +1,19 @@
const ATTR_DISPLAY = 'sidebar-display';
const $sidebar = document.getElementById('sidebar');
const $trigger = document.getElementById('sidebar-trigger');
const $mask = document.getElementById('mask');
class SidebarUtil {
static #isExpanded = false;
static toggle() {
this.#isExpanded = !this.#isExpanded;
document.body.toggleAttribute(ATTR_DISPLAY, this.#isExpanded);
$sidebar.classList.toggle('z-2', this.#isExpanded);
$mask.classList.toggle('d-none', !this.#isExpanded);
}
}
export function initSidebar() {
$trigger.onclick = $mask.onclick = () => SidebarUtil.toggle();
}

View File

@ -0,0 +1,5 @@
import { displaySearch } from '../components/search-display';
export function initTopbar() {
displaySearch();
}