Compare commits

...

6 Commits

Author SHA1 Message Date
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
3d6a421d25 3.0.8 2020-11-05 17:56:36 +00:00
a7fca4e0c1 fix(core): update 2020-11-05 17:56:35 +00:00
8 changed files with 43 additions and 22 deletions

2
package-lock.json generated
View File

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

View File

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

View File

@ -2,7 +2,7 @@ import * as plugins from '../websetup.plugins';
export interface IMetaObject {
title: string;
description: string;
description?: string;
canonicalDomain?: string;
ldCompany?: plugins.tsclass.business.ICompany;
ldProduct?: any;

View File

@ -71,7 +71,7 @@ export class JsonLdTag extends Tag {
super();
const jsonLdElement = document.createElement('script');
jsonLdElement.type = 'application/ld+json';
jsonLdElement.text = JSON.stringify(JSON.stringify(ldObjectArg));
jsonLdElement.text = JSON.stringify(ldObjectArg);
this.elementRef = jsonLdElement;
}
}

View File

@ -11,7 +11,17 @@ export type TLevelState = 'enabled' | 'disabled';
export class TagLevel {
public tagManagerRef: TagManager;
public title: string;
private titleStore: string;
public set title(titleArg: string) {
this.titleStore = titleArg;
if (this.state === 'enabled') {
document.title = this.titleStore;
}
}
public get title() {
return this.titleStore;
}
public type: TBaseLevelType;
public tags: Tag[] = [];

View File

@ -6,22 +6,22 @@ import { JsonLdTag } from './websetup.classes.tag.jsonldtag';
import { OpengraphTag } from './websetup.classes.tag.opengraphtag';
export class TagManager {
public globalLevel: TagLevel;
public globalLevel: TagLevel = new TagLevel(this, 'global');
public baseLevel: TagLevel;
public baseLevel: TagLevel = new TagLevel(this, 'base');
public activeLevel: TagLevel;
public async setup(metaObjectArg: interfaces.IMetaObject) {
// global tag level
this.globalLevel = new TagLevel(this, 'global');
this.globalLevel.addTag(new MetaTag('google', 'notranslate'));
this.globalLevel.addTag(new MetaTag('revisit-after', '1 days'));
// base tag level
this.baseLevel = new TagLevel(this, 'base');
this.baseLevel.title = metaObjectArg.title;
if (metaObjectArg.description) {
this.baseLevel.addTag(new MetaTag('description', metaObjectArg.description));
}
if (metaObjectArg.canonicalDomain) {
this.baseLevel.addTag(new MetaTag('canonical', metaObjectArg.canonicalDomain));
@ -31,24 +31,27 @@ export class TagManager {
this.baseLevel.addCompanyInfo(metaObjectArg.ldCompany);
}
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');
subPageLevel.title = metaObjectArg.title;
if (metaObjectArg.description) {
subPageLevel.addTag(new MetaTag('description', metaObjectArg.description));
this.activeLevel.disable();
}
await this.activeLevel.disable();
this.activeLevel = subPageLevel;
this.activeLevel.enable();
await this.activeLevel.enable();
return subPageLevel;
}
public revertToBaseLevel() {
public async revertToBaseLevel() {
if (this.activeLevel !== this.baseLevel) {
this.activeLevel.disable();
await this.activeLevel.disable();
this.activeLevel = this.baseLevel;
this.activeLevel.enable();
await this.activeLevel.enable();
}
}
}

View File

@ -25,7 +25,10 @@ export class WebSetup {
/**
* an async setup called by the constructor
*/
private async setup() {
public async setup(optionsArg?: IWebSetupConstructorOptions) {
if (optionsArg) {
this.options = optionsArg;
}
await this.tagManager.setup(this.options.metaObject);
}
@ -40,7 +43,10 @@ export class WebSetup {
* sets a subpage
* @param metaObjectArg
*/
public setSubLevel(metaObjectArg: interfaces.IMetaObject) {
return this.tagManager.setSubPageLevel(metaObjectArg);
public async setSubLevel(metaObjectArg: interfaces.IMetaObject) {
const subLevel = await this.tagManager.setSubPageLevel(metaObjectArg);
return subLevel;
}
public flashTitle(flashTextArg: string) {}
}

View File

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