Compare commits
39 Commits
Author | SHA1 | Date | |
---|---|---|---|
8e4bdb867c | |||
359e18f5dc | |||
751a325c81 | |||
93d4bc491f | |||
bdf55a19d9 | |||
cd1f68f55e | |||
f2bd7145b3 | |||
6d9789df45 | |||
0be8a6f60d | |||
a3793572e7 | |||
6ace59d1d1 | |||
b6ddf6a87b | |||
b999627ba5 | |||
5e8a91f302 | |||
2fc0613fa6 | |||
2283cdb633 | |||
c0db06fc18 | |||
4557000629 | |||
78997e1e5a | |||
4d5564e8d4 | |||
11d89adc4b | |||
a99fd6374c | |||
ba287cdb76 | |||
5318408037 | |||
16ef41ae20 | |||
7375675d7d | |||
68f9221d33 | |||
269e658967 | |||
9008aca718 | |||
74d73a0d21 | |||
5496c8c482 | |||
c748c5102c | |||
308133fe4f | |||
cb80b4df75 | |||
74ed988da0 | |||
d1793f9084 | |||
4a45262124 | |||
f5f51ac1a6 | |||
eb4a4288ed |
14
.gitignore
vendored
14
.gitignore
vendored
@ -1,8 +1,20 @@
|
|||||||
.nogit/
|
.nogit/
|
||||||
node_modules/
|
|
||||||
|
# artifacts
|
||||||
coverage/
|
coverage/
|
||||||
public/
|
public/
|
||||||
pages/
|
pages/
|
||||||
|
|
||||||
|
# installs
|
||||||
|
node_modules/
|
||||||
|
|
||||||
|
# caches
|
||||||
.yarn/
|
.yarn/
|
||||||
.cache/
|
.cache/
|
||||||
|
.rpt2_cache
|
||||||
|
|
||||||
|
# builds
|
||||||
dist/
|
dist/
|
||||||
|
dist_*/
|
||||||
|
|
||||||
|
# custom
|
138
.gitlab-ci.yml
138
.gitlab-ci.yml
@ -1,16 +1,16 @@
|
|||||||
# gitzone standard
|
# gitzone ci_default
|
||||||
image: hosttoday/ht-docker-node:npmci
|
image: registry.gitlab.com/hosttoday/ht-docker-node:npmci
|
||||||
|
|
||||||
cache:
|
cache:
|
||||||
paths:
|
paths:
|
||||||
- .npmci_cache/
|
- .npmci_cache/
|
||||||
key: "$CI_BUILD_STAGE"
|
key: '$CI_BUILD_STAGE'
|
||||||
|
|
||||||
stages:
|
stages:
|
||||||
- security
|
- security
|
||||||
- test
|
- test
|
||||||
- release
|
- release
|
||||||
- metadata
|
- metadata
|
||||||
|
|
||||||
# ====================
|
# ====================
|
||||||
# security stage
|
# security stage
|
||||||
@ -18,124 +18,104 @@ stages:
|
|||||||
mirror:
|
mirror:
|
||||||
stage: security
|
stage: security
|
||||||
script:
|
script:
|
||||||
- npmci git mirror
|
- npmci git mirror
|
||||||
tags:
|
tags:
|
||||||
- docker
|
- lossless
|
||||||
- notpriv
|
- docker
|
||||||
|
- notpriv
|
||||||
|
|
||||||
snyk:
|
audit:
|
||||||
|
image: registry.gitlab.com/hosttoday/ht-docker-node:npmci
|
||||||
stage: security
|
stage: security
|
||||||
script:
|
script:
|
||||||
- npmci npm prepare
|
- npmci npm prepare
|
||||||
- npmci command npm install -g snyk
|
|
||||||
- npmci command npm install --ignore-scripts
|
- npmci command npm install --ignore-scripts
|
||||||
- npmci command snyk test
|
- npmci command npm config set registry https://registry.npmjs.org
|
||||||
|
- npmci command npm audit --audit-level=high
|
||||||
tags:
|
tags:
|
||||||
- docker
|
- lossless
|
||||||
- notpriv
|
- docker
|
||||||
|
- notpriv
|
||||||
sast:
|
|
||||||
stage: security
|
|
||||||
image: docker:stable
|
|
||||||
variables:
|
|
||||||
DOCKER_DRIVER: overlay2
|
|
||||||
allow_failure: true
|
|
||||||
services:
|
|
||||||
- docker:stable-dind
|
|
||||||
script:
|
|
||||||
- export SP_VERSION=$(echo "$CI_SERVER_VERSION" | sed 's/^\([0-9]*\)\.\([0-9]*\).*/\1-\2-stable/')
|
|
||||||
- docker run
|
|
||||||
--env SAST_CONFIDENCE_LEVEL="${SAST_CONFIDENCE_LEVEL:-3}"
|
|
||||||
--volume "$PWD:/code"
|
|
||||||
--volume /var/run/docker.sock:/var/run/docker.sock
|
|
||||||
"registry.gitlab.com/gitlab-org/security-products/sast:$SP_VERSION" /app/bin/run /code
|
|
||||||
artifacts:
|
|
||||||
reports:
|
|
||||||
sast: gl-sast-report.json
|
|
||||||
tags:
|
|
||||||
- docker
|
|
||||||
- priv
|
|
||||||
|
|
||||||
# ====================
|
# ====================
|
||||||
# test stage
|
# test stage
|
||||||
# ====================
|
# ====================
|
||||||
|
|
||||||
testLTS:
|
testStable:
|
||||||
stage: test
|
stage: test
|
||||||
script:
|
script:
|
||||||
- npmci npm prepare
|
- npmci npm prepare
|
||||||
- npmci node install lts
|
- 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:
|
||||||
- docker
|
- lossless
|
||||||
- notpriv
|
- docker
|
||||||
|
- priv
|
||||||
testSTABLE:
|
|
||||||
|
testBuild:
|
||||||
stage: test
|
stage: test
|
||||||
script:
|
script:
|
||||||
- npmci npm prepare
|
- npmci npm prepare
|
||||||
- npmci node install stable
|
- npmci node install stable
|
||||||
- npmci npm install
|
- npmci npm install
|
||||||
- npmci npm test
|
- npmci command npm run build
|
||||||
coverage: /\d+.?\d+?\%\s*coverage/
|
coverage: /\d+.?\d+?\%\s*coverage/
|
||||||
tags:
|
tags:
|
||||||
- docker
|
- lossless
|
||||||
- notpriv
|
- docker
|
||||||
|
- notpriv
|
||||||
|
|
||||||
release:
|
release:
|
||||||
stage: release
|
stage: release
|
||||||
script:
|
script:
|
||||||
- npmci node install stable
|
- npmci node install stable
|
||||||
- npmci npm publish
|
- npmci npm publish
|
||||||
only:
|
only:
|
||||||
- tags
|
- tags
|
||||||
tags:
|
tags:
|
||||||
- docker
|
- lossless
|
||||||
- notpriv
|
- docker
|
||||||
|
- notpriv
|
||||||
|
|
||||||
# ====================
|
# ====================
|
||||||
# metadata stage
|
# metadata stage
|
||||||
# ====================
|
# ====================
|
||||||
codequality:
|
codequality:
|
||||||
stage: metadata
|
stage: metadata
|
||||||
image: docker:stable
|
|
||||||
allow_failure: true
|
allow_failure: true
|
||||||
services:
|
|
||||||
- docker:stable-dind
|
|
||||||
script:
|
script:
|
||||||
- export SP_VERSION=$(echo "$CI_SERVER_VERSION" | sed 's/^\([0-9]*\)\.\([0-9]*\).*/\1-\2-stable/')
|
- npmci command npm install -g tslint typescript
|
||||||
- docker run
|
- npmci npm prepare
|
||||||
--env SOURCE_CODE="$PWD"
|
- npmci npm install
|
||||||
--volume "$PWD":/code
|
- npmci command "tslint -c tslint.json ./ts/**/*.ts"
|
||||||
--volume /var/run/docker.sock:/var/run/docker.sock
|
|
||||||
"registry.gitlab.com/gitlab-org/security-products/codequality:$SP_VERSION" /code
|
|
||||||
artifacts:
|
|
||||||
paths: [codeclimate.json]
|
|
||||||
tags:
|
tags:
|
||||||
- docker
|
- lossless
|
||||||
- priv
|
- docker
|
||||||
|
- priv
|
||||||
|
|
||||||
trigger:
|
trigger:
|
||||||
stage: metadata
|
stage: metadata
|
||||||
script:
|
script:
|
||||||
- npmci trigger
|
- npmci trigger
|
||||||
only:
|
only:
|
||||||
- tags
|
- tags
|
||||||
tags:
|
tags:
|
||||||
- docker
|
- lossless
|
||||||
- notpriv
|
- docker
|
||||||
|
- notpriv
|
||||||
|
|
||||||
pages:
|
pages:
|
||||||
image: hosttoday/ht-docker-node:npmci
|
|
||||||
stage: metadata
|
stage: metadata
|
||||||
script:
|
script:
|
||||||
- npmci command npm install -g typedoc typescript
|
- npmci node install lts
|
||||||
|
- npmci command npm install -g @gitzone/tsdoc
|
||||||
- npmci npm prepare
|
- npmci npm prepare
|
||||||
- npmci npm install
|
- npmci npm install
|
||||||
- npmci command typedoc --module "commonjs" --target "ES2016" --out public/ ts/
|
- npmci command tsdoc
|
||||||
tags:
|
tags:
|
||||||
|
- lossless
|
||||||
- docker
|
- docker
|
||||||
- notpriv
|
- notpriv
|
||||||
only:
|
only:
|
||||||
@ -143,5 +123,5 @@ pages:
|
|||||||
artifacts:
|
artifacts:
|
||||||
expire_in: 1 week
|
expire_in: 1 week
|
||||||
paths:
|
paths:
|
||||||
- public
|
- public
|
||||||
allow_failure: true
|
allow_failure: true
|
||||||
|
29
.vscode/launch.json
vendored
Normal file
29
.vscode/launch.json
vendored
Normal file
@ -0,0 +1,29 @@
|
|||||||
|
{
|
||||||
|
"version": "0.2.0",
|
||||||
|
"configurations": [
|
||||||
|
{
|
||||||
|
"name": "current file",
|
||||||
|
"type": "node",
|
||||||
|
"request": "launch",
|
||||||
|
"args": [
|
||||||
|
"${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"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
26
.vscode/settings.json
vendored
Normal file
26
.vscode/settings.json
vendored
Normal file
@ -0,0 +1,26 @@
|
|||||||
|
{
|
||||||
|
"json.schemas": [
|
||||||
|
{
|
||||||
|
"fileMatch": ["/npmextra.json"],
|
||||||
|
"schema": {
|
||||||
|
"type": "object",
|
||||||
|
"properties": {
|
||||||
|
"npmci": {
|
||||||
|
"type": "object",
|
||||||
|
"description": "settings for npmci"
|
||||||
|
},
|
||||||
|
"gitzone": {
|
||||||
|
"type": "object",
|
||||||
|
"description": "settings for gitzone",
|
||||||
|
"properties": {
|
||||||
|
"projectType": {
|
||||||
|
"type": "string",
|
||||||
|
"enum": ["website", "element", "service", "npm"]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
@ -2,5 +2,16 @@
|
|||||||
"npmci": {
|
"npmci": {
|
||||||
"npmGlobalTools": [],
|
"npmGlobalTools": [],
|
||||||
"npmAccessLevel": "public"
|
"npmAccessLevel": "public"
|
||||||
|
},
|
||||||
|
"gitzone": {
|
||||||
|
"projectType": "npm",
|
||||||
|
"module": {
|
||||||
|
"githost": "gitlab.com",
|
||||||
|
"gitscope": "pushrocks",
|
||||||
|
"gitrepo": "websetup",
|
||||||
|
"shortDescription": "setup basic page properties",
|
||||||
|
"npmPackagename": "@pushrocks/websetup",
|
||||||
|
"license": "MIT"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
4712
package-lock.json
generated
4712
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
38
package.json
38
package.json
@ -1,23 +1,41 @@
|
|||||||
{
|
{
|
||||||
"name": "@pushrocks/websetup",
|
"name": "@pushrocks/websetup",
|
||||||
"version": "1.0.4",
|
"version": "2.0.15",
|
||||||
"private": false,
|
"private": false,
|
||||||
"description": "setup basic page properties",
|
"description": "setup basic page properties",
|
||||||
"main": "dist/index.js",
|
"main": "dist_ts/index.js",
|
||||||
"typings": "dist/index.d.ts",
|
"typings": "dist_ts/index.d.ts",
|
||||||
"author": "Lossless GmbH",
|
"author": "Lossless GmbH",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"test": "(tstest test/)",
|
"test": "(tstest test/)",
|
||||||
"build": "(tsbuild)",
|
"build": "(tsbuild --web && tsbundle npm)"
|
||||||
"format": "(gitzone format)"
|
|
||||||
},
|
},
|
||||||
|
"keywords": [
|
||||||
|
"lossless",
|
||||||
|
"websafe"
|
||||||
|
],
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@gitzone/tsbuild": "^2.0.22",
|
"@gitzone/tsbuild": "^2.1.22",
|
||||||
"@gitzone/tstest": "^1.0.15",
|
"@gitzone/tsbundle": "^1.0.57",
|
||||||
"@pushrocks/tapbundle": "^3.0.7",
|
"@gitzone/tstest": "^1.0.28",
|
||||||
"tslint": "^5.11.0",
|
"@pushrocks/tapbundle": "^3.2.1",
|
||||||
|
"tslint": "^6.1.0",
|
||||||
"tslint-config-prettier": "^1.15.0"
|
"tslint-config-prettier": "^1.15.0"
|
||||||
},
|
},
|
||||||
"dependencies": {}
|
"dependencies": {
|
||||||
|
"@tsclass/tsclass": "^3.0.18"
|
||||||
|
},
|
||||||
|
"files": [
|
||||||
|
"ts/**/*",
|
||||||
|
"ts_web/**/*",
|
||||||
|
"dist/**/*",
|
||||||
|
"dist_*/**/*",
|
||||||
|
"dist_ts/**/*",
|
||||||
|
"dist_ts_web/**/*",
|
||||||
|
"assets/**/*",
|
||||||
|
"cli.js",
|
||||||
|
"npmextra.json",
|
||||||
|
"readme.md"
|
||||||
|
]
|
||||||
}
|
}
|
||||||
|
43
readme.md
Normal file
43
readme.md
Normal file
@ -0,0 +1,43 @@
|
|||||||
|
# @pushrocks/websetup
|
||||||
|
setup basic page properties
|
||||||
|
|
||||||
|
## Availabililty and Links
|
||||||
|
* [npmjs.org (npm package)](https://www.npmjs.com/package/@pushrocks/websetup)
|
||||||
|
* [gitlab.com (source)](https://gitlab.com/pushrocks/websetup)
|
||||||
|
* [github.com (source mirror)](https://github.com/pushrocks/websetup)
|
||||||
|
* [docs (typedoc)](https://pushrocks.gitlab.io/websetup/)
|
||||||
|
|
||||||
|
## Status for master
|
||||||
|
|
||||||
|
Status Category | Status Badge
|
||||||
|
-- | --
|
||||||
|
GitLab Pipelines | [](https://lossless.cloud)
|
||||||
|
GitLab Pipline Test Coverage | [](https://lossless.cloud)
|
||||||
|
npm | [](https://lossless.cloud)
|
||||||
|
Snyk | [](https://lossless.cloud)
|
||||||
|
TypeScript Support | [](https://lossless.cloud)
|
||||||
|
node Support | [](https://nodejs.org/dist/latest-v10.x/docs/api/)
|
||||||
|
Code Style | [](https://lossless.cloud)
|
||||||
|
PackagePhobia (total standalone install weight) | [](https://lossless.cloud)
|
||||||
|
PackagePhobia (package size on registry) | [](https://lossless.cloud)
|
||||||
|
BundlePhobia (total size when bundled) | [](https://lossless.cloud)
|
||||||
|
Platform support | [](https://lossless.cloud) [](https://lossless.cloud)
|
||||||
|
|
||||||
|
## Usage
|
||||||
|
|
||||||
|
Use TypeScript for best in class intellisense.
|
||||||
|
|
||||||
|
## Contribution
|
||||||
|
|
||||||
|
We are always happy for code contributions. If you are not the code contributing type that is ok. Still, maintaining Open Source repositories takes considerable time and thought. If you like the quality of what we do and our modules are useful to you we would appreciate a little monthly contribution: You can [contribute one time](https://lossless.link/contribute-onetime) or [contribute monthly](https://lossless.link/contribute). :)
|
||||||
|
|
||||||
|
## Contribution
|
||||||
|
|
||||||
|
We are always happy for code contributions. If you are not the code contributing type that is ok. Still, maintaining Open Source repositories takes considerable time and thought. If you like the quality of what we do and our modules are useful to you we would appreciate a little monthly contribution: You can [contribute one time](https://lossless.link/contribute-onetime) or [contribute monthly](https://lossless.link/contribute). :)
|
||||||
|
|
||||||
|
For further information read the linked docs at the top of this readme.
|
||||||
|
|
||||||
|
> MIT licensed | **©** [Lossless GmbH](https://lossless.gmbh)
|
||||||
|
| By using this npm module you agree to our [privacy policy](https://lossless.gmbH/privacy)
|
||||||
|
|
||||||
|
[](https://maintainedby.lossless.com)
|
@ -1,8 +1,8 @@
|
|||||||
import { expect, tap } from '@pushrocks/tapbundle';
|
import { expect, tap } from '@pushrocks/tapbundle';
|
||||||
import * as websetup from '../ts/index'
|
import * as websetup from '../ts/index';
|
||||||
|
|
||||||
tap.test('first test', async () => {
|
tap.test('first test', async () => {
|
||||||
console.log(websetup.standardExport)
|
console.log('Waiting for proper puppeteer support here');
|
||||||
})
|
});
|
||||||
|
|
||||||
tap.start()
|
tap.start();
|
||||||
|
19
ts/index.ts
19
ts/index.ts
@ -2,23 +2,32 @@ import * as plugins from './websetup.plugins';
|
|||||||
|
|
||||||
import { setupGoogleAnalytics } from './tools/ganalytics';
|
import { setupGoogleAnalytics } from './tools/ganalytics';
|
||||||
import { setupFullStory } from './tools/fullstory';
|
import { setupFullStory } from './tools/fullstory';
|
||||||
|
import { IMetaObject, setupMetaInformation } from './meta';
|
||||||
|
|
||||||
export interface IWebSetupConstructorOptions {
|
export interface IWebSetupConstructorOptions {
|
||||||
googleAnalyticsCode?: string;
|
googleAnalyticsCode?: string;
|
||||||
fsCode?: string;
|
fsCode?: string;
|
||||||
|
metaObject: IMetaObject;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* the main WebSetup class
|
* the main WebSetup class
|
||||||
*/
|
*/
|
||||||
export class WebSetup {
|
export class WebSetup {
|
||||||
|
public options: IWebSetupConstructorOptions;
|
||||||
constructor(optionsArg: IWebSetupConstructorOptions) {
|
constructor(optionsArg: IWebSetupConstructorOptions) {
|
||||||
if (optionsArg.googleAnalyticsCode) {
|
this.options = optionsArg;
|
||||||
setupGoogleAnalytics(optionsArg.googleAnalyticsCode);
|
}
|
||||||
|
|
||||||
|
public async setup() {
|
||||||
|
await setupMetaInformation(this.options.metaObject);
|
||||||
|
|
||||||
|
if (this.options.googleAnalyticsCode) {
|
||||||
|
await setupGoogleAnalytics(this.options.googleAnalyticsCode);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (optionsArg.fsCode) {
|
if (this.options.fsCode) {
|
||||||
setupFullStory(optionsArg.fsCode)
|
await setupFullStory(this.options.fsCode);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
122
ts/meta/index.ts
Normal file
122
ts/meta/index.ts
Normal file
@ -0,0 +1,122 @@
|
|||||||
|
import * as plugins from '../websetup.plugins';
|
||||||
|
|
||||||
|
export interface IMetaObject {
|
||||||
|
title: string;
|
||||||
|
description: string;
|
||||||
|
canonicalDomain?: string;
|
||||||
|
ldCompany?: plugins.tsclass.business.ICompany;
|
||||||
|
ldProduct?: any;
|
||||||
|
}
|
||||||
|
|
||||||
|
export const setupMetaInformation = async (metaObjectArg: IMetaObject) => {
|
||||||
|
document.title = metaObjectArg.title;
|
||||||
|
addMetaTag('description', metaObjectArg.description);
|
||||||
|
addMetaTag('google', 'notranslate');
|
||||||
|
addMetaTag('revisit-after', '1 days');
|
||||||
|
metaObjectArg.canonicalDomain ? addLinkTag('canonical', metaObjectArg.canonicalDomain) : null;
|
||||||
|
|
||||||
|
if (metaObjectArg.ldCompany) {
|
||||||
|
addCompanyInfo(metaObjectArg.ldCompany);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
const addMetaTag = async (metaNameArg: string, contentArg: string) => {
|
||||||
|
const metaElement = document.createElement('meta');
|
||||||
|
metaElement.name = metaNameArg;
|
||||||
|
metaElement.content = contentArg;
|
||||||
|
document.getElementsByTagName('head')[0].appendChild(metaElement);
|
||||||
|
};
|
||||||
|
|
||||||
|
const addLinkTag = async (relArg, hrefArg): Promise<Element> => {
|
||||||
|
const link = !!document.querySelector("link[rel='canonical']")
|
||||||
|
? document.querySelector("link[rel='canonical']")
|
||||||
|
: document.createElement('link');
|
||||||
|
link.setAttribute('rel', relArg);
|
||||||
|
link.setAttribute('href', hrefArg);
|
||||||
|
document.head.appendChild(link);
|
||||||
|
return link;
|
||||||
|
};
|
||||||
|
|
||||||
|
const addOpenGraphProperty = async (
|
||||||
|
propertyNameArg: string,
|
||||||
|
contentArg: string
|
||||||
|
): Promise<Element> => {
|
||||||
|
const openGraphElement = document.createElement('meta');
|
||||||
|
openGraphElement.setAttribute('property', propertyNameArg);
|
||||||
|
openGraphElement.content = contentArg;
|
||||||
|
document.getElementsByTagName('head')[0].appendChild(openGraphElement);
|
||||||
|
return openGraphElement;
|
||||||
|
};
|
||||||
|
|
||||||
|
const addCompanyInfo = async (
|
||||||
|
companyDataArg: plugins.tsclass.business.ICompany
|
||||||
|
): Promise<Element[]> => {
|
||||||
|
const returnElementArray: Element[] = [];
|
||||||
|
|
||||||
|
// lets care about linked data
|
||||||
|
const companyLd = {
|
||||||
|
'@context': 'https://schema.org',
|
||||||
|
'@type': 'Corporation',
|
||||||
|
name: companyDataArg.name,
|
||||||
|
alternateName: companyDataArg.name.replace(' GmbH', ''),
|
||||||
|
url: companyDataArg.contact.website,
|
||||||
|
logo: companyDataArg.contact.logoUrl,
|
||||||
|
contactPoint: {
|
||||||
|
'@type': 'ContactPoint',
|
||||||
|
telephone: companyDataArg.contact.phone,
|
||||||
|
contactType: 'customer service',
|
||||||
|
areaServed: 'DE',
|
||||||
|
availableLanguage: ['en', 'German'],
|
||||||
|
},
|
||||||
|
sameAs: [],
|
||||||
|
};
|
||||||
|
|
||||||
|
if (companyDataArg.contact.facebookUrl) {
|
||||||
|
companyLd.sameAs.push(companyDataArg.contact.facebookUrl);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (companyDataArg.contact.twitterUrl) {
|
||||||
|
companyLd.sameAs.push(companyDataArg.contact.twitterUrl);
|
||||||
|
}
|
||||||
|
|
||||||
|
const jsonLdElement = document.createElement('script');
|
||||||
|
jsonLdElement.type = 'application/ld+json';
|
||||||
|
jsonLdElement.text = JSON.stringify(companyLd);
|
||||||
|
document.querySelector('head').appendChild(jsonLdElement);
|
||||||
|
returnElementArray.push(jsonLdElement);
|
||||||
|
|
||||||
|
// lets care about open graph
|
||||||
|
returnElementArray.push(await addOpenGraphProperty('og:type', 'business.business'));
|
||||||
|
returnElementArray.push(await addOpenGraphProperty('og:title', companyDataArg.name));
|
||||||
|
returnElementArray.push(await addOpenGraphProperty('og:url', companyDataArg.contact.website));
|
||||||
|
returnElementArray.push(await addOpenGraphProperty('og:image', companyDataArg.contact.logoUrl));
|
||||||
|
returnElementArray.push(
|
||||||
|
await addOpenGraphProperty(
|
||||||
|
'business:contact_data:street_address',
|
||||||
|
`${companyDataArg.contact.address.streetName} ${companyDataArg.contact.address.houseNumber}`
|
||||||
|
)
|
||||||
|
);
|
||||||
|
returnElementArray.push(
|
||||||
|
await addOpenGraphProperty(
|
||||||
|
'business:contact_data:locality',
|
||||||
|
companyDataArg.contact.address.postalCode
|
||||||
|
)
|
||||||
|
);
|
||||||
|
returnElementArray.push(
|
||||||
|
await addOpenGraphProperty('business:contact_data:region', companyDataArg.contact.address.city)
|
||||||
|
);
|
||||||
|
returnElementArray.push(
|
||||||
|
await addOpenGraphProperty(
|
||||||
|
'business:contact_data:postal_code',
|
||||||
|
companyDataArg.contact.address.postalCode
|
||||||
|
)
|
||||||
|
);
|
||||||
|
returnElementArray.push(
|
||||||
|
await addOpenGraphProperty(
|
||||||
|
'business:contact_data:country_name',
|
||||||
|
companyDataArg.contact.address.country
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
return returnElementArray;
|
||||||
|
};
|
@ -1,7 +1,10 @@
|
|||||||
declare global {
|
declare global {
|
||||||
// tslint:disable-next-line: interface-name
|
// tslint:disable-next-line: interface-name
|
||||||
interface Window {
|
interface Window {
|
||||||
|
_fs_debug: boolean;
|
||||||
_fs_host: any;
|
_fs_host: any;
|
||||||
|
_fs_org: string;
|
||||||
|
_fs_namespace: string;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
export const setupFullStory = async (fsCodeArg: string) => {
|
export const setupFullStory = async (fsCodeArg: string) => {
|
||||||
@ -13,7 +16,7 @@ export const setupFullStory = async (fsCodeArg: string) => {
|
|||||||
window['_fs_org'] = fsCodeArg;
|
window['_fs_org'] = fsCodeArg;
|
||||||
// tslint:disable-next-line: no-string-literal
|
// tslint:disable-next-line: no-string-literal
|
||||||
window['_fs_namespace'] = 'FS';
|
window['_fs_namespace'] = 'FS';
|
||||||
(function(m, n, e, t, l, o, g, y) {
|
((m, n, e, t, l, o, g, y) => {
|
||||||
if (e in m) {
|
if (e in m) {
|
||||||
if (m.console && m.console.log) {
|
if (m.console && m.console.log) {
|
||||||
m.console.log('FullStory namespace conflict. Please set window["_fs_namespace"].');
|
m.console.log('FullStory namespace conflict. Please set window["_fs_namespace"].');
|
||||||
@ -21,46 +24,47 @@ export const setupFullStory = async (fsCodeArg: string) => {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// tslint:disable-next-line: only-arrow-functions
|
// tslint:disable-next-line: only-arrow-functions
|
||||||
g = m[e] = function(a, b, s) {
|
g = m[e] = function (a, b, s) {
|
||||||
g.q ? g.q.push([a, b, s]) : g._api(a, b, s);
|
g.q ? g.q.push([a, b, s]) : g._api(a, b, s);
|
||||||
};
|
};
|
||||||
g.q = [];
|
g.q = [];
|
||||||
o = n.createElement(t);
|
o = n.createElement(t);
|
||||||
o.async = 1;
|
o.async = 1;
|
||||||
o.src = 'https://' + window._fs_host + '/s/fs.js';
|
o.src = 'https://' + window._fs_host + '/s/fs.js';
|
||||||
|
o.crossorigin = 'anonymous';
|
||||||
y = n.getElementsByTagName(t)[0];
|
y = n.getElementsByTagName(t)[0];
|
||||||
y.parentNode.insertBefore(o, y);
|
y.parentNode.insertBefore(o, y);
|
||||||
// tslint:disable-next-line: only-arrow-functions
|
// tslint:disable-next-line: only-arrow-functions
|
||||||
g.identify = function(i, v, s) {
|
g.identify = function (i, v, s) {
|
||||||
g(l, { uid: i }, s);
|
g(l, { uid: i }, s);
|
||||||
if (v) g(l, v, s);
|
if (v) g(l, v, s);
|
||||||
};
|
};
|
||||||
g.setUserVars = function(v, s) {
|
g.setUserVars = function (v, s) {
|
||||||
g(l, v, s);
|
g(l, v, s);
|
||||||
};
|
};
|
||||||
g.event = function(i, v, s) {
|
g.event = function (i, v, s) {
|
||||||
g('event', { n: i, p: v }, s);
|
g('event', { n: i, p: v }, s);
|
||||||
};
|
};
|
||||||
// tslint:disable-next-line: only-arrow-functions
|
// tslint:disable-next-line: only-arrow-functions
|
||||||
g.shutdown = function() {
|
g.shutdown = function () {
|
||||||
g('rec', !1);
|
g('rec', !1);
|
||||||
};
|
};
|
||||||
g.restart = function() {
|
g.restart = function () {
|
||||||
g('rec', !0);
|
g('rec', !0);
|
||||||
};
|
};
|
||||||
// tslint:disable-next-line: only-arrow-functions
|
// tslint:disable-next-line: only-arrow-functions
|
||||||
g.consent = function(a) {
|
g.consent = function (a) {
|
||||||
g('consent', !arguments.length || a);
|
g('consent', !arguments.length || a);
|
||||||
};
|
};
|
||||||
// tslint:disable-next-line: only-arrow-functions
|
// tslint:disable-next-line: only-arrow-functions
|
||||||
g.identifyAccount = function(i, v) {
|
g.identifyAccount = function (i, v) {
|
||||||
o = 'account';
|
o = 'account';
|
||||||
v = v || {};
|
v = v || {};
|
||||||
v.acctId = i;
|
v.acctId = i;
|
||||||
g(o, v);
|
g(o, v);
|
||||||
};
|
};
|
||||||
// tslint:disable-next-line: only-arrow-functions
|
// tslint:disable-next-line: only-arrow-functions
|
||||||
g.clearUserCookie = function() {};
|
g.clearUserCookie = function () {};
|
||||||
// tslint:disable-next-line: no-string-literal
|
// tslint:disable-next-line: no-string-literal
|
||||||
})(window, document, window['_fs_namespace'], 'script', 'user');
|
})(window, document, window['_fs_namespace'], 'script', 'user');
|
||||||
};
|
};
|
||||||
|
@ -7,14 +7,14 @@ declare global {
|
|||||||
|
|
||||||
export const setupGoogleAnalytics = async (gaCode: string) => {
|
export const setupGoogleAnalytics = async (gaCode: string) => {
|
||||||
// tslint:disable-next-line: only-arrow-functions
|
// tslint:disable-next-line: only-arrow-functions
|
||||||
(function(i, s, o, g, r, a, m) {
|
(function (i, s, o, g, r, a, m) {
|
||||||
// tslint:disable-next-line: no-string-literal
|
// tslint:disable-next-line: no-string-literal
|
||||||
i['GoogleAnalyticsObject'] = r;
|
i['GoogleAnalyticsObject'] = r;
|
||||||
// tslint:disable-next-line: ban-comma-operator
|
// tslint:disable-next-line: ban-comma-operator
|
||||||
(i[r] =
|
(i[r] =
|
||||||
i[r] ||
|
i[r] ||
|
||||||
// tslint:disable-next-line: only-arrow-functions
|
// tslint:disable-next-line: only-arrow-functions
|
||||||
function() {
|
function () {
|
||||||
(i[r].q = i[r].q || []).push(arguments);
|
(i[r].q = i[r].q || []).push(arguments);
|
||||||
}),
|
}),
|
||||||
(i[r].l = new Date().getTime());
|
(i[r].l = new Date().getTime());
|
||||||
@ -22,6 +22,7 @@ export const setupGoogleAnalytics = async (gaCode: string) => {
|
|||||||
(a = s.createElement(o)), (m = s.getElementsByTagName(o)[0]);
|
(a = s.createElement(o)), (m = s.getElementsByTagName(o)[0]);
|
||||||
a.async = 1;
|
a.async = 1;
|
||||||
a.src = g;
|
a.src = g;
|
||||||
|
a.crossorigin = 'anonymous';
|
||||||
m.parentNode.insertBefore(a, m);
|
m.parentNode.insertBefore(a, m);
|
||||||
})(window, document, 'script', '//www.google-analytics.com/analytics.js', 'analytics');
|
})(window, document, 'script', '//www.google-analytics.com/analytics.js', 'analytics');
|
||||||
|
|
||||||
|
@ -1,4 +1,3 @@
|
|||||||
const removeme = {};
|
import * as tsclass from '@tsclass/tsclass';
|
||||||
export {
|
|
||||||
removeme
|
export { tsclass };
|
||||||
}
|
|
||||||
|
Reference in New Issue
Block a user