import { RouterConfiguration , Router , RouteConfig } from 'aurelia-router' ; import { templates } from './templates' ; interface IReference { name : string ; url : string ; } export interface IComponentTemplate { title ? : string ; description ? : string ; references ? : IReference [ ] ; code ? : string ; sass ? : string ; mdcUrls ? : IReference [ ] ; } export class ComponentViewer { template : IComponentTemplate ; router : Router ; configureRouter ( config , router ) { this . router = router ; config . map ( [ { route : '' , redirect : 'examples' } , { route : 'examples' , name : 'examples' , title : 'Examples' , moduleId : './examples' } , { route : 'api' , name : 'api' , title : 'Api' , moduleId : '../api-viewer/api-viewer' } ] ) ; } tabs : RouteConfig [ ] ; attached ( ) { this . tabs = this . router . routes . filter ( x => ! x . redirect ) ; this . template = templates [ this . router . parent . currentInstruction . config . name ! ] ; } navigateTo ( tab ) { this . router . navigateToRoute ( tab . route as string ) ; } }