Skip to content

Commit

Permalink
Ability to embed categories
Browse files Browse the repository at this point in the history
  • Loading branch information
jvyden committed Jun 1, 2024
1 parent 7351db6 commit ee26749
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
9 changes: 7 additions & 2 deletions src/app/pages/level-listing/level-listing.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand All @@ -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();
}
Expand Down Expand Up @@ -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)
}
});
}

Expand Down
5 changes: 5 additions & 0 deletions src/app/services/embed.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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);
}
}

0 comments on commit ee26749

Please sign in to comment.