1
0
Fork 0
mirror of https://github.com/Chocobozzz/PeerTube.git synced 2025-10-04 10:19:35 +02:00

Add schema.org tags to videos

This commit is contained in:
Chocobozzz 2018-01-23 17:09:06 +01:00
parent 63c4b44961
commit 093237cf79
No known key found for this signature in database
GPG key ID: 583A612D890159BE
2 changed files with 26 additions and 2 deletions

View file

@ -84,6 +84,16 @@ function addOpenGraphAndOEmbedTags (htmlStringPage: string, video: VideoModel) {
}
]
const schemaTags = {
name: videoNameEscaped,
description: videoDescriptionEscaped,
duration: video.getActivityStreamDuration(),
thumbnailURL: previewUrl,
contentURL: videoUrl,
embedURL: embedUrl,
uploadDate: video.createdAt
}
let tagsString = ''
Object.keys(openGraphMetaTags).forEach(tagName => {
const tagValue = openGraphMetaTags[tagName]
@ -95,6 +105,16 @@ function addOpenGraphAndOEmbedTags (htmlStringPage: string, video: VideoModel) {
tagsString += `<link rel="alternate" type="${oembedLinkTag.type}" href="${oembedLinkTag.href}" title="${oembedLinkTag.title}" />`
}
tagsString += '<div itemprop="video" itemscope itemtype="http://schema.org/VideoObject">'
tagsString += '<h2>Video: <span itemprop="name">' + schemaTags.name + '</span></h2>'
Object.keys(schemaTags).forEach(tagName => {
const tagValue = schemaTags[tagName]
tagsString += `<meta itemprop="${tagName}" content="${tagValue}" />`
})
tagsString += '</div>'
return htmlStringPage.replace(OPENGRAPH_AND_OEMBED_COMMENT, tagsString)
}