fix(core): update
This commit is contained in:
parent
782c9cd740
commit
a7fca4e0c1
@ -2,7 +2,7 @@ import * as plugins from '../websetup.plugins';
|
|||||||
|
|
||||||
export interface IMetaObject {
|
export interface IMetaObject {
|
||||||
title: string;
|
title: string;
|
||||||
description: string;
|
description?: string;
|
||||||
canonicalDomain?: string;
|
canonicalDomain?: string;
|
||||||
ldCompany?: plugins.tsclass.business.ICompany;
|
ldCompany?: plugins.tsclass.business.ICompany;
|
||||||
ldProduct?: any;
|
ldProduct?: any;
|
||||||
|
@ -11,7 +11,17 @@ export type TLevelState = 'enabled' | 'disabled';
|
|||||||
export class TagLevel {
|
export class TagLevel {
|
||||||
public tagManagerRef: TagManager;
|
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 type: TBaseLevelType;
|
||||||
public tags: Tag[] = [];
|
public tags: Tag[] = [];
|
||||||
|
|
||||||
|
@ -6,22 +6,22 @@ import { JsonLdTag } from './websetup.classes.tag.jsonldtag';
|
|||||||
import { OpengraphTag } from './websetup.classes.tag.opengraphtag';
|
import { OpengraphTag } from './websetup.classes.tag.opengraphtag';
|
||||||
|
|
||||||
export class TagManager {
|
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 activeLevel: TagLevel;
|
||||||
|
|
||||||
public async setup(metaObjectArg: interfaces.IMetaObject) {
|
public async setup(metaObjectArg: interfaces.IMetaObject) {
|
||||||
// global tag level
|
// global tag level
|
||||||
this.globalLevel = new TagLevel(this, 'global');
|
|
||||||
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'));
|
||||||
|
|
||||||
// base tag level
|
// base tag level
|
||||||
this.baseLevel = new TagLevel(this, 'base');
|
|
||||||
this.baseLevel.title = metaObjectArg.title;
|
this.baseLevel.title = metaObjectArg.title;
|
||||||
this.baseLevel.addTag(new MetaTag('description', metaObjectArg.description));
|
if (metaObjectArg.description) {
|
||||||
|
this.baseLevel.addTag(new MetaTag('description', metaObjectArg.description));
|
||||||
|
}
|
||||||
|
|
||||||
if (metaObjectArg.canonicalDomain) {
|
if (metaObjectArg.canonicalDomain) {
|
||||||
this.baseLevel.addTag(new MetaTag('canonical', metaObjectArg.canonicalDomain));
|
this.baseLevel.addTag(new MetaTag('canonical', metaObjectArg.canonicalDomain));
|
||||||
@ -37,7 +37,9 @@ export class TagManager {
|
|||||||
public setSubPageLevel(metaObjectArg: interfaces.IMetaObject) {
|
public setSubPageLevel(metaObjectArg: interfaces.IMetaObject) {
|
||||||
const subPageLevel = new TagLevel(this, 'subpage');
|
const subPageLevel = new TagLevel(this, 'subpage');
|
||||||
subPageLevel.title = metaObjectArg.title;
|
subPageLevel.title = metaObjectArg.title;
|
||||||
subPageLevel.addTag(new MetaTag('description', metaObjectArg.description));
|
if (metaObjectArg.description) {
|
||||||
|
this.baseLevel.addTag(new MetaTag('description', metaObjectArg.description));
|
||||||
|
}
|
||||||
this.activeLevel.disable();
|
this.activeLevel.disable();
|
||||||
this.activeLevel = subPageLevel;
|
this.activeLevel = subPageLevel;
|
||||||
this.activeLevel.enable();
|
this.activeLevel.enable();
|
||||||
|
@ -25,7 +25,10 @@ export class WebSetup {
|
|||||||
/**
|
/**
|
||||||
* an async setup called by the constructor
|
* 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);
|
await this.tagManager.setup(this.options.metaObject);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user