aboutsummaryrefslogtreecommitdiffhomepage
path: root/server
diff options
context:
space:
mode:
authorThomas Citharel <tcit@tcit.fr>2020-12-06 18:47:49 +0100
committerChocobozzz <chocobozzz@cpy.re>2020-12-08 11:15:11 +0100
commit106fa2249de343b60259a98634e2f38bd34c20d8 (patch)
tree4b2aa62f3ab061225cbc9f83ee0e4f2299b7abeb /server
parent2805cb7cb68cae0f25bd43f166e4a6b8501d41eb (diff)
downloadPeerTube-106fa2249de343b60259a98634e2f38bd34c20d8.tar.gz
PeerTube-106fa2249de343b60259a98634e2f38bd34c20d8.tar.zst
PeerTube-106fa2249de343b60259a98634e2f38bd34c20d8.zip
Set canonical link to original video/playlist url
The local URL was used instead of the original url Signed-off-by: Thomas Citharel <tcit@tcit.fr>
Diffstat (limited to 'server')
-rw-r--r--server/lib/client-html.ts18
1 files changed, 13 insertions, 5 deletions
diff --git a/server/lib/client-html.ts b/server/lib/client-html.ts
index a1a4a5316..211ac3342 100644
--- a/server/lib/client-html.ts
+++ b/server/lib/client-html.ts
@@ -36,6 +36,7 @@ type Tags = {
36 siteName: string 36 siteName: string
37 title: string 37 title: string
38 url: string 38 url: string
39 originUrl: string
39 description: string 40 description: string
40 41
41 embed?: { 42 embed?: {
@@ -95,6 +96,7 @@ export class ClientHtml {
95 customHtml = ClientHtml.addDescriptionTag(customHtml, escapeHTML(video.description)) 96 customHtml = ClientHtml.addDescriptionTag(customHtml, escapeHTML(video.description))
96 97
97 const url = WEBSERVER.URL + video.getWatchStaticPath() 98 const url = WEBSERVER.URL + video.getWatchStaticPath()
99 const originUrl = video.url
98 const title = escapeHTML(video.name) 100 const title = escapeHTML(video.name)
99 const siteName = escapeHTML(CONFIG.INSTANCE.NAME) 101 const siteName = escapeHTML(CONFIG.INSTANCE.NAME)
100 const description = escapeHTML(video.description) 102 const description = escapeHTML(video.description)
@@ -114,7 +116,9 @@ export class ClientHtml {
114 const twitterCard = CONFIG.SERVICES.TWITTER.WHITELISTED ? 'player' : 'summary_large_image' 116 const twitterCard = CONFIG.SERVICES.TWITTER.WHITELISTED ? 'player' : 'summary_large_image'
115 const schemaType = 'VideoObject' 117 const schemaType = 'VideoObject'
116 118
117 customHtml = ClientHtml.addTags(customHtml, { url, siteName, title, description, image, embed, ogType, twitterCard, schemaType }) 119 customHtml = ClientHtml.addTags(customHtml, {
120 url, originUrl, siteName, title, description, image, embed, ogType, twitterCard, schemaType
121 })
118 122
119 return customHtml 123 return customHtml
120 } 124 }
@@ -141,6 +145,7 @@ export class ClientHtml {
141 customHtml = ClientHtml.addDescriptionTag(customHtml, escapeHTML(videoPlaylist.description)) 145 customHtml = ClientHtml.addDescriptionTag(customHtml, escapeHTML(videoPlaylist.description))
142 146
143 const url = videoPlaylist.getWatchUrl() 147 const url = videoPlaylist.getWatchUrl()
148 const originUrl = videoPlaylist.url
144 const title = escapeHTML(videoPlaylist.name) 149 const title = escapeHTML(videoPlaylist.name)
145 const siteName = escapeHTML(CONFIG.INSTANCE.NAME) 150 const siteName = escapeHTML(CONFIG.INSTANCE.NAME)
146 const description = escapeHTML(videoPlaylist.description) 151 const description = escapeHTML(videoPlaylist.description)
@@ -162,7 +167,9 @@ export class ClientHtml {
162 const twitterCard = CONFIG.SERVICES.TWITTER.WHITELISTED ? 'player' : 'summary' 167 const twitterCard = CONFIG.SERVICES.TWITTER.WHITELISTED ? 'player' : 'summary'
163 const schemaType = 'ItemList' 168 const schemaType = 'ItemList'
164 169
165 customHtml = ClientHtml.addTags(customHtml, { url, siteName, embed, title, description, image, list, ogType, twitterCard, schemaType }) 170 customHtml = ClientHtml.addTags(customHtml, {
171 url, originUrl, siteName, embed, title, description, image, list, ogType, twitterCard, schemaType
172 })
166 173
167 return customHtml 174 return customHtml
168 } 175 }
@@ -210,6 +217,7 @@ export class ClientHtml {
210 customHtml = ClientHtml.addDescriptionTag(customHtml, escapeHTML(entity.description)) 217 customHtml = ClientHtml.addDescriptionTag(customHtml, escapeHTML(entity.description))
211 218
212 const url = entity.Actor.url 219 const url = entity.Actor.url
220 const originUrl = entity.Actor.url
213 const siteName = escapeHTML(CONFIG.INSTANCE.NAME) 221 const siteName = escapeHTML(CONFIG.INSTANCE.NAME)
214 const title = escapeHTML(entity.getDisplayName()) 222 const title = escapeHTML(entity.getDisplayName())
215 const description = escapeHTML(entity.description) 223 const description = escapeHTML(entity.description)
@@ -224,7 +232,7 @@ export class ClientHtml {
224 const twitterCard = 'summary' 232 const twitterCard = 'summary'
225 const schemaType = 'ProfilePage' 233 const schemaType = 'ProfilePage'
226 234
227 customHtml = ClientHtml.addTags(customHtml, { url, title, siteName, description, image, ogType, twitterCard, schemaType }) 235 customHtml = ClientHtml.addTags(customHtml, { url, originUrl, title, siteName, description, image, ogType, twitterCard, schemaType })
228 236
229 return customHtml 237 return customHtml
230 } 238 }
@@ -417,7 +425,7 @@ export class ClientHtml {
417 const twitterCardMetaTags = this.generateTwitterCardMetaTags(tagsValues) 425 const twitterCardMetaTags = this.generateTwitterCardMetaTags(tagsValues)
418 const schemaTags = this.generateSchemaTags(tagsValues) 426 const schemaTags = this.generateSchemaTags(tagsValues)
419 427
420 const { url, title, embed } = tagsValues 428 const { url, title, embed, originUrl } = tagsValues
421 429
422 const oembedLinkTags: { type: string, href: string, title: string }[] = [] 430 const oembedLinkTags: { type: string, href: string, title: string }[] = []
423 431
@@ -463,7 +471,7 @@ export class ClientHtml {
463 } 471 }
464 472
465 // SEO, use origin URL 473 // SEO, use origin URL
466 tagsString += `<link rel="canonical" href="${url}" />` 474 tagsString += `<link rel="canonical" href="${originUrl}" />`
467 475
468 return htmlStringPage.replace(CUSTOM_HTML_TAG_COMMENTS.META_TAGS, tagsString) 476 return htmlStringPage.replace(CUSTOM_HTML_TAG_COMMENTS.META_TAGS, tagsString)
469 } 477 }