mirror of
https://github.com/ThatGuySam/doesitarm.git
synced 2026-05-18 06:44:46 -07:00
Add video structured data to TV pages
This commit is contained in:
parent
706390625b
commit
c662eb2c71
1 changed files with 70 additions and 15 deletions
|
|
@ -78,6 +78,44 @@ import VideoRow from '~/components/video/row.vue'
|
||||||
import VideoPlayer from '~/components/video/player.vue'
|
import VideoPlayer from '~/components/video/player.vue'
|
||||||
import ChannelCredit from '~/components/video/channel-credit.vue'
|
import ChannelCredit from '~/components/video/channel-credit.vue'
|
||||||
|
|
||||||
|
|
||||||
|
function makeFeaturedAppsString ( featuredApps ) {
|
||||||
|
return featuredApps.slice(0, 5).map(app => app.name).join(', ')
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
function buildVideoStructuredData ( video, featuredApps ) {
|
||||||
|
// console.log('video', video)
|
||||||
|
|
||||||
|
const thumbnailUrls = video.thumbnail.srcset.split(',').map( srcSetImage => {
|
||||||
|
const [ imageUrl ] = srcSetImage.split(' ')
|
||||||
|
|
||||||
|
return imageUrl
|
||||||
|
})
|
||||||
|
|
||||||
|
const featuredAppsString = makeFeaturedAppsString( featuredApps )
|
||||||
|
|
||||||
|
return {
|
||||||
|
"@context": "https://schema.org",
|
||||||
|
// https://developers.google.com/search/docs/data-types/video
|
||||||
|
// https://schema.org/VideoObject
|
||||||
|
"@type": "VideoObject",
|
||||||
|
"name": video.name,
|
||||||
|
"description": `Includes the following apps: ${featuredAppsString}`,
|
||||||
|
"thumbnailUrl": thumbnailUrls,
|
||||||
|
// https://en.wikipedia.org/wiki/ISO_8601
|
||||||
|
"uploadDate": video.lastUpdated.raw,
|
||||||
|
// "duration": "PT1M54S", // Need to updaet Youtube API Request for this
|
||||||
|
// "contentUrl": "https://www.example.com/video/123/file.mp4",
|
||||||
|
// "embedUrl": "https://www.example.com/embed/123",
|
||||||
|
// "interactionStatistic": {
|
||||||
|
// "@type": "InteractionCounter",
|
||||||
|
// "interactionType": { "@type": "http://schema.org/WatchAction" },
|
||||||
|
// "userInteractionCount": 5647018
|
||||||
|
// },
|
||||||
|
// "regionsAllowed": "US,NL"
|
||||||
|
}
|
||||||
|
}
|
||||||
export default {
|
export default {
|
||||||
components: {
|
components: {
|
||||||
LinkButton,
|
LinkButton,
|
||||||
|
|
@ -86,19 +124,32 @@ export default {
|
||||||
VideoPlayer,
|
VideoPlayer,
|
||||||
ChannelCredit
|
ChannelCredit
|
||||||
},
|
},
|
||||||
asyncData ({ params: { slug }, payload: { video, featuredApps, relatedVideos } }) {
|
async asyncData ( data ) {
|
||||||
|
|
||||||
// const { appsRelatedToVideo, videosRelatedToVideo } = await import('~/helpers/related.js')
|
|
||||||
// const { default: videoList } = await import('~/static/video-list.json')
|
|
||||||
|
|
||||||
// Find the video for our current page
|
const {
|
||||||
// const video = videoList.find(video => (video.slug === slug))
|
params: { slug },
|
||||||
|
route
|
||||||
|
} = data
|
||||||
|
|
||||||
// Get featured apps
|
let {
|
||||||
// const featuredApps = appsRelatedToVideo(video)
|
payload
|
||||||
|
} = data
|
||||||
|
|
||||||
// // Get related videos
|
|
||||||
// const relatedVideos = videosRelatedToVideo(video)
|
|
||||||
|
// Manually get payload as fallback
|
||||||
|
// Uncomment for dev
|
||||||
|
// if ( payload === undefined ) {
|
||||||
|
// // Read back the JSON we just wrote to ensure it exists
|
||||||
|
// const { default: savedList } = await import('~/static/nuxt-endpoints.json')
|
||||||
|
|
||||||
|
// const endpoint = savedList.find( resource => {
|
||||||
|
// return resource.route === route.path
|
||||||
|
// } )
|
||||||
|
|
||||||
|
// payload = endpoint.payload
|
||||||
|
// }
|
||||||
|
|
||||||
// console.log({
|
// console.log({
|
||||||
// video,
|
// video,
|
||||||
|
|
@ -107,9 +158,9 @@ export default {
|
||||||
// })
|
// })
|
||||||
|
|
||||||
return {
|
return {
|
||||||
video,
|
video: payload.video,
|
||||||
featuredApps,
|
featuredApps: payload.featuredApps,
|
||||||
relatedVideos
|
relatedVideos: payload.relatedVideos
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
|
|
@ -117,10 +168,11 @@ export default {
|
||||||
return `${this.video.name} - Does It ARM`
|
return `${this.video.name} - Does It ARM`
|
||||||
},
|
},
|
||||||
description () {
|
description () {
|
||||||
const featuredAppsString = this.featuredApps.slice(0, 5).map(app => app.name).join(', ')
|
const featuredAppsString = makeFeaturedAppsString( this.featuredApps )
|
||||||
|
|
||||||
return `Apple Silicon performance and support videos for ${featuredAppsString}`
|
return `Apple Silicon performance and support videos for ${featuredAppsString}`
|
||||||
}
|
},
|
||||||
|
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
getAppEndpoint
|
getAppEndpoint
|
||||||
|
|
@ -151,7 +203,10 @@ export default {
|
||||||
'property': 'twitter:url',
|
'property': 'twitter:url',
|
||||||
'content': `${process.env.URL}${this.$nuxt.$route.path}`
|
'content': `${process.env.URL}${this.$nuxt.$route.path}`
|
||||||
},
|
},
|
||||||
]
|
],
|
||||||
|
|
||||||
|
__dangerouslyDisableSanitizers: ['script'],
|
||||||
|
script: [{ innerHTML: JSON.stringify( buildVideoStructuredData( this.video, this.featuredApps ) ), type: 'application/ld+json' }]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue