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

32 lines
1.4 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[] = [];
tagArray.push(new OpengraphTag('og:url', globalThis.location.href));
tagArray.push(new OpengraphTag('og:title', productArg.name));
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;
}
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;
}
}