rimarima/themes/hugo-liftoff/assets/js/pages/home.js
Adrian Amaglio c09f092db4 init
2023-11-17 10:54:41 +01:00

21 lines
565 B
JavaScript

function filterPosts() {
let selectPosts = document.getElementById('select-posts');
let entries = document.querySelectorAll('.post-entry-filter');
if (selectPosts) {
selectPosts.addEventListener('change', () => {
entries.forEach(function(entry) {
if (entry.classList.contains(`entry--${selectPosts.value}`) | selectPosts.value === 'all-posts') {
entry.style.display = 'block';
} else {
entry.style.display = 'none';
}
});
});
}
}
const home = (() => {
filterPosts();
})();
export { home };