diff options
author | Chocobozzz <me@florianbigard.com> | 2018-01-23 17:09:06 +0100 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2018-01-23 17:09:06 +0100 |
commit | 093237cf79ea62207b51dd632a4c4fd1f74d71fd (patch) | |
tree | 97286c140fdc23dfe1b19f8c0689a1f6140f7010 /server/controllers | |
parent | 63c4b44961aa86ed4dabf039e495879103f9d729 (diff) | |
download | PeerTube-093237cf79ea62207b51dd632a4c4fd1f74d71fd.tar.gz PeerTube-093237cf79ea62207b51dd632a4c4fd1f74d71fd.tar.zst PeerTube-093237cf79ea62207b51dd632a4c4fd1f74d71fd.zip |
Add schema.org tags to videos
Diffstat (limited to 'server/controllers')
-rw-r--r-- | server/controllers/client.ts | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/server/controllers/client.ts b/server/controllers/client.ts index 39e046727..bb02f5075 100644 --- a/server/controllers/client.ts +++ b/server/controllers/client.ts | |||
@@ -84,6 +84,16 @@ function addOpenGraphAndOEmbedTags (htmlStringPage: string, video: VideoModel) { | |||
84 | } | 84 | } |
85 | ] | 85 | ] |
86 | 86 | ||
87 | const schemaTags = { | ||
88 | name: videoNameEscaped, | ||
89 | description: videoDescriptionEscaped, | ||
90 | duration: video.getActivityStreamDuration(), | ||
91 | thumbnailURL: previewUrl, | ||
92 | contentURL: videoUrl, | ||
93 | embedURL: embedUrl, | ||
94 | uploadDate: video.createdAt | ||
95 | } | ||
96 | |||
87 | let tagsString = '' | 97 | let tagsString = '' |
88 | Object.keys(openGraphMetaTags).forEach(tagName => { | 98 | Object.keys(openGraphMetaTags).forEach(tagName => { |
89 | const tagValue = openGraphMetaTags[tagName] | 99 | const tagValue = openGraphMetaTags[tagName] |
@@ -95,6 +105,16 @@ function addOpenGraphAndOEmbedTags (htmlStringPage: string, video: VideoModel) { | |||
95 | tagsString += `<link rel="alternate" type="${oembedLinkTag.type}" href="${oembedLinkTag.href}" title="${oembedLinkTag.title}" />` | 105 | tagsString += `<link rel="alternate" type="${oembedLinkTag.type}" href="${oembedLinkTag.href}" title="${oembedLinkTag.title}" />` |
96 | } | 106 | } |
97 | 107 | ||
108 | tagsString += '<div itemprop="video" itemscope itemtype="http://schema.org/VideoObject">' | ||
109 | tagsString += '<h2>Video: <span itemprop="name">' + schemaTags.name + '</span></h2>' | ||
110 | |||
111 | Object.keys(schemaTags).forEach(tagName => { | ||
112 | const tagValue = schemaTags[tagName] | ||
113 | tagsString += `<meta itemprop="${tagName}" content="${tagValue}" />` | ||
114 | }) | ||
115 | |||
116 | tagsString += '</div>' | ||
117 | |||
98 | return htmlStringPage.replace(OPENGRAPH_AND_OEMBED_COMMENT, tagsString) | 118 | return htmlStringPage.replace(OPENGRAPH_AND_OEMBED_COMMENT, tagsString) |
99 | } | 119 | } |
100 | 120 | ||