]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blob - client/src/app/app-routing.module.ts
Lazy load all routes
[github/Chocobozzz/PeerTube.git] / client / src / app / app-routing.module.ts
1 import { NgModule } from '@angular/core'
2 import { RouteReuseStrategy, RouterModule, Routes } from '@angular/router'
3 import { AppComponent } from '@app/app.component'
4 import { CustomReuseStrategy } from '@app/core/routing/custom-reuse-strategy'
5 import { MenuGuards } from '@app/core/routing/menu-guard.service'
6 import { PreloadSelectedModulesList } from './core'
7 import { EmptyComponent } from './empty.component'
8
9 const routes: Routes = [
10 {
11 path: 'admin',
12 canActivate: [ MenuGuards.close() ],
13 canDeactivate: [ MenuGuards.open() ],
14 loadChildren: () => import('./+admin/admin.module').then(m => m.AdminModule)
15 },
16 {
17 path: 'my-account',
18 loadChildren: () => import('./+my-account/my-account.module').then(m => m.MyAccountModule)
19 },
20 {
21 path: 'verify-account',
22 loadChildren: () => import('./+signup/+verify-account/verify-account.module').then(m => m.VerifyAccountModule)
23 },
24 {
25 path: 'accounts',
26 loadChildren: () => import('./+accounts/accounts.module').then(m => m.AccountsModule)
27 },
28 {
29 path: 'video-channels',
30 loadChildren: () => import('./+video-channels/video-channels.module').then(m => m.VideoChannelsModule)
31 },
32 {
33 path: 'about',
34 loadChildren: () => import('./+about/about.module').then(m => m.AboutModule)
35 },
36 {
37 path: 'signup',
38 loadChildren: () => import('./+signup/+register/register.module').then(m => m.RegisterModule)
39 },
40 {
41 path: 'reset-password',
42 loadChildren: () => import('./+reset-password/reset-password.module').then(m => m.ResetPasswordModule)
43 },
44 {
45 path: 'login',
46 loadChildren: () => import('./+login/login.module').then(m => m.LoginModule)
47 },
48 {
49 path: 'search',
50 loadChildren: () => import('./+search/search.module').then(m => m.SearchModule)
51 },
52 {
53 path: 'videos',
54 loadChildren: () => import('./+videos/videos.module').then(m => m.VideosModule)
55 },
56 {
57 path: '',
58 component: EmptyComponent // Avoid 404, app component will redirect dynamically
59 },
60 {
61 path: '**',
62 loadChildren: () => import('./+page-not-found/page-not-found.module').then(m => m.PageNotFoundModule)
63 }
64 ]
65
66 @NgModule({
67 imports: [
68 RouterModule.forRoot(routes, {
69 useHash: Boolean(history.pushState) === false,
70 scrollPositionRestoration: 'disabled',
71 preloadingStrategy: PreloadSelectedModulesList,
72 anchorScrolling: 'disabled'
73 })
74 ],
75 providers: [
76 MenuGuards.guards,
77 PreloadSelectedModulesList,
78 { provide: RouteReuseStrategy, useClass: CustomReuseStrategy }
79 ],
80 exports: [ RouterModule ]
81 })
82 export class AppRoutingModule {}