Organize recently added videos by performer for better browsing
Adjust the "Recently Added" grid to filter videos from the "Geschichte des Liedes" collection, group them by performer, sort each group by upload date, and then distribute them by taking one from each performer per round to a maximum of 15 videos. Replit-Commit-Author: Agent Replit-Commit-Session-Id: 074b0e4c-6171-43bd-aa98-f9e04623ca14 Replit-Commit-Checkpoint-Type: full_checkpoint Replit-Commit-Screenshot-Url: https://storage.googleapis.com/screenshot-production-us-central1/8cc42625-c1f5-4e43-99bd-77f2c4dedee2/074b0e4c-6171-43bd-aa98-f9e04623ca14/DVZN4Rp
This commit is contained in:
parent
6e68075851
commit
ff7660be82
@ -56,7 +56,44 @@ export default function NetflixGrid({ videos, isLoading }: NetflixGridProps) {
|
||||
},
|
||||
{
|
||||
title: "Recently Added",
|
||||
videos: sortedByDate.slice(0, 15)
|
||||
videos: (() => {
|
||||
// Filter videos from "Geschichte des Liedes" collection
|
||||
const geschichteVideos = videos.filter(video =>
|
||||
video.title.includes("Geschichte des Liedes")
|
||||
);
|
||||
|
||||
// Group by performer/artist (extract performer name before " - ")
|
||||
const performerGroups: { [key: string]: typeof videos } = {};
|
||||
geschichteVideos.forEach(video => {
|
||||
const performer = video.title.split(" - ")[0] || "Unknown";
|
||||
if (!performerGroups[performer]) {
|
||||
performerGroups[performer] = [];
|
||||
}
|
||||
performerGroups[performer].push(video);
|
||||
});
|
||||
|
||||
// Sort each group by upload date (newest first)
|
||||
Object.keys(performerGroups).forEach(performer => {
|
||||
performerGroups[performer].sort((a, b) =>
|
||||
new Date(b.createdAt).getTime() - new Date(a.createdAt).getTime()
|
||||
);
|
||||
});
|
||||
|
||||
// Distribute videos: first one from each performer, then continue
|
||||
const result = [];
|
||||
const performers = Object.keys(performerGroups);
|
||||
let maxRounds = Math.max(...performers.map(p => performerGroups[p].length));
|
||||
|
||||
for (let round = 0; round < maxRounds && result.length < 15; round++) {
|
||||
for (let performer of performers) {
|
||||
if (performerGroups[performer][round] && result.length < 15) {
|
||||
result.push(performerGroups[performer][round]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
})()
|
||||
},
|
||||
{
|
||||
title: "Trending Now",
|
||||
|
||||
Loading…
Reference in New Issue
Block a user