From 1055f804290feea415da680b55ad6419aac9a35c Mon Sep 17 00:00:00 2001 From: Sam Carlton Date: Thu, 9 Jun 2022 14:08:55 -0500 Subject: [PATCH] Add ensureListingDetails to prevent redundancy --- helpers/listing-page.js | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/helpers/listing-page.js b/helpers/listing-page.js index 1e03b87..377dff3 100644 --- a/helpers/listing-page.js +++ b/helpers/listing-page.js @@ -93,6 +93,8 @@ export class ListingDetails { type = '' + isListingDetails = true + get mainHeading () { if ( this.type === 'formula' ) { return `Does ${ this.api.name } work on Apple Silicon when installed via Homebrew?` @@ -176,3 +178,12 @@ export class ListingDetails { } } } + + +export function ensureListingDetails ( listing ) { + if ( listing.isListingDetails ) { + return listing + } + + return new ListingDetails( listing ) +}