diff --git a/src/pages/benchmarks.astro b/src/pages/benchmarks.astro index e3d9097..d5827b9 100644 --- a/src/pages/benchmarks.astro +++ b/src/pages/benchmarks.astro @@ -11,13 +11,104 @@ import { DoesItAPI } from '~/helpers/api/client.js' import Layout from '../layouts/default.astro' import BgPlayer from '~/src/components/video/bg-player.astro' +import VideoRow from '~/src/components/video/row.astro' import LinkButton from '~/components/link-button.vue' -const videosPage = await DoesItAPI.kind.tv(1).get() -const video = videosPage.items[0] +const pagesToGet = 10 -console.log('videos', video) +const allVideos = [] + +// Run through out newest video pages and get all the videos +await Promise.all( + Array.from({ length: pagesToGet }, (_, i) => i + 1).map(async (page) => { + + // console.log('Getting page', page) + + const videoPage = await DoesItAPI.kind.tv( page ).get() + + // Merge in the new videos + allVideos.push( ...videoPage.items ) + + return videoPage + }) +) + +// Our initial video for the hero +const heroVideo = allVideos[0] + +// Setup video rows data for the page +const videoRows = { + 'video-benchmarks': { + heading: 'Video Editing Benchmarks', + matchesCondition: video => { + return video.tags.includes('benchmark') && video.tags.includes('video-and-motion-tools') + }, + videos: [] + }, + 'music-and-audio-tools': { + heading: 'Music and DAW Performance', + matchesCondition: video => { + return video.tags.includes('music-and-audio-tools') + }, + videos: [] + }, + 'science-and-research-software': { + heading: 'Science and Research', + matchesCondition: video => { + return video.tags.includes('science-and-research-software') + }, + videos: [] + }, + 'photo-and-graphic-tools': { + heading: 'Photography and Design Compatibility', + matchesCondition: video => { + return video.tags.includes('photo-and-graphic-tools') + }, + videos: [] + }, + 'games': { + heading: 'Gaming Benchmarks', + matchesCondition: video => { + return video.tags.includes('benchmark') && video.tags.includes('games') + }, + videos: [] + }, + 'benchmarks': { + heading: 'Other Benchmark Videos', + matchesCondition: video => video.tags.includes('benchmark'), + videos: [] + }, + 'performance': { + heading: 'Performance Videos', + matchesCondition: video => video.tags.includes('performance'), + videos: [] + }, + + 'other': { + heading: 'More Videos', + // Always true + matchesCondition: () => true, + videos: [] + } +} + + +// Move videos to relevant categories one at a time +// so that we we don't get duplicates in the rows + +for (const video of allVideos) { + // Look through row conditions to see if video matches + for (const rowKey in videoRows) { + if( videoRows[ rowKey ].matchesCondition(video) ) { + + // Add the matching video + videoRows[ rowKey ].videos.push(video) + + continue + } + } +} ---
@@ -49,7 +140,7 @@ console.log('videos', video) + { Object.entries(videoRows).map(([ rowKey, row ]) => { + // Skip rows that don't have enough videos + if ( row.videos.length < 3 ) return - { /*
-

- { row.heading } -

- - -
*/ } + return ( +
+

+ { row.heading } +

+ +
+ ) + }) }