updated discord components v2 embed/meta tags
This commit is contained in:
1 parent
e20d4b45b6
commit
921659a2c2
2 files changed
+21
-4
No files matched your search
Binary file not shown.
|
After Width: | Height: | Size: 14 KiB |
@@ -14,7 +14,7 @@ export interface DiscordButton {
|
|||||||
|
|
||||||
export class SeoService {
|
export class SeoService {
|
||||||
private readonly rootDomain = 'https://itzminey.dev';
|
private readonly rootDomain = 'https://itzminey.dev';
|
||||||
private readonly defaultImage = 'https://meta.itzminey.dev/assets/ogimg.png';
|
private readonly defaultImage = 'https://itzminey.dev/assets/ogimg.png';
|
||||||
private readonly siteColor = '#0095a4';
|
private readonly siteColor = '#0095a4';
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
@@ -45,10 +45,10 @@ export class SeoService {
|
|||||||
this.metaService.updateTag({ property: 'og:url', content: currentUrl });
|
this.metaService.updateTag({ property: 'og:url', content: currentUrl });
|
||||||
this.metaService.updateTag({ name: 'theme-color', content: this.siteColor });
|
this.metaService.updateTag({ name: 'theme-color', content: this.siteColor });
|
||||||
|
|
||||||
this.injectDiscordButtons(config.buttons);
|
this.injectDiscordComponentEmbed(config.buttons, { title, description, image, currentUrl });
|
||||||
}
|
}
|
||||||
|
|
||||||
private injectDiscordButtons( buttons?: DiscordButton[] ) {
|
private injectDiscordComponentEmbed(buttons?: DiscordButton[], meta?: { title: string; description: string; image: string; currentUrl: string }) {
|
||||||
const existingScript = this.document.getElementById('discord:component-embed');
|
const existingScript = this.document.getElementById('discord:component-embed');
|
||||||
if (existingScript) {
|
if (existingScript) {
|
||||||
existingScript.remove();
|
existingScript.remove();
|
||||||
@@ -57,11 +57,28 @@ export class SeoService {
|
|||||||
if (!buttons || buttons.length === 0) return;
|
if (!buttons || buttons.length === 0) return;
|
||||||
|
|
||||||
const componentPayload = {
|
const componentPayload = {
|
||||||
|
flags: 32768,
|
||||||
component: {
|
component: {
|
||||||
type: 17,
|
type: 17,
|
||||||
|
accent_color: parseInt(this.siteColor.replace('#', ''), 16),
|
||||||
components: [
|
components: [
|
||||||
{
|
{
|
||||||
type: 1,
|
type: 9,
|
||||||
|
components: [
|
||||||
|
{
|
||||||
|
type: 10,
|
||||||
|
content: `### [${meta?.title ?? ''}](${meta?.currentUrl ?? ''})\n${meta?.description ?? ''}`
|
||||||
|
}
|
||||||
|
],
|
||||||
|
accessory: {
|
||||||
|
type: 11,
|
||||||
|
media: {
|
||||||
|
url: 'https://itzminey.dev/assets/thumb.png'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
type: 1, // Action Row for buttons
|
||||||
components: buttons.map(btn => ({
|
components: buttons.map(btn => ({
|
||||||
type: 2,
|
type: 2,
|
||||||
label: btn.label,
|
label: btn.label,
|
||||||
|
|||||||
Reference in new issue
Block a user