From 6d3f0f20c56d256fe63b408bb4ec96f34f25df2f Mon Sep 17 00:00:00 2001 From: Sam Carlton Date: Fri, 6 May 2022 18:47:24 -0500 Subject: [PATCH] Preload poster iamge for benchmarks --- src/pages/app/[...appPath].astro | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/src/pages/app/[...appPath].astro b/src/pages/app/[...appPath].astro index 4680e04..5201eb0 100644 --- a/src/pages/app/[...appPath].astro +++ b/src/pages/app/[...appPath].astro @@ -29,6 +29,8 @@ const [ subSlug = null ] = getPathPartsFromAstroRequest( Astro.request ) +const isBenchmarkPage = subSlug === 'benchmarks' + // Create an empty API URL const apiUrl = new URL( import.meta.env.PUBLIC_API_DOMAIN ) @@ -52,11 +54,26 @@ const appListing = await axios.get( apiUrl.toString() ) const listingDetails = new ListingDetails( appListing ) +const headOptions = listingDetails.headOptions + + +if ( isBenchmarkPage ) { + + // Preload video thumbnail + // + headOptions.link.push({ + 'rel': 'preload', + 'as': 'image', + 'href': `https://i.ytimg.com/vi_webp/${ listingDetails.initialVideo.id }/sddefault.webp` + }) + +} + --- - { subSlug === 'benchmarks' ? ( + { isBenchmarkPage ? (