Skip to content

Commit

Permalink
better text handling for card metadata
Browse files Browse the repository at this point in the history
  • Loading branch information
seiyria committed Jun 19, 2024
1 parent d706f94 commit 5b350f7
Showing 1 changed file with 25 additions and 13 deletions.
38 changes: 25 additions & 13 deletions src/app/card/card.page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -131,19 +131,7 @@ export class CardPage implements OnInit, OnDestroy {

this.cardData.set(cardData);

this.pageMeta.updateTag({ property: 'og:title', content: cardData.name });
this.pageMeta.updateTag({ property: 'og:image', content: cardData.image });
this.pageMeta.updateTag({
property: 'og:description',
content: cardData.text,
});
this.pageMeta.updateTag({
property: 'og:url',
content: `${environment.baseAppUrl}/card/${encodeURIComponent(
cardData.id
)}`,
});
this.pageMeta.updateTag({ name: 'description', content: cardData.text });
this.updateMeta(cardData);

/*
I might like to do something like one of these, but I want to replace the url without doing a nav.
Expand All @@ -168,4 +156,28 @@ export class CardPage implements OnInit, OnDestroy {
searchTag(tag: string) {
this.search(`game:"${this.cardData()?.game}" tag:"${tag}"`);
}

private updateMeta(cardData: ICard) {
const text = cardData.text
? this.removeEmojis(cardData.text)
: 'No text entered for this card.';

this.pageMeta.updateTag({ property: 'og:title', content: cardData.name });
this.pageMeta.updateTag({ property: 'og:image', content: cardData.image });
this.pageMeta.updateTag({
property: 'og:description',
content: text,
});
this.pageMeta.updateTag({
property: 'og:url',
content: `${environment.baseAppUrl}/card/${encodeURIComponent(
cardData.id
)}`,
});
this.pageMeta.updateTag({ name: 'description', content: text });
}

private removeEmojis(text: string) {
return text.split('`').join('').split('symbol:').join('');
}
}

0 comments on commit 5b350f7

Please sign in to comment.