]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blob - client/src/app/app-routing.module.ts
Instance homepage support (#4007)
[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 { CustomReuseStrategy } from '@app/core/routing/custom-reuse-strategy'
4 import { MenuGuards } from '@app/core/routing/menu-guard.service'
5 import { POSSIBLE_LOCALES } from '@shared/core-utils/i18n'
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: 'home',
18 loadChildren: () => import('./+home/home.module').then(m => m.HomeModule)
19 },
20 {
21 path: 'my-account',
22 loadChildren: () => import('./+my-account/my-account.module').then(m => m.MyAccountModule)
23 },
24 {
25 path: 'my-library',
26 loadChildren: () => import('./+my-library/my-library.module').then(m => m.MyLibraryModule)
27 },
28 {
29 path: 'verify-account',
30 loadChildren: () => import('./+signup/+verify-account/verify-account.module').then(m => m.VerifyAccountModule)
31 },
32 {
33 path: 'accounts',
34 loadChildren: () => import('./+accounts/accounts.module').then(m => m.AccountsModule)
35 },
36 {
37 path: 'video-channels',
38 loadChildren: () => import('./+video-channels/video-channels.module').then(m => m.VideoChannelsModule)
39 },
40 {
41 path: 'about',
42 loadChildren: () => import('./+about/about.module').then(m => m.AboutModule)
43 },
44 {
45 path: 'signup',
46 loadChildren: () => import('./+signup/+register/register.module').then(m => m.RegisterModule)
47 },
48 {
49 path: 'reset-password',
50 loadChildren: () => import('./+reset-password/reset-password.module').then(m => m.ResetPasswordModule)
51 },
52 {
53 path: 'login',
54 loadChildren: () => import('./+login/login.module').then(m => m.LoginModule)
55 },
56 {
57 path: 'search',
58 loadChildren: () => import('./+search/search.module').then(m => m.SearchModule)
59 },
60 {
61 path: 'videos',
62 loadChildren: () => import('./+videos/videos.module').then(m => m.VideosModule)
63 },
64 {
65 path: 'remote-interaction',
66 loadChildren: () => import('./+remote-interaction/remote-interaction.module').then(m => m.RemoteInteractionModule)
67 },
68 {
69 path: 'video-playlists/watch',
70 redirectTo: 'videos/watch/playlist'
71 },
72 {
73 path: '',
74 component: EmptyComponent // Avoid 404, app component will redirect dynamically
75 }
76 ]
77
78 // Avoid 404 when changing language
79 for (const locale of POSSIBLE_LOCALES) {
80 routes.push({
81 path: locale,
82 component: EmptyComponent
83 })
84 }
85
86 routes.push({
87 path: '**',
88 loadChildren: () => import('./+page-not-found/page-not-found.module').then(m => m.PageNotFoundModule)
89 })
90
91 @NgModule({
92 imports: [
93 RouterModule.forRoot(routes, {
94 useHash: Boolean(history.pushState) === false,
95 scrollPositionRestoration: 'disabled',
96 preloadingStrategy: PreloadSelectedModulesList,
97 anchorScrolling: 'disabled'
98 })
99 ],
100 providers: [
101 MenuGuards.guards,
102 PreloadSelectedModulesList,
103 { provide: RouteReuseStrategy, useClass: CustomReuseStrategy }
104 ],
105 exports: [ RouterModule ]
106 })
107 export class AppRoutingModule {}