From 5b3e0721fdecab047ca49a8148bc5d8c37eb1262 Mon Sep 17 00:00:00 2001 From: Sam Carlton Date: Sat, 7 May 2022 12:31:01 -0500 Subject: [PATCH] Add support for responsive preloads --- src/pages/app/[...appPath].astro | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/src/pages/app/[...appPath].astro b/src/pages/app/[...appPath].astro index 5201eb0..efa737e 100644 --- a/src/pages/app/[...appPath].astro +++ b/src/pages/app/[...appPath].astro @@ -5,7 +5,10 @@ import axios from 'axios' import { catchRedirectResponse } from '~/helpers/astro/request.js' -import { ListingDetails } from '~/helpers/listing-page.js' +import { + getVideoImages, + ListingDetails +} from '~/helpers/listing-page.js' import { getPathPartsFromAstroRequest } from '~/helpers/url.js' import Layout from '~/src/layouts/default.astro' @@ -59,13 +62,13 @@ const headOptions = listingDetails.headOptions if ( isBenchmarkPage ) { + const { preloads } = getVideoImages( listingDetails.initialVideo ) + // Preload video thumbnail - // - headOptions.link.push({ - 'rel': 'preload', - 'as': 'image', - 'href': `https://i.ytimg.com/vi_webp/${ listingDetails.initialVideo.id }/sddefault.webp` - }) + headOptions.link = [ + ...headOptions.link, + ...preloads + ] }