Update page title and description on video change

This commit is contained in:
Chocobozzz 2023-11-08 16:03:49 +01:00
parent dbd0a3bcac
commit 7ca4de2d98
No known key found for this signature in database
GPG Key ID: 583A612D890159BE
1 changed files with 10 additions and 1 deletions

View File

@ -15,7 +15,8 @@ import {
Hotkey, Hotkey,
HotkeysService, HotkeysService,
User, User,
UserService UserService,
MetaService
} from '@app/core' } from '@app/core'
import { HooksService } from '@app/core/plugins/hooks.service' import { HooksService } from '@app/core/plugins/hooks.service'
import { isXPercentInViewport, scrollToTop, toBoolean } from '@app/helpers' import { isXPercentInViewport, scrollToTop, toBoolean } from '@app/helpers'
@ -136,6 +137,7 @@ export class VideoWatchComponent implements OnInit, OnDestroy {
private screenService: ScreenService, private screenService: ScreenService,
private videoFileTokenService: VideoFileTokenService, private videoFileTokenService: VideoFileTokenService,
private location: PlatformLocation, private location: PlatformLocation,
private metaService: MetaService,
@Inject(LOCALE_ID) private localeId: string @Inject(LOCALE_ID) private localeId: string
) { } ) { }
@ -460,6 +462,7 @@ export class VideoWatchComponent implements OnInit, OnDestroy {
} }
this.buildHotkeysHelp(video) this.buildHotkeysHelp(video)
this.setMetaTags(video)
this.loadPlayer({ loggedInOrAnonymousUser, forceAutoplay }) this.loadPlayer({ loggedInOrAnonymousUser, forceAutoplay })
.catch(err => logger.error('Cannot build the player', err)) .catch(err => logger.error('Cannot build the player', err))
@ -913,6 +916,12 @@ export class VideoWatchComponent implements OnInit, OnDestroy {
this.hotkeysService.add(this.hotkeys) this.hotkeysService.add(this.hotkeys)
} }
private setMetaTags (video: Video) {
this.metaService.setTitle(video.name)
this.metaService.setTag('description', video.description)
}
private getUrlOptions (): URLOptions { private getUrlOptions (): URLOptions {
const queryParams = this.route.snapshot.queryParams const queryParams = this.route.snapshot.queryParams