fix(core): update
This commit is contained in:
parent
0294895f78
commit
7fa14ceabd
@ -3,6 +3,7 @@ import * as plugins from '../websetup.plugins';
|
||||
export interface IMetaObject {
|
||||
title: string;
|
||||
description?: string;
|
||||
twitterHandle?: string;
|
||||
canonicalDomain?: string;
|
||||
ldCompany?: plugins.tsclass.business.ICompany;
|
||||
ldProduct?: any;
|
||||
|
@ -35,35 +35,33 @@ export class JsonLdTag extends Tag {
|
||||
return ldTag;
|
||||
}
|
||||
|
||||
public static createNewsArticleLd (newsArticleArg: plugins.tsclass.content.IArticle) {
|
||||
public static createNewsArticleJsonLd(newsArticleArg: plugins.tsclass.content.IArticle) {
|
||||
const newsArticleLd = {
|
||||
"@context": "https://schema.org",
|
||||
"@type": "NewsArticle",
|
||||
"mainEntityOfPage": {
|
||||
"@type": "WebPage",
|
||||
"@id": window.location.href
|
||||
'@context': 'https://schema.org',
|
||||
'@type': 'NewsArticle',
|
||||
mainEntityOfPage: {
|
||||
'@type': 'WebPage',
|
||||
'@id': window.location.href,
|
||||
},
|
||||
"headline": "Article headline",
|
||||
"image": [
|
||||
newsArticleArg.featuredImageUrl
|
||||
],
|
||||
"datePublished": new Date(newsArticleArg.timestamp).toISOString(),
|
||||
"dateModified": new Date(newsArticleArg.timestamp).toISOString(),
|
||||
"author": {
|
||||
"@type": "Person",
|
||||
"name": `${newsArticleArg.author.firstName} ${newsArticleArg.author.surName}`
|
||||
headline: 'Article headline',
|
||||
image: [newsArticleArg.featuredImageUrl],
|
||||
datePublished: new Date(newsArticleArg.timestamp).toISOString(),
|
||||
dateModified: new Date(newsArticleArg.timestamp).toISOString(),
|
||||
author: {
|
||||
'@type': 'Person',
|
||||
name: `${newsArticleArg.author.firstName} ${newsArticleArg.author.surName}`,
|
||||
},
|
||||
"publisher": {
|
||||
"@type": "Organization",
|
||||
"name": newsArticleArg.author.surName, // TODO
|
||||
"logo": {
|
||||
"@type": "ImageObject",
|
||||
"url": newsArticleArg.author.surName // TODO
|
||||
}
|
||||
publisher: {
|
||||
'@type': 'Organization',
|
||||
name: newsArticleArg.author.surName, // TODO
|
||||
logo: {
|
||||
'@type': 'ImageObject',
|
||||
url: newsArticleArg.author.surName, // TODO
|
||||
},
|
||||
},
|
||||
"description": newsArticleArg.author.firstName
|
||||
description: newsArticleArg.author.firstName,
|
||||
};
|
||||
const ldTag = new JsonLdTag(newsArticleArg);
|
||||
const ldTag = new JsonLdTag(newsArticleLd);
|
||||
return ldTag;
|
||||
}
|
||||
|
||||
|
@ -1,6 +1,16 @@
|
||||
import * as plugins from './websetup.plugins';
|
||||
import { Tag } from './websetup.classes.tag';
|
||||
|
||||
export class OpengraphTag extends Tag {
|
||||
public static createNewsArticleOgTags (newsArticleArg: plugins.tsclass.content.IArticle) {
|
||||
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;
|
||||
}
|
||||
|
||||
constructor(propertyNameArg: string, contentArg: string) {
|
||||
super();
|
||||
const openGraphElement = document.createElement('meta');
|
||||
|
@ -31,10 +31,16 @@ export class TagLevel {
|
||||
this.tagManagerRef = tagManagerRefArg;
|
||||
}
|
||||
|
||||
public addTag(tagArg: Tag) {
|
||||
this.tags.push(tagArg);
|
||||
if (this.state === 'enabled') {
|
||||
tagArg.appendToDom();
|
||||
public addTag(tagArg: Tag | Tag[]) {
|
||||
if (tagArg instanceof Array) {
|
||||
for (const tagArg2 of tagArg) {
|
||||
this.addTag(tagArg2);
|
||||
}
|
||||
} else {
|
||||
this.tags.push(tagArg);
|
||||
if (this.state === 'enabled') {
|
||||
tagArg.appendToDom();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -70,7 +76,8 @@ export class TagLevel {
|
||||
}
|
||||
|
||||
public addNewsArticleInfo(articleArg: plugins.tsclass.content.IArticle) {
|
||||
this.addTag(JsonLdTag.createNewsArticleLd(articleArg));
|
||||
this.addTag(JsonLdTag.createNewsArticleJsonLd(articleArg));
|
||||
this.addTag(OpengraphTag.createNewsArticleOgTags(articleArg));
|
||||
}
|
||||
|
||||
public async enable() {
|
||||
|
@ -16,6 +16,12 @@ export class TagManager {
|
||||
// global tag level
|
||||
this.globalLevel.addTag(new MetaTag('google', 'notranslate'));
|
||||
this.globalLevel.addTag(new MetaTag('revisit-after', '1 days'));
|
||||
|
||||
if (metaObjectArg.twitterHandle) {
|
||||
this.globalLevel.addTag(new MetaTag('twitter:card', 'summary_large_image'));
|
||||
this.globalLevel.addTag(new MetaTag('twitter:site', metaObjectArg.twitterHandle));
|
||||
this.globalLevel.addTag(new MetaTag('twitter:creator', metaObjectArg.twitterHandle));
|
||||
}
|
||||
|
||||
// base tag level
|
||||
this.baseLevel.title = metaObjectArg.title;
|
||||
|
Loading…
Reference in New Issue
Block a user