--- // Component Script: // You can write any JavaScript/TypeScript that you'd like here. // It will run during the build, but never in the browser. // All variables are available to use in the HTML template below. // Full Astro Component Syntax: // https://docs.astro.build/core-concepts/astro-components/ import { DoesItAPI } from '~/helpers/api/client.js' import { applyResponseDefaults } from '~/helpers/astro/request.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' applyResponseDefaults( Astro ) const pagesToGet = 10 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 } } } ---

Benchmarks

{ heroVideo.name }

{ Object.entries(videoRows).map(([ rowKey, row ]) => { // Skip rows that don't have enough videos if ( row.videos.length < 3 ) return return (

{ row.heading }

) }) }