Compare commits
19 Commits
Author | SHA1 | Date | |
---|---|---|---|
751a325c81 | |||
93d4bc491f | |||
bdf55a19d9 | |||
cd1f68f55e | |||
f2bd7145b3 | |||
6d9789df45 | |||
0be8a6f60d | |||
a3793572e7 | |||
6ace59d1d1 | |||
b6ddf6a87b | |||
b999627ba5 | |||
5e8a91f302 | |||
2fc0613fa6 | |||
2283cdb633 | |||
c0db06fc18 | |||
4557000629 | |||
78997e1e5a | |||
4d5564e8d4 | |||
11d89adc4b |
4
.gitignore
vendored
4
.gitignore
vendored
@ -15,8 +15,6 @@ node_modules/
|
|||||||
|
|
||||||
# builds
|
# builds
|
||||||
dist/
|
dist/
|
||||||
dist_web/
|
dist_*/
|
||||||
dist_serve/
|
|
||||||
dist_ts_web/
|
|
||||||
|
|
||||||
# custom
|
# custom
|
@ -24,13 +24,14 @@ mirror:
|
|||||||
- docker
|
- docker
|
||||||
- notpriv
|
- notpriv
|
||||||
|
|
||||||
snyk:
|
audit:
|
||||||
image: registry.gitlab.com/hosttoday/ht-docker-node:snyk
|
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 --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=moderate
|
||||||
tags:
|
tags:
|
||||||
- lossless
|
- lossless
|
||||||
- docker
|
- docker
|
||||||
|
2226
package-lock.json
generated
2226
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
25
package.json
25
package.json
@ -1,34 +1,39 @@
|
|||||||
{
|
{
|
||||||
"name": "@pushrocks/websetup",
|
"name": "@pushrocks/websetup",
|
||||||
"version": "2.0.4",
|
"version": "2.0.14",
|
||||||
"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 --web)",
|
"build": "(tsbuild --web && npm run bundle)",
|
||||||
"format": "(gitzone format)"
|
"format": "(gitzone format)",
|
||||||
|
"bundle": "tsbundle --production --from ./ts/index.ts --to ./dist_bundle/bundle.js"
|
||||||
},
|
},
|
||||||
"keywords": [
|
"keywords": [
|
||||||
"lossless",
|
"lossless",
|
||||||
"websafe"
|
"websafe"
|
||||||
],
|
],
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@gitzone/tsbuild": "^2.1.17",
|
"@gitzone/tsbuild": "^2.1.22",
|
||||||
|
"@gitzone/tsbundle": "^1.0.57",
|
||||||
"@gitzone/tstest": "^1.0.28",
|
"@gitzone/tstest": "^1.0.28",
|
||||||
"@pushrocks/tapbundle": "^3.2.0",
|
"@pushrocks/tapbundle": "^3.2.1",
|
||||||
"tslint": "^6.0.0",
|
"tslint": "^6.1.0",
|
||||||
"tslint-config-prettier": "^1.15.0"
|
"tslint-config-prettier": "^1.15.0"
|
||||||
},
|
},
|
||||||
"dependencies": {},
|
"dependencies": {
|
||||||
|
"@tsclass/tsclass": "^3.0.12"
|
||||||
|
},
|
||||||
"files": [
|
"files": [
|
||||||
"ts/**/*",
|
"ts/**/*",
|
||||||
"ts_web/**/*",
|
"ts_web/**/*",
|
||||||
"dist/**/*",
|
"dist/**/*",
|
||||||
"dist_web/**/*",
|
"dist_*/**/*",
|
||||||
|
"dist_ts/**/*",
|
||||||
"dist_ts_web/**/*",
|
"dist_ts_web/**/*",
|
||||||
"assets/**/*",
|
"assets/**/*",
|
||||||
"cli.js",
|
"cli.js",
|
||||||
|
@ -18,6 +18,10 @@ setup basic page properties
|
|||||||
|
|
||||||
## Usage
|
## Usage
|
||||||
|
|
||||||
|
## 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
|
## Contribution
|
||||||
|
|
||||||
|
101
ts/meta/index.ts
101
ts/meta/index.ts
@ -1,29 +1,122 @@
|
|||||||
|
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;
|
||||||
|
ldProduct?: any;
|
||||||
}
|
}
|
||||||
|
|
||||||
export const setupMetaInformation = async (metaObjectArg: IMetaObject) => {
|
export const setupMetaInformation = async (metaObjectArg: IMetaObject) => {
|
||||||
document.title = metaObjectArg.title;
|
document.title = metaObjectArg.title;
|
||||||
addMetaTag('description', metaObjectArg.description);
|
addMetaTag('description', metaObjectArg.description);
|
||||||
addMetaTag('google', 'notranslate');
|
addMetaTag('google', 'notranslate');
|
||||||
addMetaTag('revisited-after', '1 days');
|
addMetaTag('revisit-after', '1 days');
|
||||||
metaObjectArg.canonicalDomain ? addLinkTag('canonical', metaObjectArg.canonicalDomain) : null;
|
metaObjectArg.canonicalDomain ? addLinkTag('canonical', metaObjectArg.canonicalDomain) : null;
|
||||||
|
|
||||||
|
if (metaObjectArg.ldCompany) {
|
||||||
|
addCompanyInfo(metaObjectArg.ldCompany);
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
const addMetaTag = async (linkNameArg: string, contentArg: string) => {
|
const addMetaTag = async (metaNameArg: string, contentArg: string) => {
|
||||||
const metaElement = document.createElement('meta');
|
const metaElement = document.createElement('meta');
|
||||||
metaElement.name = linkNameArg;
|
metaElement.name = metaNameArg;
|
||||||
metaElement.content = contentArg;
|
metaElement.content = contentArg;
|
||||||
document.getElementsByTagName('head')[0].appendChild(metaElement);
|
document.getElementsByTagName('head')[0].appendChild(metaElement);
|
||||||
};
|
};
|
||||||
|
|
||||||
const addLinkTag = async (relArg, hrefArg) => {
|
const addLinkTag = async (relArg, hrefArg): Promise<Element> => {
|
||||||
const link = !!document.querySelector("link[rel='canonical']")
|
const link = !!document.querySelector("link[rel='canonical']")
|
||||||
? document.querySelector("link[rel='canonical']")
|
? document.querySelector("link[rel='canonical']")
|
||||||
: document.createElement('link');
|
: document.createElement('link');
|
||||||
link.setAttribute('rel', relArg);
|
link.setAttribute('rel', relArg);
|
||||||
link.setAttribute('href', hrefArg);
|
link.setAttribute('href', hrefArg);
|
||||||
document.head.appendChild(link);
|
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"].');
|
||||||
|
@ -1,2 +1,3 @@
|
|||||||
const removeme = {};
|
import * as tsclass from '@tsclass/tsclass';
|
||||||
export { removeme };
|
|
||||||
|
export { tsclass };
|
||||||
|
Reference in New Issue
Block a user