Compare commits

..

8 Commits

Author SHA1 Message Date
9175cb7841 3.0.12 2020-12-07 05:06:31 +00:00
6b9ebcec7a fix(core): update 2020-12-07 05:06:30 +00:00
2159995342 3.0.11 2020-11-06 01:11:26 +00:00
7fa14ceabd fix(core): update 2020-11-06 01:11:26 +00:00
0294895f78 3.0.10 2020-11-05 20:03:13 +00:00
74fc97a220 fix(core): update 2020-11-05 20:03:12 +00:00
bab9124ad9 3.0.9 2020-11-05 18:36:09 +00:00
fda71ac3e6 fix(core): update 2020-11-05 18:36:08 +00:00
9 changed files with 81 additions and 43 deletions

2
package-lock.json generated
View File

@ -1,6 +1,6 @@
{ {
"name": "@pushrocks/websetup", "name": "@pushrocks/websetup",
"version": "3.0.8", "version": "3.0.12",
"lockfileVersion": 1, "lockfileVersion": 1,
"requires": true, "requires": true,
"dependencies": { "dependencies": {

View File

@ -1,6 +1,6 @@
{ {
"name": "@pushrocks/websetup", "name": "@pushrocks/websetup",
"version": "3.0.8", "version": "3.0.12",
"private": false, "private": false,
"description": "setup basic page properties", "description": "setup basic page properties",
"main": "dist_ts/index.js", "main": "dist_ts/index.js",
@ -24,6 +24,7 @@
"tslint-config-prettier": "^1.15.0" "tslint-config-prettier": "^1.15.0"
}, },
"dependencies": { "dependencies": {
"@pushrocks/smartdelay": "^2.0.10",
"@pushrocks/smartpromise": "^3.1.3", "@pushrocks/smartpromise": "^3.1.3",
"@tsclass/tsclass": "^3.0.29" "@tsclass/tsclass": "^3.0.29"
}, },

View File

@ -6,4 +6,15 @@ export interface IMetaObject {
canonicalDomain?: string; canonicalDomain?: string;
ldCompany?: plugins.tsclass.business.ICompany; ldCompany?: plugins.tsclass.business.ICompany;
ldProduct?: any; ldProduct?: any;
// handles
twitterHandle?: string;
facebookhandle?: string;
// links
companyWebsiteLink?: string;
googleNewsLink?: string;
mediumLink?: string;
slackLink?: string;
airmeetLink?: string;
} }

View File

@ -35,35 +35,33 @@ export class JsonLdTag extends Tag {
return ldTag; return ldTag;
} }
public static createNewsArticleLd (newsArticleArg: plugins.tsclass.content.IArticle) { public static createNewsArticleJsonLd(newsArticleArg: plugins.tsclass.content.IArticle) {
const newsArticleLd = { const newsArticleLd = {
"@context": "https://schema.org", '@context': 'https://schema.org',
"@type": "NewsArticle", '@type': 'NewsArticle',
"mainEntityOfPage": { mainEntityOfPage: {
"@type": "WebPage", '@type': 'WebPage',
"@id": window.location.href '@id': window.location.href,
}, },
"headline": "Article headline", headline: 'Article headline',
"image": [ image: [newsArticleArg.featuredImageUrl],
newsArticleArg.featuredImageUrl datePublished: new Date(newsArticleArg.timestamp).toISOString(),
], dateModified: new Date(newsArticleArg.timestamp).toISOString(),
"datePublished": new Date(newsArticleArg.timestamp).toISOString(), author: {
"dateModified": new Date(newsArticleArg.timestamp).toISOString(), '@type': 'Person',
"author": { name: `${newsArticleArg.author.firstName} ${newsArticleArg.author.surName}`,
"@type": "Person",
"name": `${newsArticleArg.author.firstName} ${newsArticleArg.author.surName}`
}, },
"publisher": { publisher: {
"@type": "Organization", '@type': 'Organization',
"name": newsArticleArg.author.surName, // TODO name: newsArticleArg.author.surName, // TODO
"logo": { logo: {
"@type": "ImageObject", '@type': 'ImageObject',
"url": newsArticleArg.author.surName // TODO 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; return ldTag;
} }
@ -71,7 +69,7 @@ export class JsonLdTag extends Tag {
super(); super();
const jsonLdElement = document.createElement('script'); const jsonLdElement = document.createElement('script');
jsonLdElement.type = 'application/ld+json'; jsonLdElement.type = 'application/ld+json';
jsonLdElement.text = JSON.stringify(JSON.stringify(ldObjectArg)); jsonLdElement.text = JSON.stringify(ldObjectArg);
this.elementRef = jsonLdElement; this.elementRef = jsonLdElement;
} }
} }

View File

@ -1,6 +1,16 @@
import * as plugins from './websetup.plugins';
import { Tag } from './websetup.classes.tag'; import { Tag } from './websetup.classes.tag';
export class OpengraphTag extends 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) { constructor(propertyNameArg: string, contentArg: string) {
super(); super();
const openGraphElement = document.createElement('meta'); const openGraphElement = document.createElement('meta');

View File

@ -31,12 +31,18 @@ export class TagLevel {
this.tagManagerRef = tagManagerRefArg; this.tagManagerRef = tagManagerRefArg;
} }
public addTag(tagArg: Tag) { public addTag(tagArg: Tag | Tag[]) {
if (tagArg instanceof Array) {
for (const tagArg2 of tagArg) {
this.addTag(tagArg2);
}
} else {
this.tags.push(tagArg); this.tags.push(tagArg);
if (this.state === 'enabled') { if (this.state === 'enabled') {
tagArg.appendToDom(); tagArg.appendToDom();
} }
} }
}
public async addCompanyInfo(companyDataArg: plugins.tsclass.business.ICompany) { public async addCompanyInfo(companyDataArg: plugins.tsclass.business.ICompany) {
this.addTag(JsonLdTag.createCompanyLd(companyDataArg)); this.addTag(JsonLdTag.createCompanyLd(companyDataArg));
@ -70,7 +76,8 @@ export class TagLevel {
} }
public addNewsArticleInfo(articleArg: plugins.tsclass.content.IArticle) { 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() { public async enable() {

View File

@ -17,6 +17,12 @@ export class TagManager {
this.globalLevel.addTag(new MetaTag('google', 'notranslate')); this.globalLevel.addTag(new MetaTag('google', 'notranslate'));
this.globalLevel.addTag(new MetaTag('revisit-after', '1 days')); 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 // base tag level
this.baseLevel.title = metaObjectArg.title; this.baseLevel.title = metaObjectArg.title;
if (metaObjectArg.description) { if (metaObjectArg.description) {
@ -31,26 +37,27 @@ export class TagManager {
this.baseLevel.addCompanyInfo(metaObjectArg.ldCompany); this.baseLevel.addCompanyInfo(metaObjectArg.ldCompany);
} }
await this.globalLevel.enable(); await this.globalLevel.enable();
await this.baseLevel.enable(); this.activeLevel = this.baseLevel;
await this.activeLevel.enable();
} }
public setSubPageLevel(metaObjectArg: interfaces.IMetaObject) { public async setSubPageLevel(metaObjectArg: interfaces.IMetaObject) {
const subPageLevel = new TagLevel(this, 'subpage'); const subPageLevel = new TagLevel(this, 'subpage');
subPageLevel.title = metaObjectArg.title; subPageLevel.title = metaObjectArg.title;
if (metaObjectArg.description) { if (metaObjectArg.description) {
this.baseLevel.addTag(new MetaTag('description', metaObjectArg.description)); subPageLevel.addTag(new MetaTag('description', metaObjectArg.description));
} }
this.activeLevel.disable(); await this.activeLevel.disable();
this.activeLevel = subPageLevel; this.activeLevel = subPageLevel;
this.activeLevel.enable(); await this.activeLevel.enable();
return subPageLevel; return subPageLevel;
} }
public revertToBaseLevel() { public async revertToBaseLevel() {
if (this.activeLevel !== this.baseLevel) { if (this.activeLevel !== this.baseLevel) {
this.activeLevel.disable(); await this.activeLevel.disable();
this.activeLevel = this.baseLevel; this.activeLevel = this.baseLevel;
this.activeLevel.enable(); await this.activeLevel.enable();
} }
} }
} }

View File

@ -43,7 +43,10 @@ export class WebSetup {
* sets a subpage * sets a subpage
* @param metaObjectArg * @param metaObjectArg
*/ */
public setSubLevel(metaObjectArg: interfaces.IMetaObject) { public async setSubLevel(metaObjectArg: interfaces.IMetaObject) {
return this.tagManager.setSubPageLevel(metaObjectArg); const subLevel = await this.tagManager.setSubPageLevel(metaObjectArg);
return subLevel;
} }
public flashTitle(flashTextArg: string) {}
} }

View File

@ -1,7 +1,8 @@
// pushrocks scope // pushrocks scope
import * as smartdelay from '@pushrocks/smartdelay';
import * as smartpromise from '@pushrocks/smartpromise'; import * as smartpromise from '@pushrocks/smartpromise';
export { smartpromise }; export { smartdelay, smartpromise };
// tsclass scope // tsclass scope
import * as tsclass from '@tsclass/tsclass'; import * as tsclass from '@tsclass/tsclass';