Add Video Rows to benchmarks page

This commit is contained in:
Sam Carlton 2022-06-08 12:49:06 -05:00
parent c0f6fb2f7c
commit 62d1c11afd

View file

@ -11,13 +11,104 @@ import { DoesItAPI } from '~/helpers/api/client.js'
import Layout from '../layouts/default.astro' import Layout from '../layouts/default.astro'
import BgPlayer from '~/src/components/video/bg-player.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' 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
}
}
}
--- ---
<Layout <Layout
@ -36,7 +127,7 @@ console.log('videos', video)
<main class="container relative md:static overflow-hidden md:overflow-visible pb-16"> <main class="container relative md:static overflow-hidden md:overflow-visible pb-16">
<div class="flex flex-col items-center text-center space-y-12"> <div class="flex flex-col items-center text-center space-y-12">
<BgPlayer <BgPlayer
video={ video } video={ heroVideo }
classes="absolute overflow-hidden w-2x-screen md:w-full pointer-events-none" classes="absolute overflow-hidden w-2x-screen md:w-full pointer-events-none"
/> />
@ -49,7 +140,7 @@ console.log('videos', video)
<div class="line-separator border-white border-t-2 mb-12" /> <div class="line-separator border-white border-t-2 mb-12" />
<a <a
href={ video.endpoint } href={ heroVideo.endpoint }
> >
<div <div
class="relative flex flex-col w-full justify-center items-center space-y-8 py-16 md:pt-0 md:pb-12 md:px-10" class="relative flex flex-col w-full justify-center items-center space-y-8 py-16 md:pt-0 md:pb-12 md:px-10"
@ -68,13 +159,13 @@ console.log('videos', video)
</svg> </svg>
</div> </div>
<h2 class="title text-lg md:text-2xl font-bold"> <h2 class="title text-lg md:text-2xl font-bold">
{ video.name } { heroVideo.name }
</h2> </h2>
</div> </div>
</a> </a>
<!-- <div <!-- <div
class="features-apps w-full" class="featured-apps w-full"
> >
<hr class="w-full" > <hr class="w-full" >
<div class="featured-apps overflow-x-auto overflow-y-visible whitespace-no-wrap py-2 space-x-2"> <div class="featured-apps overflow-x-auto overflow-y-visible whitespace-no-wrap py-2 space-x-2">
@ -89,19 +180,25 @@ console.log('videos', video)
</div> </div>
</div> --> </div> -->
{ Object.entries(videoRows).map(([ rowKey, row ]) => {
// Skip rows that don't have enough videos
if ( row.videos.length < 3 ) return
{ /* <div return (
v-for="(row, key) in videoRows" <div
class={ `${ key }-videos w-full max-w-4xl` } class={ `${ rowKey }-videos w-full max-w-4xl` }
> >
<h2 class="subtitle text-xl md:text-2xl font-bold mb-3"> <h2 class="subtitle text-xl md:text-2xl font-bold mb-3">
{ row.heading } { row.heading }
</h2> </h2>
<!-- <pre class="text-left">{{ benchmarkVideos }}</pre> --> <VideoRow
<VideoRow client:load
videos={ "row.videos" }
/> videos={ row.videos }
</div> */ } />
</div>
)
}) }
</div> </div>
</main> </main>