Compare commits
36 Commits
Author | SHA1 | Date | |
---|---|---|---|
6acfddb70d | |||
c34d71238a | |||
2f4fd839a1 | |||
bd8585aa42 | |||
e4f8e53066 | |||
d381f8adad | |||
d1c0501461 | |||
f5d33bdebe | |||
2b9c9225a5 | |||
5ce55190fe | |||
8fb071f57b | |||
3278ef7425 | |||
11282daa38 | |||
1fe7dd8d06 | |||
9175cb7841 | |||
6b9ebcec7a | |||
2159995342 | |||
7fa14ceabd | |||
0294895f78 | |||
74fc97a220 | |||
bab9124ad9 | |||
fda71ac3e6 | |||
3d6a421d25 | |||
a7fca4e0c1 | |||
782c9cd740 | |||
b8ab19a683 | |||
e47869caed | |||
4f06c5d7c5 | |||
c0d223959d | |||
c40c01b5c8 | |||
57868de491 | |||
ccd68a1257 | |||
c1f82be85f | |||
ca3398c4fd | |||
0884b61099 | |||
db8ea28cee |
@ -12,30 +12,38 @@ stages:
|
|||||||
- release
|
- release
|
||||||
- metadata
|
- metadata
|
||||||
|
|
||||||
|
before_script:
|
||||||
|
- pnpm install -g pnpm
|
||||||
|
- pnpm install -g @shipzone/npmci
|
||||||
|
- npmci npm prepare
|
||||||
|
|
||||||
# ====================
|
# ====================
|
||||||
# security stage
|
# security stage
|
||||||
# ====================
|
# ====================
|
||||||
mirror:
|
# ====================
|
||||||
stage: security
|
# security stage
|
||||||
script:
|
# ====================
|
||||||
- npmci git mirror
|
auditProductionDependencies:
|
||||||
tags:
|
|
||||||
- lossless
|
|
||||||
- docker
|
|
||||||
- notpriv
|
|
||||||
|
|
||||||
audit:
|
|
||||||
image: registry.gitlab.com/hosttoday/ht-docker-node:npmci
|
image: registry.gitlab.com/hosttoday/ht-docker-node:npmci
|
||||||
stage: security
|
stage: security
|
||||||
script:
|
script:
|
||||||
- npmci npm prepare
|
- npmci command npm config set registry https://registry.npmjs.org
|
||||||
- npmci command npm install --ignore-scripts
|
- npmci command pnpm audit --audit-level=high --prod
|
||||||
- npmci command npm config set registry https://registry.npmjs.org
|
|
||||||
- npmci command npm audit --audit-level=high
|
|
||||||
tags:
|
tags:
|
||||||
- lossless
|
- lossless
|
||||||
- docker
|
- docker
|
||||||
- notpriv
|
allow_failure: true
|
||||||
|
|
||||||
|
auditDevDependencies:
|
||||||
|
image: registry.gitlab.com/hosttoday/ht-docker-node:npmci
|
||||||
|
stage: security
|
||||||
|
script:
|
||||||
|
- npmci command npm config set registry https://registry.npmjs.org
|
||||||
|
- npmci command pnpm audit --audit-level=high --dev
|
||||||
|
tags:
|
||||||
|
- lossless
|
||||||
|
- docker
|
||||||
|
allow_failure: true
|
||||||
|
|
||||||
# ====================
|
# ====================
|
||||||
# test stage
|
# test stage
|
||||||
@ -44,28 +52,22 @@ audit:
|
|||||||
testStable:
|
testStable:
|
||||||
stage: test
|
stage: test
|
||||||
script:
|
script:
|
||||||
- npmci npm prepare
|
|
||||||
- npmci node install stable
|
- npmci node install stable
|
||||||
- npmci npm install
|
- npmci npm install
|
||||||
- npmci npm test
|
- npmci npm test
|
||||||
coverage: /\d+.?\d+?\%\s*coverage/
|
coverage: /\d+.?\d+?\%\s*coverage/
|
||||||
tags:
|
tags:
|
||||||
- lossless
|
|
||||||
- docker
|
- docker
|
||||||
- priv
|
|
||||||
|
|
||||||
testBuild:
|
testBuild:
|
||||||
stage: test
|
stage: test
|
||||||
script:
|
script:
|
||||||
- npmci npm prepare
|
|
||||||
- npmci node install stable
|
- npmci node install stable
|
||||||
- npmci npm install
|
- npmci npm install
|
||||||
- npmci command npm run build
|
- npmci npm build
|
||||||
coverage: /\d+.?\d+?\%\s*coverage/
|
coverage: /\d+.?\d+?\%\s*coverage/
|
||||||
tags:
|
tags:
|
||||||
- lossless
|
|
||||||
- docker
|
- docker
|
||||||
- notpriv
|
|
||||||
|
|
||||||
release:
|
release:
|
||||||
stage: release
|
stage: release
|
||||||
@ -85,11 +87,12 @@ release:
|
|||||||
codequality:
|
codequality:
|
||||||
stage: metadata
|
stage: metadata
|
||||||
allow_failure: true
|
allow_failure: true
|
||||||
|
only:
|
||||||
|
- tags
|
||||||
script:
|
script:
|
||||||
- npmci command npm install -g tslint typescript
|
- npmci command npm install -g typescript
|
||||||
- npmci npm prepare
|
- npmci npm prepare
|
||||||
- npmci npm install
|
- npmci npm install
|
||||||
- npmci command "tslint -c tslint.json ./ts/**/*.ts"
|
|
||||||
tags:
|
tags:
|
||||||
- lossless
|
- lossless
|
||||||
- docker
|
- docker
|
||||||
@ -109,11 +112,9 @@ trigger:
|
|||||||
pages:
|
pages:
|
||||||
stage: metadata
|
stage: metadata
|
||||||
script:
|
script:
|
||||||
- npmci node install lts
|
- npmci node install stable
|
||||||
- npmci command npm install -g @gitzone/tsdoc
|
|
||||||
- npmci npm prepare
|
|
||||||
- npmci npm install
|
- npmci npm install
|
||||||
- npmci command tsdoc
|
- npmci command npm run buildDocs
|
||||||
tags:
|
tags:
|
||||||
- lossless
|
- lossless
|
||||||
- docker
|
- docker
|
||||||
|
24
.vscode/launch.json
vendored
24
.vscode/launch.json
vendored
@ -2,28 +2,10 @@
|
|||||||
"version": "0.2.0",
|
"version": "0.2.0",
|
||||||
"configurations": [
|
"configurations": [
|
||||||
{
|
{
|
||||||
"name": "current file",
|
"command": "npm test",
|
||||||
"type": "node",
|
"name": "Run npm test",
|
||||||
"request": "launch",
|
"request": "launch",
|
||||||
"args": [
|
"type": "node-terminal"
|
||||||
"${relativeFile}"
|
|
||||||
],
|
|
||||||
"runtimeArgs": ["-r", "@gitzone/tsrun"],
|
|
||||||
"cwd": "${workspaceRoot}",
|
|
||||||
"protocol": "inspector",
|
|
||||||
"internalConsoleOptions": "openOnSessionStart"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "test.ts",
|
|
||||||
"type": "node",
|
|
||||||
"request": "launch",
|
|
||||||
"args": [
|
|
||||||
"test/test.ts"
|
|
||||||
],
|
|
||||||
"runtimeArgs": ["-r", "@gitzone/tsrun"],
|
|
||||||
"cwd": "${workspaceRoot}",
|
|
||||||
"protocol": "inspector",
|
|
||||||
"internalConsoleOptions": "openOnSessionStart"
|
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
2
.vscode/settings.json
vendored
2
.vscode/settings.json
vendored
@ -15,7 +15,7 @@
|
|||||||
"properties": {
|
"properties": {
|
||||||
"projectType": {
|
"projectType": {
|
||||||
"type": "string",
|
"type": "string",
|
||||||
"enum": ["website", "element", "service", "npm"]
|
"enum": ["website", "element", "service", "npm", "wcc"]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -9,7 +9,7 @@
|
|||||||
"githost": "gitlab.com",
|
"githost": "gitlab.com",
|
||||||
"gitscope": "pushrocks",
|
"gitscope": "pushrocks",
|
||||||
"gitrepo": "websetup",
|
"gitrepo": "websetup",
|
||||||
"shortDescription": "setup basic page properties",
|
"description": "setup basic page properties",
|
||||||
"npmPackagename": "@pushrocks/websetup",
|
"npmPackagename": "@pushrocks/websetup",
|
||||||
"license": "MIT"
|
"license": "MIT"
|
||||||
}
|
}
|
||||||
|
11474
package-lock.json
generated
11474
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
23
package.json
23
package.json
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@pushrocks/websetup",
|
"name": "@pushrocks/websetup",
|
||||||
"version": "3.0.1",
|
"version": "3.0.19",
|
||||||
"private": false,
|
"private": false,
|
||||||
"description": "setup basic page properties",
|
"description": "setup basic page properties",
|
||||||
"main": "dist_ts/index.js",
|
"main": "dist_ts/index.js",
|
||||||
@ -9,23 +9,23 @@
|
|||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"test": "(tstest test/)",
|
"test": "(tstest test/)",
|
||||||
"build": "(tsbuild --web && tsbundle npm)"
|
"build": "(tsbuild --web --allowimplicitany && tsbundle npm)",
|
||||||
|
"buildDocs": "tsdoc"
|
||||||
},
|
},
|
||||||
"keywords": [
|
"keywords": [
|
||||||
"lossless",
|
"lossless",
|
||||||
"websafe"
|
"websafe"
|
||||||
],
|
],
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@gitzone/tsbuild": "^2.1.25",
|
"@gitzone/tsbuild": "^2.1.65",
|
||||||
"@gitzone/tsbundle": "^1.0.78",
|
"@gitzone/tsbundle": "^2.0.7",
|
||||||
"@gitzone/tstest": "^1.0.52",
|
"@gitzone/tstest": "^1.0.74",
|
||||||
"@pushrocks/tapbundle": "^3.2.9",
|
"@pushrocks/tapbundle": "^5.0.4"
|
||||||
"tslint": "^6.1.3",
|
|
||||||
"tslint-config-prettier": "^1.15.0"
|
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@pushrocks/smartpromise": "^3.1.3",
|
"@pushrocks/smartdelay": "^3.0.1",
|
||||||
"@tsclass/tsclass": "^3.0.29"
|
"@pushrocks/smartpromise": "^4.0.2",
|
||||||
|
"@tsclass/tsclass": "^4.0.41"
|
||||||
},
|
},
|
||||||
"files": [
|
"files": [
|
||||||
"ts/**/*",
|
"ts/**/*",
|
||||||
@ -41,5 +41,6 @@
|
|||||||
],
|
],
|
||||||
"browserslist": [
|
"browserslist": [
|
||||||
"last 1 chrome versions"
|
"last 1 chrome versions"
|
||||||
]
|
],
|
||||||
|
"type": "module"
|
||||||
}
|
}
|
||||||
|
4481
pnpm-lock.yaml
generated
Normal file
4481
pnpm-lock.yaml
generated
Normal file
File diff suppressed because it is too large
Load Diff
@ -21,7 +21,6 @@ Code Style | [](htt
|
|||||||
PackagePhobia (total standalone install weight) | [](https://lossless.cloud)
|
PackagePhobia (total standalone install weight) | [](https://lossless.cloud)
|
||||||
PackagePhobia (package size on registry) | [](https://lossless.cloud)
|
PackagePhobia (package size on registry) | [](https://lossless.cloud)
|
||||||
BundlePhobia (total size when bundled) | [](https://lossless.cloud)
|
BundlePhobia (total size when bundled) | [](https://lossless.cloud)
|
||||||
Platform support | [](https://lossless.cloud) [](https://lossless.cloud)
|
|
||||||
|
|
||||||
## Usage
|
## Usage
|
||||||
|
|
||||||
@ -33,7 +32,6 @@ We are always happy for code contributions. If you are not the code contributing
|
|||||||
|
|
||||||
For further information read the linked docs at the top of this readme.
|
For further information read the linked docs at the top of this readme.
|
||||||
|
|
||||||
> MIT licensed | **©** [Lossless GmbH](https://lossless.gmbh)
|
## Legal
|
||||||
|
> MIT licensed | **©** [Task Venture Capital GmbH](https://task.vc)
|
||||||
| By using this npm module you agree to our [privacy policy](https://lossless.gmbH/privacy)
|
| By using this npm module you agree to our [privacy policy](https://lossless.gmbH/privacy)
|
||||||
|
|
||||||
[](https://maintainedby.lossless.com)
|
|
||||||
|
@ -1,16 +1,18 @@
|
|||||||
import { expect, tap } from '@pushrocks/tapbundle';
|
import { expect, tap, webhelpers } from '@pushrocks/tapbundle';
|
||||||
import * as websetup from '../ts/index';
|
webhelpers.enable();
|
||||||
|
|
||||||
|
import * as websetup from '../ts/index.js';
|
||||||
|
|
||||||
tap.test('first test', async () => {
|
tap.test('first test', async () => {
|
||||||
const websetupInstance = new websetup.WebSetup({
|
const websetupInstance = new websetup.WebSetup({
|
||||||
metaObject: {
|
metaObject: {
|
||||||
description: 'A awesome description',
|
description: 'A awesome description',
|
||||||
title: 'mytitle',
|
title: 'mytitle',
|
||||||
canonicalDomain: 'lossless.com'
|
canonicalDomain: 'lossless.com',
|
||||||
}
|
},
|
||||||
});
|
});
|
||||||
await websetupInstance.setup();
|
await websetupInstance.readyPromise;
|
||||||
expect(document.title).to.equal('mytitle');
|
expect(document.title).toEqual('mytitle');
|
||||||
});
|
});
|
||||||
|
|
||||||
tap.start();
|
tap.start();
|
||||||
|
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.19',
|
||||||
|
description: 'setup basic page properties'
|
||||||
|
}
|
@ -1,4 +1,5 @@
|
|||||||
export * from './websetup.classes.websetup';
|
export * from './websetup.classes.websetup.js';
|
||||||
export * from './websetup.classes.tag.metatag';
|
export * from './websetup.classes.tag.metatag.js';
|
||||||
export * from './websetup.classes.tag.opengraphtag';
|
export * from './websetup.classes.tag.opengraphtag.js';
|
||||||
export * from './websetup.classes.tag.jsonldtag';
|
export * from './websetup.classes.tag.jsonldtag.js';
|
||||||
|
export * from './websetup.classes.title.js';
|
||||||
|
@ -1,9 +1,19 @@
|
|||||||
import * as plugins from '../websetup.plugins';
|
import * as plugins from '../websetup.plugins.js';
|
||||||
|
|
||||||
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?: plugins.tsclass.saas.IProduct;
|
||||||
|
|
||||||
|
// handles
|
||||||
|
twitterHandle?: string;
|
||||||
|
facebookHandle?: string;
|
||||||
|
|
||||||
|
// links
|
||||||
|
companyWebsiteLink?: string;
|
||||||
|
googleNewsLink?: string;
|
||||||
|
mediumLink?: string;
|
||||||
|
slackLink?: string;
|
||||||
|
airmeetLink?: string;
|
||||||
}
|
}
|
||||||
|
@ -1,10 +1,11 @@
|
|||||||
import * as plugins from './websetup.plugins';
|
import * as plugins from './websetup.plugins.js';
|
||||||
import * as interfaces from './interfaces';
|
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 {
|
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
|
// lets care about linked data
|
||||||
const companyLd = {
|
const companyLd = {
|
||||||
'@context': 'https://schema.org',
|
'@context': 'https://schema.org',
|
||||||
@ -22,11 +23,11 @@ export class JsonLdTag extends Tag {
|
|||||||
},
|
},
|
||||||
sameAs: [],
|
sameAs: [],
|
||||||
};
|
};
|
||||||
|
|
||||||
if (companyDataArg.contact.facebookUrl) {
|
if (companyDataArg.contact.facebookUrl) {
|
||||||
companyLd.sameAs.push(companyDataArg.contact.facebookUrl);
|
companyLd.sameAs.push(companyDataArg.contact.facebookUrl);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (companyDataArg.contact.twitterUrl) {
|
if (companyDataArg.contact.twitterUrl) {
|
||||||
companyLd.sameAs.push(companyDataArg.contact.twitterUrl);
|
companyLd.sameAs.push(companyDataArg.contact.twitterUrl);
|
||||||
}
|
}
|
||||||
@ -35,11 +36,71 @@ export class JsonLdTag extends Tag {
|
|||||||
return ldTag;
|
return ldTag;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static createNewsArticleJsonLd(newsArticleArg: plugins.tsclass.content.IArticle) {
|
||||||
|
const newsArticleLd = {
|
||||||
|
'@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}`,
|
||||||
|
},
|
||||||
|
publisher: {
|
||||||
|
'@type': 'Organization',
|
||||||
|
name: newsArticleArg.author.surName, // TODO
|
||||||
|
logo: {
|
||||||
|
'@type': 'ImageObject',
|
||||||
|
url: newsArticleArg.author.surName, // TODO
|
||||||
|
},
|
||||||
|
},
|
||||||
|
description: newsArticleArg.author.firstName,
|
||||||
|
};
|
||||||
|
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) {
|
constructor(ldObjectArg: any) {
|
||||||
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;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
import { Tag } from './websetup.classes.tag';
|
import { Tag } from './websetup.classes.tag.js';
|
||||||
|
|
||||||
export class LinkTag extends Tag {
|
export class LinkTag extends Tag {
|
||||||
constructor(relArg: string, hrefArg: string) {
|
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 {
|
export class MetaTag extends Tag {
|
||||||
constructor(metaNameArg: string, contentArg: string) {
|
constructor(metaNameArg: string, contentArg: string) {
|
||||||
@ -8,4 +8,4 @@ export class MetaTag extends Tag {
|
|||||||
metaElement.content = contentArg;
|
metaElement.content = contentArg;
|
||||||
this.elementRef = metaElement;
|
this.elementRef = metaElement;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,26 @@
|
|||||||
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 {
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static createProductOgTags(productArg: plugins.tsclass.saas.IProduct) {
|
||||||
|
const tagArray: OpengraphTag[] = [];
|
||||||
|
tagArray.push(new OpengraphTag('og:url', globalThis.location.href));
|
||||||
|
tagArray.push(new OpengraphTag('og:title', `${productArg.name} - ${productArg.slogan}`));
|
||||||
|
tagArray.push(new OpengraphTag('og:site_name', productArg.name))
|
||||||
|
tagArray.push(new OpengraphTag('og:description', productArg.description));
|
||||||
|
tagArray.push(new OpengraphTag('og:image', productArg.logoLink));
|
||||||
|
return tagArray;
|
||||||
|
}
|
||||||
|
|
||||||
constructor(propertyNameArg: string, contentArg: string) {
|
constructor(propertyNameArg: string, contentArg: string) {
|
||||||
super();
|
super();
|
||||||
const openGraphElement = document.createElement('meta');
|
const openGraphElement = document.createElement('meta');
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
import * as plugins from './websetup.plugins';
|
import * as plugins from './websetup.plugins.js';
|
||||||
|
|
||||||
export class Tag {
|
export class Tag {
|
||||||
public elementRef: Element;
|
public elementRef: Element;
|
||||||
@ -18,4 +18,4 @@ export class Tag {
|
|||||||
this.elementRef.parentNode.removeChild(this.elementRef);
|
this.elementRef.parentNode.removeChild(this.elementRef);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,32 +1,52 @@
|
|||||||
import { Tag } from './websetup.classes.tag';
|
import { Tag } from './websetup.classes.tag.js';
|
||||||
import { JsonLdTag } from './websetup.classes.tag.jsonldtag';
|
import { JsonLdTag } from './websetup.classes.tag.jsonldtag.js';
|
||||||
import { OpengraphTag } from './websetup.classes.tag.opengraphtag';
|
import { OpengraphTag } from './websetup.classes.tag.opengraphtag.js';
|
||||||
import { TagManager } from './websetup.classes.tagmanager';
|
import { TagManager } from './websetup.classes.tagmanager.js';
|
||||||
import * as plugins from './websetup.plugins';
|
import * as plugins from './websetup.plugins.js';
|
||||||
|
|
||||||
export type TBaseLevelType = 'global' | 'base' | 'subpage';
|
export type TBaseLevelType = 'global' | 'base' | 'subpage';
|
||||||
|
|
||||||
|
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[] = [];
|
||||||
|
|
||||||
|
public state: TLevelState = 'disabled';
|
||||||
|
|
||||||
constructor(tagManagerRefArg: TagManager, levelType: TBaseLevelType) {
|
constructor(tagManagerRefArg: TagManager, levelType: TBaseLevelType) {
|
||||||
this.tagManagerRef = tagManagerRefArg;
|
this.tagManagerRef = tagManagerRefArg;
|
||||||
}
|
}
|
||||||
|
|
||||||
public addTag(tagArg: Tag) {
|
public addTag(tagArg: Tag | Tag[]) {
|
||||||
this.tags.push(tagArg);
|
if (tagArg instanceof Array) {
|
||||||
|
for (const tagArg2 of tagArg) {
|
||||||
|
this.addTag(tagArg2);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
this.tags.push(tagArg);
|
||||||
|
if (this.state === 'enabled') {
|
||||||
|
tagArg.appendToDom();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public async addCompanyInfo(
|
public async addCompanyInfo(companyDataArg: plugins.tsclass.business.ICompany) {
|
||||||
companyDataArg: plugins.tsclass.business.ICompany
|
this.addTag(JsonLdTag.createCompanyJsonLd(companyDataArg));
|
||||||
) {
|
|
||||||
|
|
||||||
this.addTag(JsonLdTag.createCompanyLd(companyDataArg));
|
|
||||||
|
|
||||||
// lets care about open graph
|
// lets care about open graph
|
||||||
this.addTag(new OpengraphTag('og:type', 'business.business'));
|
this.addTag(new OpengraphTag('og:type', 'business.business'));
|
||||||
this.addTag(new OpengraphTag('og:title', companyDataArg.name));
|
this.addTag(new OpengraphTag('og:title', companyDataArg.name));
|
||||||
@ -39,10 +59,7 @@ export class TagLevel {
|
|||||||
)
|
)
|
||||||
);
|
);
|
||||||
this.addTag(
|
this.addTag(
|
||||||
new OpengraphTag(
|
new OpengraphTag('business:contact_data:locality', companyDataArg.contact.address.postalCode)
|
||||||
'business:contact_data:locality',
|
|
||||||
companyDataArg.contact.address.postalCode
|
|
||||||
)
|
|
||||||
);
|
);
|
||||||
this.addTag(
|
this.addTag(
|
||||||
new OpengraphTag('business:contact_data:region', companyDataArg.contact.address.city)
|
new OpengraphTag('business:contact_data:region', companyDataArg.contact.address.city)
|
||||||
@ -54,13 +71,20 @@ export class TagLevel {
|
|||||||
)
|
)
|
||||||
);
|
);
|
||||||
this.addTag(
|
this.addTag(
|
||||||
new OpengraphTag(
|
new OpengraphTag('business:contact_data:country_name', companyDataArg.contact.address.country)
|
||||||
'business:contact_data:country_name',
|
|
||||||
companyDataArg.contact.address.country
|
|
||||||
)
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public addNewsArticleInfo(articleArg: plugins.tsclass.content.IArticle) {
|
||||||
|
this.addTag(JsonLdTag.createNewsArticleJsonLd(articleArg));
|
||||||
|
this.addTag(OpengraphTag.createNewsArticleOgTags(articleArg));
|
||||||
|
}
|
||||||
|
|
||||||
|
public addProductInfo(productArg: plugins.tsclass.saas.IProduct, companyArg: plugins.tsclass.business.ICompany) {
|
||||||
|
this.addTag(JsonLdTag.createProductJsonLd(productArg, companyArg));
|
||||||
|
this.addTag(OpengraphTag.createProductOgTags(productArg));
|
||||||
|
}
|
||||||
|
|
||||||
public async enable() {
|
public async enable() {
|
||||||
if (this.title) {
|
if (this.title) {
|
||||||
document.title = this.title;
|
document.title = this.title;
|
||||||
@ -68,11 +92,13 @@ export class TagLevel {
|
|||||||
for (const tagArg of this.tags) {
|
for (const tagArg of this.tags) {
|
||||||
tagArg.appendToDom();
|
tagArg.appendToDom();
|
||||||
}
|
}
|
||||||
|
this.state = 'enabled';
|
||||||
}
|
}
|
||||||
|
|
||||||
public async disable() {
|
public async disable() {
|
||||||
for (const tagArg of this.tags) {
|
for (const tagArg of this.tags) {
|
||||||
tagArg.removeFromDom();
|
tagArg.removeFromDom();
|
||||||
}
|
}
|
||||||
|
this.state = 'disabled';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,53 +1,71 @@
|
|||||||
import { TagLevel } from './websetup.classes.taglevel';
|
import { TagLevel } from './websetup.classes.taglevel.js';
|
||||||
import * as plugins from './websetup.plugins';
|
import * as plugins from './websetup.plugins.js';
|
||||||
import * as interfaces from './interfaces';
|
import * as interfaces from './interfaces/index.js';
|
||||||
import { MetaTag } from './websetup.classes.tag.metatag';
|
import { MetaTag } from './websetup.classes.tag.metatag.js';
|
||||||
import { JsonLdTag } from './websetup.classes.tag.jsonldtag';
|
import { JsonLdTag } from './websetup.classes.tag.jsonldtag.js';
|
||||||
import { OpengraphTag } from './websetup.classes.tag.opengraphtag';
|
import { OpengraphTag } from './websetup.classes.tag.opengraphtag.js';
|
||||||
|
|
||||||
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'));
|
||||||
|
|
||||||
|
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 = 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){
|
|
||||||
this.baseLevel.addTag(new MetaTag('canonical', metaObjectArg.canonicalDomain))
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (metaObjectArg.ldCompany) {
|
if (metaObjectArg.canonicalDomain) {
|
||||||
this.baseLevel.addCompanyInfo(metaObjectArg.ldCompany);
|
this.baseLevel.addTag(new MetaTag('canonical', metaObjectArg.canonicalDomain));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// 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();
|
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;
|
||||||
subPageLevel.addTag(new MetaTag('description', metaObjectArg.description));
|
if (metaObjectArg.description) {
|
||||||
this.activeLevel.disable();
|
subPageLevel.addTag(new MetaTag('description', metaObjectArg.description));
|
||||||
|
}
|
||||||
|
await this.activeLevel.disable();
|
||||||
this.activeLevel = subPageLevel;
|
this.activeLevel = subPageLevel;
|
||||||
this.activeLevel.enable();
|
await this.activeLevel.enable();
|
||||||
|
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();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
7
ts/websetup.classes.title.ts
Normal file
7
ts/websetup.classes.title.ts
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
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 {}
|
@ -1,10 +1,11 @@
|
|||||||
import * as plugins from './websetup.plugins';
|
import * as plugins from './websetup.plugins.js';
|
||||||
import * as interfaces from './interfaces';
|
import * as interfaces from './interfaces/index.js';
|
||||||
import { TagManager } from './websetup.classes.tagmanager';
|
import { TagManager } from './websetup.classes.tagmanager.js';
|
||||||
import { TagLevel } from './websetup.classes.taglevel';
|
import { TagLevel } from './websetup.classes.taglevel.js';
|
||||||
|
|
||||||
export interface IWebSetupConstructorOptions {
|
export interface IWebSetupConstructorOptions {
|
||||||
metaObject: interfaces.IMetaObject;
|
metaObject: interfaces.IMetaObject;
|
||||||
|
smartssrWaitForReadySignal?: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -13,17 +14,31 @@ export interface IWebSetupConstructorOptions {
|
|||||||
export class WebSetup {
|
export class WebSetup {
|
||||||
public tagManager: TagManager = new TagManager();
|
public tagManager: TagManager = new TagManager();
|
||||||
public options: IWebSetupConstructorOptions;
|
public options: IWebSetupConstructorOptions;
|
||||||
|
|
||||||
|
// private deferreds
|
||||||
private readyDeferred = plugins.smartpromise.defer();
|
private readyDeferred = plugins.smartpromise.defer();
|
||||||
|
private readyForSmartssrDeferred = plugins.smartpromise.defer();
|
||||||
|
|
||||||
|
// public promises
|
||||||
public readyPromise = this.readyDeferred.promise;
|
public readyPromise = this.readyDeferred.promise;
|
||||||
|
public readyForSmartssrPromise = this.readyForSmartssrDeferred.promise;
|
||||||
constructor(optionsArg: IWebSetupConstructorOptions) {
|
constructor(optionsArg: IWebSetupConstructorOptions) {
|
||||||
this.options = optionsArg;
|
this.options = optionsArg;
|
||||||
this.setup().then(() => {this.readyDeferred.resolve()});
|
this.setup().then(() => {
|
||||||
|
this.readyDeferred.resolve();
|
||||||
|
if (!this.options.smartssrWaitForReadySignal) {
|
||||||
|
this.readyForSmartssrDeferred.resolve();
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 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);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -36,8 +51,28 @@ export class WebSetup {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* sets a subpage
|
* sets a subpage
|
||||||
* @param metaObject
|
* @param metaObjectArg
|
||||||
*/
|
*/
|
||||||
public setSubLevel(metaObject: interfaces.IMetaObject) {
|
public async setSubLevel(metaObjectArg: interfaces.IMetaObject) {
|
||||||
|
const subLevel = await this.tagManager.setSubPageLevel(metaObjectArg);
|
||||||
|
return subLevel;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* flashes the title with the given text
|
||||||
|
* @param flashTextArg
|
||||||
|
*/
|
||||||
|
public flashTitle(flashTextArg: string) {}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* informs smartssr that the page is ready to be rendered
|
||||||
|
*/
|
||||||
|
public informReadyForSmartssr() {
|
||||||
|
if (!this.options.smartssrWaitForReadySignal) {
|
||||||
|
console.error(
|
||||||
|
`You have not indicated that you inform smartssr by a dedicated signal! Please consider doing so!`
|
||||||
|
);
|
||||||
|
}
|
||||||
|
this.readyForSmartssrDeferred.resolve();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,9 +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 {
|
export { smartdelay, smartpromise };
|
||||||
smartpromise
|
|
||||||
};
|
|
||||||
|
|
||||||
// tsclass scope
|
// tsclass scope
|
||||||
import * as tsclass from '@tsclass/tsclass';
|
import * as tsclass from '@tsclass/tsclass';
|
||||||
|
10
tsconfig.json
Normal file
10
tsconfig.json
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
{
|
||||||
|
"compilerOptions": {
|
||||||
|
"experimentalDecorators": true,
|
||||||
|
"useDefineForClassFields": false,
|
||||||
|
"target": "ES2022",
|
||||||
|
"module": "ES2022",
|
||||||
|
"moduleResolution": "nodenext",
|
||||||
|
"esModuleInterop": true
|
||||||
|
}
|
||||||
|
}
|
17
tslint.json
17
tslint.json
@ -1,17 +0,0 @@
|
|||||||
{
|
|
||||||
"extends": ["tslint:latest", "tslint-config-prettier"],
|
|
||||||
"rules": {
|
|
||||||
"semicolon": [true, "always"],
|
|
||||||
"no-console": false,
|
|
||||||
"ordered-imports": false,
|
|
||||||
"object-literal-sort-keys": false,
|
|
||||||
"member-ordering": {
|
|
||||||
"options":{
|
|
||||||
"order": [
|
|
||||||
"static-method"
|
|
||||||
]
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"defaultSeverity": "warning"
|
|
||||||
}
|
|
Reference in New Issue
Block a user