contribution sort control in sidebar

This commit is contained in:
2026-06-16 16:27:56 +02:00
parent 36ef947be0
commit 5aa1fbf13c
3 changed files with 41 additions and 2 deletions

View File

@@ -829,11 +829,20 @@ function updateContributionsList() {
return matchesCategory && matchesSearch;
});
// Sorts by Date (newest first)
// Sorts by selected Option
var sortBy = document.getElementById('list-sort') ? document.getElementById('list-sort').value : 'date-desc';
filtered.sort(function (a, b) {
return new Date(b.properties.created_at) - new Date(a.properties.created_at);
if (sortBy === 'date-desc') return new Date(b.properties.created_at) - new Date(a.properties.created_at);
if (sortBy === 'date-asc') return new Date(a.properties.created_at) - new Date(b.properties.created_at);
if (sortBy === 'likes') return b.properties.likes_count - a.properties.likes_count;
if (sortBy === 'comments') return (b.properties.comment_count || 0) - (a.properties.comment_count || 0);
return 0;
});
// Updates Count Display
var countEl = document.getElementById('list-count');
if (countEl) countEl.textContent = filtered.length + ' Beiträge';
// Builds HTML
if (filtered.length === 0) {
container.innerHTML = '<p class="empty-state">Keine Beiträge gefunden.</p>';