PeerTube/client/src/app/+videos/videos-routing.module.ts

73 lines
1.7 KiB
TypeScript
Raw Normal View History

import { NgModule } from '@angular/core'
import { RouterModule, Routes, UrlSegment } from '@angular/router'
2021-01-27 17:15:21 +01:00
import { LoginGuard } from '@app/core'
import { VideosListCommonPageComponent } from './video-list'
2020-06-23 14:49:20 +02:00
import { VideoOverviewComponent } from './video-list/overview/video-overview.component'
2020-06-23 14:10:17 +02:00
import { VideoUserSubscriptionsComponent } from './video-list/video-user-subscriptions.component'
2016-07-08 17:15:14 +02:00
2016-11-20 17:18:15 +01:00
const videosRoutes: Routes = [
2016-07-08 17:15:14 +02:00
{
2020-06-23 14:49:20 +02:00
path: '',
2016-07-08 17:15:14 +02:00
children: [
2018-08-30 14:58:00 +02:00
{
path: 'overview',
component: VideoOverviewComponent,
data: {
meta: {
2020-08-17 10:30:59 +02:00
title: $localize`Discover videos`
2018-08-30 14:58:00 +02:00
}
}
},
2016-07-08 17:15:14 +02:00
{
// Old URL redirection
2019-10-01 23:11:53 +02:00
path: 'most-liked',
redirectTo: 'trending?sort=most-liked'
2019-10-01 23:11:53 +02:00
},
2017-12-01 14:46:22 +01:00
{
matcher: (url: UrlSegment[]) => {
if (url.length === 1 && [ 'recently-added', 'trending', 'local' ].includes(url[0].path)) {
return {
consumed: url,
posParams: {
page: new UrlSegment(url[0].path, {})
}
}
}
return null
},
component: VideosListCommonPageComponent,
2016-11-04 17:25:26 +01:00
data: {
2019-03-21 16:49:46 +01:00
reuse: {
enabled: true,
key: 'videos-list'
2016-11-04 17:25:26 +01:00
}
}
2016-07-08 17:15:14 +02:00
},
2018-03-13 10:24:28 +01:00
{
2018-08-21 16:18:59 +02:00
path: 'subscriptions',
canActivate: [ LoginGuard ],
2018-08-21 16:18:59 +02:00
component: VideoUserSubscriptionsComponent,
data: {
meta: {
2020-08-17 10:30:59 +02:00
title: $localize`Subscriptions`
2019-03-21 16:49:46 +01:00
},
reuse: {
enabled: true,
key: 'subscription-videos-list'
2018-08-21 16:18:59 +02:00
}
}
2016-07-08 17:15:14 +02:00
}
]
}
]
2016-11-20 17:18:15 +01:00
@NgModule({
imports: [ RouterModule.forChild(videosRoutes) ],
exports: [ RouterModule ]
})
export class VideosRoutingModule {}