'init'
This commit is contained in:
17
public/js/search.js
Normal file
17
public/js/search.js
Normal file
@@ -0,0 +1,17 @@
|
||||
function filterArticles() {
|
||||
const tagSelect = document.getElementById('tag-select');
|
||||
const selectedTag = tagSelect.value;
|
||||
const articles = document.querySelectorAll('.article');
|
||||
|
||||
articles.forEach(article => {
|
||||
const tags = article.getAttribute('data-tags').split(' ');
|
||||
if (selectedTag === 'all' || tags.includes(selectedTag)) {
|
||||
article.style.display = 'flex';
|
||||
} else {
|
||||
article.style.display = 'none';
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// Initial call to display all articles
|
||||
filterArticles();
|
||||
Reference in New Issue
Block a user