Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 44 additions & 4 deletions src/app/app.component.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,13 @@
/* eslint-disable @typescript-eslint/no-extraneous-class */
import { ChangeDetectionStrategy, Component } from '@angular/core';
import { RouterOutlet } from '@angular/router';
import { ChangeDetectionStrategy, Component, inject, OnInit } from '@angular/core';
import { Meta } from '@angular/platform-browser';
import { ActivatedRoute, Data, NavigationEnd, Router, RouterOutlet } from '@angular/router';
import { NavBarComponent } from 'components/nav-bar/nav-bar.component';
import { TabBarComponent } from 'components/tab-bar/tab-bar.component';
import { of } from 'rxjs';
import { filter, map, mergeMap } from 'rxjs/operators';

const DEFAULT_DESCRIPTION =
"Site dedicated to and maintained by SFU's Computing Science Student Society";

@Component({
selector: 'app-root',
Expand All @@ -11,4 +16,39 @@ import { TabBarComponent } from 'components/tab-bar/tab-bar.component';
styleUrl: './app.component.scss',
changeDetection: ChangeDetectionStrategy.OnPush
})
export class AppComponent {}
export class AppComponent implements OnInit {
private router = inject(Router);
private route = inject(ActivatedRoute);
private metaService = inject(Meta);

ngOnInit(): void {
this.router.events
.pipe(
filter(event => event instanceof NavigationEnd),
map(() => {
let route = this.route.firstChild;
while (route?.firstChild) {
route = route.firstChild;
}
return route;
}),
filter(route => route?.outlet === 'primary'),
mergeMap(route => route?.data ?? of({} as Data))
)
.subscribe(data => {
if (data['meta']) {
this.metaService.updateTag({
name: 'robots',
content: 'noindex'
});
} else {
this.metaService.removeTag("name='robots'");
}
const desc = data['description'] ?? DEFAULT_DESCRIPTION;
this.metaService.updateTag({
name: 'description',
content: desc
});
});
}
}
45 changes: 36 additions & 9 deletions src/app/app.routes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,58 +15,85 @@ export const routes: Routes = [
{
path: 'readme',
loadComponent: () => import('./pages/readme/readme.component').then(m => m.ReadMeComponent),
title: makeTitle('README')
title: makeTitle('README'),
data: {
description: 'Welcome to the Computing Science Student Society!'
}
},
{
path: 'officers',
loadComponent: () =>
import('./pages/officers/officers.component').then(m => m.OfficersComponent),
title: makeTitle('Officers')
title: makeTitle('Officers'),
data: {
description: 'Meet the officers that keep the CSSS running.'
}
},
{
path: 'committees',
loadComponent: () =>
import('./pages/committees/committees.component').then(m => m.CommitteesComponent),
title: makeTitle('Committees')
title: makeTitle('Committees'),
data: {
description: 'Learn about the committees that make up the CSSS.'
}
},
{
path: 'common-room',
loadComponent: () =>
import('./pages/common-room/common-room.component').then(m => m.CommonRoomComponent),
title: makeTitle('Common Room')
title: makeTitle('Common Room'),
data: {
description: 'Come hang out with us in the Common Room.'
}
},
{
path: 'affiliates',
loadComponent: () =>
import('./pages/affiliates/affiliates.component').then(m => m.AffiliatesComponent),
title: makeTitle('Affiliates')
title: makeTitle('Affiliates'),
data: {
description: 'Find out about other societies and clubs that our members interact with'
}
},
// Events
{
path: 'events',
loadComponent: () => import('./pages/events/events.component').then(m => m.EventsComponent),
title: makeTitle('Events')
title: makeTitle('Events'),
data: {
description: 'Discover the events the CSSS hosts.'
}
},
{
path: 'event-archives',
loadComponent: () =>
import('pages/event-archives/event-archives.component').then(m => m.EventArchivesComponent),
title: makeTitle('Event Archives')
title: makeTitle('Event Archives'),
data: {
description: 'Explore the old event pages past executive teams created.'
}
},
// Elections
{
path: 'elections',
loadComponent: () =>
import('./pages/elections/elections.component').then(m => m.ElectionsComponent),
title: makeTitle('Elections')
title: makeTitle('Elections'),
data: {
description: 'Learn about the responsibilities of our executives and how you can become one.'
}
},
{ path: '', component: HomeComponent, title: 'Computing Science Student Society' },
// 404 will go down there
{
path: '**',
loadComponent: () =>
import('./pages/not-found/not-found.component').then(m => m.NotFoundComponent),
title: makeTitle('Not Found')
title: makeTitle('Not Found'),
data: {
meta: 'noindex'
}
}
] as const;

Expand Down