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>
pull/3432/head
Thomas Citharel 2020-12-06 18:47:49 +01:00 committed by Chocobozzz
parent 2805cb7cb6
commit 106fa2249d
1 changed files with 13 additions and 5 deletions

View File

@ -36,6 +36,7 @@ type Tags = {
siteName: string
title: string
url: string
originUrl: string
description: string
embed?: {
@ -95,6 +96,7 @@ export class ClientHtml {
customHtml = ClientHtml.addDescriptionTag(customHtml, escapeHTML(video.description))
const url = WEBSERVER.URL + video.getWatchStaticPath()
const originUrl = video.url
const title = escapeHTML(video.name)
const siteName = escapeHTML(CONFIG.INSTANCE.NAME)
const description = escapeHTML(video.description)
@ -114,7 +116,9 @@ export class ClientHtml {
const twitterCard = CONFIG.SERVICES.TWITTER.WHITELISTED ? 'player' : 'summary_large_image'
const schemaType = 'VideoObject'
customHtml = ClientHtml.addTags(customHtml, { url, siteName, title, description, image, embed, ogType, twitterCard, schemaType })
customHtml = ClientHtml.addTags(customHtml, {
url, originUrl, siteName, title, description, image, embed, ogType, twitterCard, schemaType
})
return customHtml
}
@ -141,6 +145,7 @@ export class ClientHtml {
customHtml = ClientHtml.addDescriptionTag(customHtml, escapeHTML(videoPlaylist.description))
const url = videoPlaylist.getWatchUrl()
const originUrl = videoPlaylist.url
const title = escapeHTML(videoPlaylist.name)
const siteName = escapeHTML(CONFIG.INSTANCE.NAME)
const description = escapeHTML(videoPlaylist.description)
@ -162,7 +167,9 @@ export class ClientHtml {
const twitterCard = CONFIG.SERVICES.TWITTER.WHITELISTED ? 'player' : 'summary'
const schemaType = 'ItemList'
customHtml = ClientHtml.addTags(customHtml, { url, siteName, embed, title, description, image, list, ogType, twitterCard, schemaType })
customHtml = ClientHtml.addTags(customHtml, {
url, originUrl, siteName, embed, title, description, image, list, ogType, twitterCard, schemaType
})
return customHtml
}
@ -210,6 +217,7 @@ export class ClientHtml {
customHtml = ClientHtml.addDescriptionTag(customHtml, escapeHTML(entity.description))
const url = entity.Actor.url
const originUrl = entity.Actor.url
const siteName = escapeHTML(CONFIG.INSTANCE.NAME)
const title = escapeHTML(entity.getDisplayName())
const description = escapeHTML(entity.description)
@ -224,7 +232,7 @@ export class ClientHtml {
const twitterCard = 'summary'
const schemaType = 'ProfilePage'
customHtml = ClientHtml.addTags(customHtml, { url, title, siteName, description, image, ogType, twitterCard, schemaType })
customHtml = ClientHtml.addTags(customHtml, { url, originUrl, title, siteName, description, image, ogType, twitterCard, schemaType })
return customHtml
}
@ -417,7 +425,7 @@ export class ClientHtml {
const twitterCardMetaTags = this.generateTwitterCardMetaTags(tagsValues)
const schemaTags = this.generateSchemaTags(tagsValues)
const { url, title, embed } = tagsValues
const { url, title, embed, originUrl } = tagsValues
const oembedLinkTags: { type: string, href: string, title: string }[] = []
@ -463,7 +471,7 @@ export class ClientHtml {
}
// SEO, use origin URL
tagsString += `<link rel="canonical" href="${url}" />`
tagsString += `<link rel="canonical" href="${originUrl}" />`
return htmlStringPage.replace(CUSTOM_HTML_TAG_COMMENTS.META_TAGS, tagsString)
}