From 93afef5f6297bd5e7a6f9a17b22e2bb13cd54753 Mon Sep 17 00:00:00 2001 From: Sam Carlton Date: Thu, 5 May 2022 13:46:58 -0500 Subject: [PATCH] Add benchmark getters --- helpers/listing-page.js | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/helpers/listing-page.js b/helpers/listing-page.js index ca14b13..03e9f54 100644 --- a/helpers/listing-page.js +++ b/helpers/listing-page.js @@ -5,8 +5,13 @@ import { } from './app-derived.js' import { buildVideoStructuredData } from './structured-data.js' import { nuxtHead } from './config.js' +import { + getPartPartsFromUrl +} from './url.js' +export const samChannelId = 'UCB3jOb5QVjX7lYecvyCoTqQ' + function makeTitle ( listing ) { return `Does ${ listing.name } work on Apple Silicon? - ${ nuxtHead.title }` } @@ -43,6 +48,36 @@ export class ListingDetails { return makeDescription( this.listing ) } + get endpointParts () { + return getPartPartsFromUrl( this.listing.endpoint ) + } + + get hasRelatedVideos () { + return Array.isArray( this.listing.relatedVideos ) && this.listing.relatedVideos.length > 0 + } + + get hasBenchmarksPage () { + return this.hasRelatedVideos + } + + get shouldHaveSubscribeButton () { + if ( this.initialVideo === null ) return false + + return this.initialVideo.channel.id !== samChannelId + } + + get initialVideo () { + if ( this.type === 'video' ) { + return this.listing.video + } + + if ( this.hasRelatedVideos ) { + return this.listing.relatedVideos[0] + } + + return null + } + get structuredData () { if ( this.type === 'video' ) { return buildVideoStructuredData( this.listing, this.listing.featuredApps, { siteUrl: import.meta.site } )