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

22 lines
880 B
TypeScript
Raw Permalink Normal View History

2020-11-06 01:11:26 +00:00
import * as plugins from './websetup.plugins';
2020-11-04 18:01:04 +00:00
import { Tag } from './websetup.classes.tag';
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;
}
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;
}
}