Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 28 additions & 5 deletions site/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -180,18 +180,41 @@
}
});

// Update URL hash to reflect active filter
const activeFilter = pill.classList.contains('active') ? category : null;
if (activeFilter && activeFilter !== 'all') {
history.replaceState(null, '', '#' + activeFilter);
} else {
history.replaceState(null, '', window.location.pathname + window.location.search);
}

// Update view toggle button state
if (window.updateViewToggleState) {
window.updateViewToggleState();
}
});
});

// Auto-click "All" button on page load to show all cards
const allButton = document.querySelector('.filter-pill[data-filter="all"]');
if (allButton) {
allButton.click();
}
// Apply filter from a given category string (or "all" / empty for no filter)
const applyHashFilter = (category) => {
const target = category
? document.querySelector(`.filter-pill[data-filter="${category}"]`)
: null;
if (target) {
target.click();
} else {
const allButton = document.querySelector('.filter-pill[data-filter="all"]');
if (allButton) allButton.click();
}
};

// On load, apply filter from URL hash or default to "All"
applyHashFilter(window.location.hash.slice(1));

// Also react to browser back/forward hash changes
window.addEventListener('hashchange', () => {
applyHashFilter(window.location.hash.slice(1));
});
};

/* ==========================================================
Expand Down