Bumped to version v0.0.14-alpha
[oweals/peertube.git] / server / controllers / client.ts
index 39e046727291714afa75ded7b1a0945dfd8f859b..bb02f5075e1a6af3b8bc5147988c2e2ea82b461f 100644 (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)
 }