From 7ca4de2d9816b771ed7ba535dcea129aa1cb7f61 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Wed, 8 Nov 2023 16:03:49 +0100 Subject: [PATCH] Update page title and description on video change --- .../app/+videos/+video-watch/video-watch.component.ts | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/client/src/app/+videos/+video-watch/video-watch.component.ts b/client/src/app/+videos/+video-watch/video-watch.component.ts index 5485b3ec5..7b8af3e32 100644 --- a/client/src/app/+videos/+video-watch/video-watch.component.ts +++ b/client/src/app/+videos/+video-watch/video-watch.component.ts @@ -15,7 +15,8 @@ import { Hotkey, HotkeysService, User, - UserService + UserService, + MetaService } from '@app/core' import { HooksService } from '@app/core/plugins/hooks.service' import { isXPercentInViewport, scrollToTop, toBoolean } from '@app/helpers' @@ -136,6 +137,7 @@ export class VideoWatchComponent implements OnInit, OnDestroy { private screenService: ScreenService, private videoFileTokenService: VideoFileTokenService, private location: PlatformLocation, + private metaService: MetaService, @Inject(LOCALE_ID) private localeId: string ) { } @@ -460,6 +462,7 @@ export class VideoWatchComponent implements OnInit, OnDestroy { } this.buildHotkeysHelp(video) + this.setMetaTags(video) this.loadPlayer({ loggedInOrAnonymousUser, forceAutoplay }) .catch(err => logger.error('Cannot build the player', err)) @@ -913,6 +916,12 @@ export class VideoWatchComponent implements OnInit, OnDestroy { this.hotkeysService.add(this.hotkeys) } + private setMetaTags (video: Video) { + this.metaService.setTitle(video.name) + + this.metaService.setTag('description', video.description) + } + private getUrlOptions (): URLOptions { const queryParams = this.route.snapshot.queryParams