fix(core): update
This commit is contained in:
8
ts/00_commitinfo_data.ts
Normal file
8
ts/00_commitinfo_data.ts
Normal file
@ -0,0 +1,8 @@
|
||||
/**
|
||||
* autocreated commitinfo by @pushrocks/commitinfo
|
||||
*/
|
||||
export const commitinfo = {
|
||||
name: '@pushrocks/websetup',
|
||||
version: '3.0.17',
|
||||
description: 'setup basic page properties'
|
||||
}
|
10
ts/index.ts
10
ts/index.ts
@ -1,5 +1,5 @@
|
||||
export * from './websetup.classes.websetup';
|
||||
export * from './websetup.classes.tag.metatag';
|
||||
export * from './websetup.classes.tag.opengraphtag';
|
||||
export * from './websetup.classes.tag.jsonldtag';
|
||||
export * from './websetup.classes.title';
|
||||
export * from './websetup.classes.websetup.js';
|
||||
export * from './websetup.classes.tag.metatag.js';
|
||||
export * from './websetup.classes.tag.opengraphtag.js';
|
||||
export * from './websetup.classes.tag.jsonldtag.js';
|
||||
export * from './websetup.classes.title.js';
|
||||
|
@ -1,11 +1,10 @@
|
||||
import * as plugins from '../websetup.plugins';
|
||||
|
||||
import * as plugins from '../websetup.plugins.js';
|
||||
export interface IMetaObject {
|
||||
title: string;
|
||||
description?: string;
|
||||
canonicalDomain?: string;
|
||||
ldCompany?: plugins.tsclass.business.ICompany;
|
||||
ldProduct?: any;
|
||||
ldProduct?: plugins.tsclass.saas.IProduct;
|
||||
|
||||
// handles
|
||||
twitterHandle?: string;
|
||||
|
@ -1,10 +1,11 @@
|
||||
import * as plugins from './websetup.plugins';
|
||||
import * as interfaces from './interfaces';
|
||||
import * as plugins from './websetup.plugins.js';
|
||||
import * as interfaces from './interfaces/index.js';
|
||||
|
||||
import { Tag } from './websetup.classes.tag';
|
||||
import { Tag } from './websetup.classes.tag.js';
|
||||
|
||||
export class JsonLdTag extends Tag {
|
||||
public static createCompanyLd(companyDataArg: plugins.tsclass.business.ICompany) {
|
||||
public static createCompanyJsonLd(companyDataArg: plugins.tsclass.business.ICompany) {
|
||||
// STATIC
|
||||
// lets care about linked data
|
||||
const companyLd = {
|
||||
'@context': 'https://schema.org',
|
||||
@ -64,7 +65,37 @@ export class JsonLdTag extends Tag {
|
||||
const ldTag = new JsonLdTag(newsArticleLd);
|
||||
return ldTag;
|
||||
}
|
||||
public static createProductJsonLd(
|
||||
productArg: plugins.tsclass.saas.IProduct,
|
||||
publisherArg: plugins.tsclass.business.ICompany
|
||||
) {
|
||||
const productLd = {
|
||||
'@context': 'https://schema.org',
|
||||
'@type': 'SoftwareApplication',
|
||||
name: productArg.name,
|
||||
description: productArg.description,
|
||||
operatingSystem: productArg.os,
|
||||
applicationCategory: productArg.category,
|
||||
offers: {
|
||||
'@type': 'Offer',
|
||||
name: 'User-based Plan',
|
||||
priceSpecification: {
|
||||
'@type': 'PropertyValueSpecification',
|
||||
valueName: 'Number of Users',
|
||||
valueRequired: true,
|
||||
price: '4.99',
|
||||
priceCurrency: 'EUR',
|
||||
},
|
||||
},
|
||||
publisher: this.createCompanyJsonLd(publisherArg).elementRef.textContent,
|
||||
screenshot: 'https://www.social.io/screenshot.png',
|
||||
url: 'https://www.social.io/',
|
||||
};
|
||||
const ldTag = new JsonLdTag(productLd);
|
||||
return ldTag;
|
||||
}
|
||||
|
||||
// INSTANCE
|
||||
constructor(ldObjectArg: any) {
|
||||
super();
|
||||
const jsonLdElement = document.createElement('script');
|
||||
|
@ -1,4 +1,4 @@
|
||||
import { Tag } from './websetup.classes.tag';
|
||||
import { Tag } from './websetup.classes.tag.js';
|
||||
|
||||
export class LinkTag extends Tag {
|
||||
constructor(relArg: string, hrefArg: string) {
|
||||
|
@ -1,4 +1,4 @@
|
||||
import { Tag } from './websetup.classes.tag';
|
||||
import { Tag } from './websetup.classes.tag.js';
|
||||
|
||||
export class MetaTag extends Tag {
|
||||
constructor(metaNameArg: string, contentArg: string) {
|
||||
|
@ -1,5 +1,5 @@
|
||||
import * as plugins from './websetup.plugins';
|
||||
import { Tag } from './websetup.classes.tag';
|
||||
import * as plugins from './websetup.plugins.js';
|
||||
import { Tag } from './websetup.classes.tag.js';
|
||||
|
||||
export class OpengraphTag extends Tag {
|
||||
public static createNewsArticleOgTags(newsArticleArg: plugins.tsclass.content.IArticle) {
|
||||
|
@ -1,4 +1,4 @@
|
||||
import * as plugins from './websetup.plugins';
|
||||
import * as plugins from './websetup.plugins.js';
|
||||
|
||||
export class Tag {
|
||||
public elementRef: Element;
|
||||
|
@ -1,8 +1,8 @@
|
||||
import { Tag } from './websetup.classes.tag';
|
||||
import { JsonLdTag } from './websetup.classes.tag.jsonldtag';
|
||||
import { OpengraphTag } from './websetup.classes.tag.opengraphtag';
|
||||
import { TagManager } from './websetup.classes.tagmanager';
|
||||
import * as plugins from './websetup.plugins';
|
||||
import { Tag } from './websetup.classes.tag.js';
|
||||
import { JsonLdTag } from './websetup.classes.tag.jsonldtag.js';
|
||||
import { OpengraphTag } from './websetup.classes.tag.opengraphtag.js';
|
||||
import { TagManager } from './websetup.classes.tagmanager.js';
|
||||
import * as plugins from './websetup.plugins.js';
|
||||
|
||||
export type TBaseLevelType = 'global' | 'base' | 'subpage';
|
||||
|
||||
@ -45,7 +45,7 @@ export class TagLevel {
|
||||
}
|
||||
|
||||
public async addCompanyInfo(companyDataArg: plugins.tsclass.business.ICompany) {
|
||||
this.addTag(JsonLdTag.createCompanyLd(companyDataArg));
|
||||
this.addTag(JsonLdTag.createCompanyJsonLd(companyDataArg));
|
||||
|
||||
// lets care about open graph
|
||||
this.addTag(new OpengraphTag('og:type', 'business.business'));
|
||||
@ -80,6 +80,10 @@ export class TagLevel {
|
||||
this.addTag(OpengraphTag.createNewsArticleOgTags(articleArg));
|
||||
}
|
||||
|
||||
public addProductInfo(productArg: plugins.tsclass.saas.IProduct, companyArg: plugins.tsclass.business.ICompany) {
|
||||
this.addTag(JsonLdTag.createProductJsonLd(productArg, companyArg));
|
||||
}
|
||||
|
||||
public async enable() {
|
||||
if (this.title) {
|
||||
document.title = this.title;
|
||||
|
@ -1,9 +1,9 @@
|
||||
import { TagLevel } from './websetup.classes.taglevel';
|
||||
import * as plugins from './websetup.plugins';
|
||||
import * as interfaces from './interfaces';
|
||||
import { MetaTag } from './websetup.classes.tag.metatag';
|
||||
import { JsonLdTag } from './websetup.classes.tag.jsonldtag';
|
||||
import { OpengraphTag } from './websetup.classes.tag.opengraphtag';
|
||||
import { TagLevel } from './websetup.classes.taglevel.js';
|
||||
import * as plugins from './websetup.plugins.js';
|
||||
import * as interfaces from './interfaces/index.js';
|
||||
import { MetaTag } from './websetup.classes.tag.metatag.js';
|
||||
import { JsonLdTag } from './websetup.classes.tag.jsonldtag.js';
|
||||
import { OpengraphTag } from './websetup.classes.tag.opengraphtag.js';
|
||||
|
||||
export class TagManager {
|
||||
public globalLevel: TagLevel = new TagLevel(this, 'global');
|
||||
@ -33,9 +33,17 @@ export class TagManager {
|
||||
this.baseLevel.addTag(new MetaTag('canonical', metaObjectArg.canonicalDomain));
|
||||
}
|
||||
|
||||
if (metaObjectArg.ldCompany) {
|
||||
this.baseLevel.addCompanyInfo(metaObjectArg.ldCompany);
|
||||
|
||||
// json ld
|
||||
switch (true) {
|
||||
case metaObjectArg.ldCompany && !metaObjectArg.ldProduct:
|
||||
this.baseLevel.addCompanyInfo(metaObjectArg.ldCompany);
|
||||
break;
|
||||
case !!metaObjectArg.ldProduct:
|
||||
this.baseLevel.addProductInfo(metaObjectArg.ldProduct, metaObjectArg.ldCompany);
|
||||
break;
|
||||
}
|
||||
|
||||
await this.globalLevel.enable();
|
||||
this.activeLevel = this.baseLevel;
|
||||
await this.activeLevel.enable();
|
||||
|
@ -1,9 +1,7 @@
|
||||
import * as plugins from './websetup.plugins';
|
||||
import * as plugins from './websetup.plugins.js';
|
||||
|
||||
/**
|
||||
* a title proxy class
|
||||
* --> to be used in the future when flashing titles is supported
|
||||
*/
|
||||
export class Title {
|
||||
|
||||
}
|
||||
export class Title {}
|
||||
|
@ -1,7 +1,7 @@
|
||||
import * as plugins from './websetup.plugins';
|
||||
import * as interfaces from './interfaces';
|
||||
import { TagManager } from './websetup.classes.tagmanager';
|
||||
import { TagLevel } from './websetup.classes.taglevel';
|
||||
import * as plugins from './websetup.plugins.js';
|
||||
import * as interfaces from './interfaces/index.js';
|
||||
import { TagManager } from './websetup.classes.tagmanager.js';
|
||||
import { TagLevel } from './websetup.classes.taglevel.js';
|
||||
|
||||
export interface IWebSetupConstructorOptions {
|
||||
metaObject: interfaces.IMetaObject;
|
||||
@ -14,7 +14,7 @@ export interface IWebSetupConstructorOptions {
|
||||
export class WebSetup {
|
||||
public tagManager: TagManager = new TagManager();
|
||||
public options: IWebSetupConstructorOptions;
|
||||
|
||||
|
||||
// private deferreds
|
||||
private readyDeferred = plugins.smartpromise.defer();
|
||||
private readyForSmartssrDeferred = plugins.smartpromise.defer();
|
||||
@ -69,7 +69,9 @@ export class WebSetup {
|
||||
*/
|
||||
public informReadyForSmartssr() {
|
||||
if (!this.options.smartssrWaitForReadySignal) {
|
||||
console.error(`You have not indicated that you inform smartssr by a dedicated signal! Please consider doing so!`);
|
||||
console.error(
|
||||
`You have not indicated that you inform smartssr by a dedicated signal! Please consider doing so!`
|
||||
);
|
||||
}
|
||||
this.readyForSmartssrDeferred.resolve();
|
||||
}
|
||||
|
Reference in New Issue
Block a user