import { Component, OnInit } from '@angular/core';
import { Location } from '@angular/common';

import { PageService }      from '../../../services/svc.page';
import { PageType }         from '../../../types/page';
import { SeoService }       from '../../../services/svc.seo';

@Component({
  moduleId: module.id+'',
  selector: 'video-view',
  templateUrl: 'tpl.video.pug'
})
export class VideoView implements OnInit {

  constructor(
    private _page: PageService,
    private _location: Location,
    private _seo : SeoService
  ) { }

  pageContent;

  ngOnInit() { 
    // Get current location, strip first occurrence of `/`
        let urlKey:string = this._location.path();
        if(urlKey.match(/\/.+/)){
            urlKey = urlKey.replace('/', '');
        }

        // Get page content
        this._page.getPageContent(urlKey)
            .then((content) => {
                this.pageContent = content;

                // Set SEO
                this._seo.setTitle(content.meta.title);
                this._seo.updateTag('description', content.meta.description);
            });
  }

}