websetup/ts/websetup.classes.tag.opengraphtag.ts

44 lines
2.0 KiB
TypeScript
Raw Normal View History

2023-05-07 18:24:53 +00:00
import * as plugins from './websetup.plugins.js';
import { Tag } from './websetup.classes.tag.js';
2020-11-04 18:01:04 +00:00
export class OpengraphTag extends Tag {
2020-12-07 05:06:30 +00:00
public static createNewsArticleOgTags(newsArticleArg: plugins.tsclass.content.IArticle) {
2020-11-06 01:11:26 +00:00
const tagArray: OpengraphTag[] = [];
tagArray.push(new OpengraphTag('og:url', newsArticleArg.url));
tagArray.push(new OpengraphTag('og:title', newsArticleArg.title));
tagArray.push(new OpengraphTag('og:description', newsArticleArg.content));
tagArray.push(new OpengraphTag('og:image', newsArticleArg.featuredImageUrl));
return tagArray;
}
2023-05-08 08:07:33 +00:00
public static createProductOgTags(productArg: plugins.tsclass.saas.IProduct) {
const tagArray: OpengraphTag[] = [];
2024-03-30 20:49:21 +00:00
tagArray.push(new OpengraphTag('og:type', 'product'));
2023-05-08 08:07:33 +00:00
tagArray.push(new OpengraphTag('og:url', globalThis.location.href));
2023-05-08 13:22:27 +00:00
tagArray.push(new OpengraphTag('og:title', `${productArg.name} - ${productArg.slogan}`));
2023-05-08 08:07:33 +00:00
tagArray.push(new OpengraphTag('og:site_name', productArg.name))
tagArray.push(new OpengraphTag('og:description', productArg.description));
tagArray.push(new OpengraphTag('og:image', productArg.logoLink));
return tagArray;
}
2024-03-30 20:49:21 +00:00
public static createCompanyOgTags(companyArg: plugins.tsclass.business.ICompany) {
const tagArray: OpengraphTag[] = [];
tagArray.push(new OpengraphTag('og:type', 'company'));
tagArray.push(new OpengraphTag('og:url', globalThis.location.href));
tagArray.push(new OpengraphTag('og:title', `${companyArg.name} - ${companyArg.slogan}`));
tagArray.push(new OpengraphTag('og:site_name', companyArg.name))
tagArray.push(new OpengraphTag('og:description', companyArg.description));
tagArray.push(new OpengraphTag('og:image', companyArg.logoLink));
return tagArray;
}
2020-11-04 18:01:04 +00:00
constructor(propertyNameArg: string, contentArg: string) {
super();
const openGraphElement = document.createElement('meta');
openGraphElement.setAttribute('property', propertyNameArg);
openGraphElement.content = contentArg;
this.elementRef = openGraphElement;
}
}