From 14738eaea31e3ac8006d7d47f8bd33eca2e3650e Mon Sep 17 00:00:00 2001 From: Sam Carlton Date: Tue, 7 Jun 2022 16:19:20 -0500 Subject: [PATCH] Add device listing template --- src/pages/device/[...devicePath].astro | 107 +++++++++++++++++++++++++ 1 file changed, 107 insertions(+) create mode 100644 src/pages/device/[...devicePath].astro diff --git a/src/pages/device/[...devicePath].astro b/src/pages/device/[...devicePath].astro new file mode 100644 index 0000000..11d7f4c --- /dev/null +++ b/src/pages/device/[...devicePath].astro @@ -0,0 +1,107 @@ +--- +// Full Astro Component Syntax: +// https://docs.astro.build/core-concepts/astro-components/ + + +import { DoesItAPI } from '~/helpers/api/client.js' +import { getPathPartsFromAstroRequest } from '~/helpers/url.js' +import { catchRedirectResponse } from '~/helpers/astro/request.js' +import { deviceSupportsApp } from '~/helpers/devices.js' + + +import Layout from '../../layouts/default.astro' +import Search from '~/components/search-stork.vue' + + +// Get type and slug from the request path +// so that we don't have extra parts for +// urls like /:type/:slug/benchmarks +const { + pathname, + pathSlug, + subSlug = 1 + } = getPathPartsFromAstroRequest( Astro.request ) + + +const redirectResponse = await catchRedirectResponse( Astro ) + +if ( redirectResponse !== null ) { + return redirectResponse +} + +const device = await DoesItAPI.device( pathSlug ).get() +const rawAppPage = await DoesItAPI.kind( 'app' )( subSlug ).get() + + +const appPage = { + ...rawAppPage, + + // Map out paginnation links + // so we stay in the context of this device + previousPage: rawAppPage.previousPage.replace( '/kind/app', '/device/' + pathSlug ), + nextPage: rawAppPage.nextPage.replace( '/kind/app', '/device/' + pathSlug ), + + // Map device support over text/status + items: rawAppPage.items.map( listing => { + const listingIsSupported = deviceSupportsApp( device, listing ) + + return { + ...listing, + text: listingIsSupported ? `✅ Supported on ${ device.name }` : `🚫 Not yet reported working on ${ device.name }`, + } + }) +} + +--- + + +
+
+ +
+

+ Apple Silicon Support for { device.name } +

+ +
+ { device.description } +
+ +
+ +
+ Supported apps include { appPage.summary.sampleNamesShort }. +
+
+ + + + + + + +
+
+ +