import { computed, inject, Injectable, type Signal } from '@angular/core'; import { LocaleService } from '../i18n/locale.service'; import { type RouteId } from '../routing/route-ids'; import { CASE_STUDY_IDS, type CaseStudyCopy, type CaseStudyId, type ContactPageCopy, type HomePageCopy, type LegalPageCopy, type PageCopy, type PitchPageCopy, type ProjectsPageCopy, type ServicesPageCopy, type StackPageCopy, } from './content.contracts'; import { SITE_CONTENT } from './content.token'; @Injectable({ providedIn: 'root' }) export class ContentService { private readonly localeService = inject(LocaleService); private readonly content = inject(SITE_CONTENT); page(routeId: RouteId): Signal { return computed(() => this.content[this.localeService.locale()].pages[routeId]); } home(): Signal { return computed(() => this.content[this.localeService.locale()].home); } pitch(): Signal { return computed(() => this.content[this.localeService.locale()].pitch); } services(): Signal { return computed(() => this.content[this.localeService.locale()].services); } caseStudy(id: CaseStudyId): Signal { return computed(() => this.content[this.localeService.locale()].cases[id]); } cases(): Signal { return computed(() => { const cases = this.content[this.localeService.locale()].cases; return CASE_STUDY_IDS.map((id) => cases[id]); }); } contact(): Signal { return computed(() => this.content[this.localeService.locale()].contact); } projects(): Signal { return computed(() => this.content[this.localeService.locale()].projects); } stack(): Signal { return computed(() => this.content[this.localeService.locale()].stack); } legal(id: 'imprint' | 'privacy'): Signal { return computed(() => this.content[this.localeService.locale()].legal[id]); } }