From 106fa2249de343b60259a98634e2f38bd34c20d8 Mon Sep 17 00:00:00 2001 From: Thomas Citharel Date: Sun, 6 Dec 2020 18:47:49 +0100 Subject: Set canonical link to original video/playlist url The local URL was used instead of the original url Signed-off-by: Thomas Citharel --- server/lib/client-html.ts | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) (limited to 'server') 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 = { 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 += `` + tagsString += `` return htmlStringPage.replace(CUSTOM_HTML_TAG_COMMENTS.META_TAGS, tagsString) } -- cgit v1.2.3