diff --git a/.gitignore b/.gitignore index d9eb71a..05644c2 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ ~$*.pptx node_modules +.idea diff --git a/itenium-socks/angular.json b/itenium-socks/angular.json index e7cfa50..f61caf2 100644 --- a/itenium-socks/angular.json +++ b/itenium-socks/angular.json @@ -100,5 +100,8 @@ } } } + }, + "cli": { + "analytics": false } } diff --git a/itenium-socks/src/app/TemplatePageTitleStrategy.ts b/itenium-socks/src/app/TemplatePageTitleStrategy.ts new file mode 100644 index 0000000..3a6f2d5 --- /dev/null +++ b/itenium-socks/src/app/TemplatePageTitleStrategy.ts @@ -0,0 +1,21 @@ +import { Injectable } from "@angular/core"; +import { RouterStateSnapshot, TitleStrategy } from "@angular/router"; +import { Title } from "@angular/platform-browser"; + +@Injectable({ providedIn: 'root' }) +export class TemplatePageTitleStrategy extends TitleStrategy { + constructor(private readonly title: Title) { + super(); + } + + private readonly default_title = "Toe-tally Amazing"; + + override updateTitle(routerState: RouterStateSnapshot) { + const title = this.buildTitle(routerState) + if (!title) { + this.title.setTitle(this.default_title); + } else { + this.title.setTitle(`${title} | ${this.default_title}`); + } + } +} diff --git a/itenium-socks/src/app/app.config.ts b/itenium-socks/src/app/app.config.ts index 3450030..0fa1702 100644 --- a/itenium-socks/src/app/app.config.ts +++ b/itenium-socks/src/app/app.config.ts @@ -1,13 +1,15 @@ import { ApplicationConfig, provideZoneChangeDetection } from '@angular/core'; -import { provideRouter } from '@angular/router'; +import { provideRouter, TitleStrategy } from '@angular/router'; import { provideHttpClient, withFetch } from '@angular/common/http'; import { routes } from './app.routes'; +import { TemplatePageTitleStrategy } from "./TemplatePageTitleStrategy"; export const appConfig: ApplicationConfig = { providers: [ provideZoneChangeDetection({ eventCoalescing: true }), provideRouter(routes), provideHttpClient(withFetch()), + { provide: TitleStrategy, useClass: TemplatePageTitleStrategy }, ] }; diff --git a/itenium-socks/src/app/app.routes.ts b/itenium-socks/src/app/app.routes.ts index 14b59f8..141591c 100644 --- a/itenium-socks/src/app/app.routes.ts +++ b/itenium-socks/src/app/app.routes.ts @@ -12,7 +12,7 @@ export const routes: Routes = [ path: '', component: LayoutComponent, children: [ - { path: 'why-us', component: WhyUsComponent }, + { path: 'why-us', component: WhyUsComponent, title: "Why Us" }, { path: 'socks', component: ShopComponent }, { path: 'socks/:id', component: SockComponent }, ] diff --git a/itenium-socks/src/index.html b/itenium-socks/src/index.html index da0623f..8edd79f 100644 --- a/itenium-socks/src/index.html +++ b/itenium-socks/src/index.html @@ -2,7 +2,6 @@ - Toe-tally Amazing