summaryrefslogtreecommitdiff
path: root/main.js
blob: 7a1225437f848f57f744cb3ed2c40d288237f301 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
document.addEventListener('DOMContentLoaded', () => {
    /**
     * Updates the 'last modified' timestamp on the page.
     * Looks for an element with the ID 'lastmod'.
     */
    const lastModElement = document.getElementById('lastmod');
    if (lastModElement) {
        // Use a standard YYYY-MM-DD format for the date.
        const lastModifiedDate = new Date(document.lastModified);
        lastModElement.textContent = lastModifiedDate.toISOString().split('T')[0];
    }

    /**
     * Handles the mobile sidebar toggle functionality.
     * Looks for a button with ID 'menu-toggle' and a sidebar with ID 'mobile-sidebar'.
     */
    const menuToggleButton = document.getElementById('menu-toggle');
    const mobileSidebar = document.getElementById('mobile-sidebar');

    if (menuToggleButton && mobileSidebar) {
        const closedText = menuToggleButton.textContent;
        const openText = menuToggleButton.dataset.openText || 'Hide menu'; // Fallback text

        menuToggleButton.addEventListener('click', () => {
            const isExpanded = mobileSidebar.classList.toggle('visible');
            menuToggleButton.setAttribute('aria-expanded', String(isExpanded));
            menuToggleButton.textContent = isExpanded ? openText : closedText;
        });
    }
});