mirror of
https://github.com/ThatGuySam/doesitarm.git
synced 2026-05-18 06:44:46 -07:00
Enable Video Structured Data on benchmark pages
This commit is contained in:
parent
c1b232a291
commit
da7ae98d5c
3 changed files with 42 additions and 7 deletions
|
|
@ -3,6 +3,7 @@ import fs from 'fs-extra'
|
|||
|
||||
import pkg from '~/package.json'
|
||||
import { getSiteUrl } from '~/helpers/url.js'
|
||||
import { getRouteType } from '~/helpers/app-derived.js'
|
||||
|
||||
|
||||
export const siteUrl = getSiteUrl()
|
||||
|
|
@ -232,6 +233,10 @@ export class PageHead {
|
|||
return this.pageUrl.toString()
|
||||
}
|
||||
|
||||
get routeType () {
|
||||
return getRouteType( this.pathname )
|
||||
}
|
||||
|
||||
get defaultMeta () {
|
||||
return nuxtHead.meta
|
||||
}
|
||||
|
|
@ -310,14 +315,22 @@ export class PageHead {
|
|||
].join('')
|
||||
}
|
||||
|
||||
|
||||
get structuredDataMarkup () {
|
||||
// console.log( 'this.structuredData', this.structuredData )
|
||||
// console.log( 'this.routeType', this.routeType, this.pathname )
|
||||
|
||||
if ( this.structuredData === null ) return ''
|
||||
const hasStructuredData = this.structuredData !== null
|
||||
// Route is primarily for video
|
||||
const videoRouteType = [ 'tv', 'benchmarks' ].includes( this.routeType )
|
||||
|
||||
const structuredDataJson = JSON.stringify( this.structuredData )
|
||||
if ( hasStructuredData && videoRouteType ) {
|
||||
const structuredDataJson = JSON.stringify( this.structuredData )
|
||||
|
||||
return `<script type="application/ld+json">${ structuredDataJson }</script>`
|
||||
return `<script type="application/ld+json">${ structuredDataJson }</script>`
|
||||
}
|
||||
|
||||
|
||||
return ''
|
||||
}
|
||||
|
||||
get allHeadMarkup () {
|
||||
|
|
|
|||
|
|
@ -183,10 +183,22 @@ export class ListingDetails {
|
|||
}
|
||||
|
||||
get structuredData () {
|
||||
// Normal video page with app links
|
||||
if ( this.type === 'video' ) {
|
||||
return buildVideoStructuredData( this.api, this.api.appLinks )
|
||||
}
|
||||
|
||||
// Benchmark page
|
||||
if ( this.hasInitialVideo ) {
|
||||
// Build app links with just the current app
|
||||
const appLinks = [ {
|
||||
name: this.api.name,
|
||||
endpoint: this.api.endpoint
|
||||
} ]
|
||||
|
||||
return buildVideoStructuredData( this.initialVideo, appLinks )
|
||||
}
|
||||
|
||||
return null
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue