From 95f4e2f7cdedf87d289f28dc442cfc13eba7be87 Mon Sep 17 00:00:00 2001 From: Sam Carlton Date: Fri, 10 Jun 2022 16:12:29 -0500 Subject: [PATCH] Add game template --- src/pages/game/[...gamePath].astro | 76 ++++++++++++++++++++++++++++++ 1 file changed, 76 insertions(+) create mode 100644 src/pages/game/[...gamePath].astro diff --git a/src/pages/game/[...gamePath].astro b/src/pages/game/[...gamePath].astro new file mode 100644 index 0000000..1b4e573 --- /dev/null +++ b/src/pages/game/[...gamePath].astro @@ -0,0 +1,76 @@ +--- +// Full Astro Component Syntax: +// https://docs.astro.build/core-concepts/astro-components/ + +import { DoesItAPI } from '~/helpers/api/client.js' +import { catchRedirectResponse } from '~/helpers/astro/request.js' +import { + getVideoImages, + ListingDetails +} from '~/helpers/listing-page.js' +import { getPathPartsFromAstroRequest } from '~/helpers/url.js' + +import Layout from '~/src/layouts/default.astro' +import Listing from '~/src/components/default-listing.astro' +import VideoListing from '~/src/components/video-listing.astro' + + +const redirectResponse = await catchRedirectResponse( Astro ) + +if ( redirectResponse !== null ) { + return redirectResponse +} + + +// Get type and slug from the request path +// so that we don't have extra parts for +// urls like /:type/:slug/benchmarks +const { + pathSlug, + subSlug = null + } = getPathPartsFromAstroRequest( Astro.request ) + +const isBenchmarkPage = subSlug === 'benchmarks' + + +// Astro Request reference +// https://docs.astro.build/en/reference/api-reference/#astrorequests + +// Request App data from API +const appListing = await DoesItAPI.game( pathSlug ).get() + +const listingDetails = new ListingDetails( appListing ) + +const headOptions = listingDetails.headOptions + + +if ( isBenchmarkPage ) { + + // Set the page title + headOptions.title = `${ listingDetails.api.name } Benchmarks for Apple Silicon - Does It ARM` + + const { preloads } = getVideoImages( listingDetails.initialVideo ) + + // Add image preloads for video thumbnail + headOptions.link = [ + ...headOptions.link, + ...preloads + ] + +} + +--- + + { isBenchmarkPage ? ( + + ) : ( + + )} + +