From ee2674964d183c929676fda31857681aff324add Mon Sep 17 00:00:00 2001 From: jvyden Date: Sat, 1 Jun 2024 19:00:37 -0400 Subject: [PATCH] Ability to embed categories --- src/app/pages/level-listing/level-listing.component.ts | 9 +++++++-- src/app/services/embed.service.ts | 5 +++++ 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/src/app/pages/level-listing/level-listing.component.ts b/src/app/pages/level-listing/level-listing.component.ts index b0205c7..1f65b65 100644 --- a/src/app/pages/level-listing/level-listing.component.ts +++ b/src/app/pages/level-listing/level-listing.component.ts @@ -12,6 +12,7 @@ import {ContainerComponent} from "../../components/ui/container.component"; import {Scrollable} from "../../helpers/scrollable"; import {defaultListInfo, RefreshApiListInfo} from "../../api/refresh-api-list-info"; import {InfiniteScrollerComponent} from "../../components/ui/infinite-scroller.component"; +import {EmbedService} from "../../services/embed.service"; @Component({ selector: 'app-level-listing', @@ -34,7 +35,7 @@ export class LevelListingComponent implements OnInit, Scrollable { private queryParams: Params = {}; - constructor(private client: ClientService, private route: ActivatedRoute) { + constructor(private client: ClientService, private embed: EmbedService, private route: ActivatedRoute) { // Start requesting category information immediately. this.client.getLevelCategories().subscribe(); } @@ -70,8 +71,12 @@ export class LevelListingComponent implements OnInit, Scrollable { if(this.category === undefined) this.category = null; - if(this.category) + if(this.category) { this.loadData(); + this.embed.embedCategory(this.category) + } else { + console.warn("No category found for route " + route) + } }); } diff --git a/src/app/services/embed.service.ts b/src/app/services/embed.service.ts index d3e29d0..71be697 100644 --- a/src/app/services/embed.service.ts +++ b/src/app/services/embed.service.ts @@ -7,6 +7,7 @@ import {ClientService} from "../api/client.service"; import {Photo} from "../api/types/photos/photo"; import {getImageLink} from "../helpers/data-fetching"; import {TitleService} from "./title.service"; +import {LevelCategory} from "../api/types/levels/level-category"; @Injectable({providedIn: 'root'}) export class EmbedService { @@ -89,4 +90,8 @@ export class EmbedService { this.setNamedTag("twitter:card", "summary_large_image"); this.setNamedTag("twitter:image", getImageLink(photo.largeHash)); } + + embedCategory(category: LevelCategory) { + this.embed(category.name, category.description); + } }