make seo helper service buttons optional and reuse components v2 script builder for meta on every page
This commit is contained in:
1 parent
921659a2c2
commit
8976d56495
1 file changed
+30
-27
@@ -54,39 +54,42 @@ export class SeoService {
|
|||||||
existingScript.remove();
|
existingScript.remove();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!buttons || buttons.length === 0) return;
|
const sectionComponent = {
|
||||||
|
type: 9,
|
||||||
|
components: [
|
||||||
|
{
|
||||||
|
type: 10,
|
||||||
|
content: `### [${meta?.title ?? ''}](${meta?.currentUrl ?? ''})\n${meta?.description ?? ''}`
|
||||||
|
}
|
||||||
|
],
|
||||||
|
accessory: {
|
||||||
|
type: 11,
|
||||||
|
media: {
|
||||||
|
url: 'https://itzminey.dev/assets/thumb.png'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
const containerComponents: any[] = [sectionComponent];
|
||||||
|
|
||||||
|
if (buttons && buttons.length > 0) {
|
||||||
|
containerComponents.push({
|
||||||
|
type: 1,
|
||||||
|
components: buttons.map(btn => ({
|
||||||
|
type: 2,
|
||||||
|
label: btn.label,
|
||||||
|
style: 5,
|
||||||
|
url: btn.url
|
||||||
|
}))
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
const componentPayload = {
|
const componentPayload = {
|
||||||
flags: 32768,
|
flags: 32768,
|
||||||
component: {
|
component: {
|
||||||
type: 17,
|
type: 17,
|
||||||
accent_color: parseInt(this.siteColor.replace('#', ''), 16),
|
accent_color: parseInt(this.siteColor.replace('#', ''), 16),
|
||||||
components: [
|
components: containerComponents
|
||||||
{
|
|
||||||
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 => ({
|
|
||||||
type: 2,
|
|
||||||
label: btn.label,
|
|
||||||
style: 5,
|
|
||||||
url: btn.url
|
|
||||||
}))
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user