Lazy load all routes
[oweals/peertube.git] / client / src / app / +videos / videos-routing.module.ts
1 import { NgModule } from '@angular/core'
2 import { RouterModule, Routes } from '@angular/router'
3 import { MetaGuard } from '@ngx-meta/core'
4 import { VideoOverviewComponent } from './video-list/overview/video-overview.component'
5 import { VideoLocalComponent } from './video-list/video-local.component'
6 import { VideoMostLikedComponent } from './video-list/video-most-liked.component'
7 import { VideoRecentlyAddedComponent } from './video-list/video-recently-added.component'
8 import { VideoTrendingComponent } from './video-list/video-trending.component'
9 import { VideoUserSubscriptionsComponent } from './video-list/video-user-subscriptions.component'
10 import { VideosComponent } from './videos.component'
11
12 const videosRoutes: Routes = [
13   {
14     path: '',
15     component: VideosComponent,
16     canActivateChild: [ MetaGuard ],
17     children: [
18       {
19         path: 'overview',
20         component: VideoOverviewComponent,
21         data: {
22           meta: {
23             title: 'Discover videos'
24           }
25         }
26       },
27       {
28         path: 'trending',
29         component: VideoTrendingComponent,
30         data: {
31           meta: {
32             title: 'Trending videos'
33           },
34           reuse: {
35             enabled: true,
36             key: 'trending-videos-list'
37           }
38         }
39       },
40       {
41         path: 'most-liked',
42         component: VideoMostLikedComponent,
43         data: {
44           meta: {
45             title: 'Most liked videos'
46           },
47           reuse: {
48             enabled: true,
49             key: 'most-liked-videos-list'
50           }
51         }
52       },
53       {
54         path: 'recently-added',
55         component: VideoRecentlyAddedComponent,
56         data: {
57           meta: {
58             title: 'Recently added videos'
59           },
60           reuse: {
61             enabled: true,
62             key: 'recently-added-videos-list'
63           }
64         }
65       },
66       {
67         path: 'subscriptions',
68         component: VideoUserSubscriptionsComponent,
69         data: {
70           meta: {
71             title: 'Subscriptions'
72           },
73           reuse: {
74             enabled: true,
75             key: 'subscription-videos-list'
76           }
77         }
78       },
79       {
80         path: 'local',
81         component: VideoLocalComponent,
82         data: {
83           meta: {
84             title: 'Local videos'
85           },
86           reuse: {
87             enabled: true,
88             key: 'local-videos-list'
89           }
90         }
91       },
92       {
93         path: 'upload',
94         loadChildren: () => import('@app/+videos/+video-edit/video-add.module').then(m => m.VideoAddModule),
95         data: {
96           meta: {
97             title: 'Upload a video'
98           }
99         }
100       },
101       {
102         path: 'update/:uuid',
103         loadChildren: () => import('@app/+videos/+video-edit/video-update.module').then(m => m.VideoUpdateModule),
104         data: {
105           meta: {
106             title: 'Edit a video'
107           }
108         }
109       },
110       {
111         path: 'watch',
112         loadChildren: () => import('@app/+videos/+video-watch/video-watch.module').then(m => m.VideoWatchModule),
113         data: {
114           preload: 3000
115         }
116       }
117     ]
118   }
119 ]
120
121 @NgModule({
122   imports: [ RouterModule.forChild(videosRoutes) ],
123   exports: [ RouterModule ]
124 })
125 export class VideosRoutingModule {}