Compare commits
4 Commits
Author | SHA1 | Date | |
---|---|---|---|
269e658967 | |||
9008aca718 | |||
74d73a0d21 | |||
5496c8c482 |
@ -1,4 +1,4 @@
|
||||
# gitzone standard
|
||||
# gitzone ci_default
|
||||
image: hosttoday/ht-docker-node:npmci
|
||||
|
||||
cache:
|
||||
|
2
package-lock.json
generated
2
package-lock.json
generated
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@pushrocks/websetup",
|
||||
"version": "1.0.8",
|
||||
"version": "2.0.1",
|
||||
"lockfileVersion": 1,
|
||||
"requires": true,
|
||||
"dependencies": {
|
||||
|
14
package.json
14
package.json
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@pushrocks/websetup",
|
||||
"version": "1.0.8",
|
||||
"version": "2.0.1",
|
||||
"private": false,
|
||||
"description": "setup basic page properties",
|
||||
"main": "dist/index.js",
|
||||
@ -23,5 +23,15 @@
|
||||
"tslint": "^5.11.0",
|
||||
"tslint-config-prettier": "^1.15.0"
|
||||
},
|
||||
"dependencies": {}
|
||||
"dependencies": {},
|
||||
"files": [
|
||||
"ts/*",
|
||||
"ts_web/*",
|
||||
"dist/*",
|
||||
"dist_web/*",
|
||||
"assets/*",
|
||||
"cli.js",
|
||||
"npmextra.json",
|
||||
"readme.md"
|
||||
]
|
||||
}
|
||||
|
22
ts/index.ts
22
ts/index.ts
@ -2,38 +2,32 @@ import * as plugins from './websetup.plugins';
|
||||
|
||||
import { setupGoogleAnalytics } from './tools/ganalytics';
|
||||
import { setupFullStory } from './tools/fullstory';
|
||||
import { setupServiceWoker } from './serviceworker';
|
||||
import { IMetaObject, setupMetaInformation } from './meta';
|
||||
|
||||
export interface IWebSetupConstructorOptions {
|
||||
googleAnalyticsCode?: string;
|
||||
fsCode?: string;
|
||||
metaObject: IMetaObject;
|
||||
serviceworker?: boolean;
|
||||
}
|
||||
|
||||
/**
|
||||
* the main WebSetup class
|
||||
*/
|
||||
export class WebSetup {
|
||||
public options: IWebSetupConstructorOptions;
|
||||
constructor(optionsArg: IWebSetupConstructorOptions) {
|
||||
// most important, lets get the meta information in place
|
||||
this.setup(optionsArg);
|
||||
this.options = optionsArg;
|
||||
}
|
||||
|
||||
async setup(optionsArg: IWebSetupConstructorOptions) {
|
||||
await setupMetaInformation(optionsArg.metaObject);
|
||||
public async setup() {
|
||||
await setupMetaInformation(this.options.metaObject);
|
||||
|
||||
if (optionsArg.serviceworker) {
|
||||
await setupServiceWoker();
|
||||
if (this.options.googleAnalyticsCode) {
|
||||
await setupGoogleAnalytics(this.options.googleAnalyticsCode);
|
||||
}
|
||||
|
||||
if (optionsArg.googleAnalyticsCode) {
|
||||
await setupGoogleAnalytics(optionsArg.googleAnalyticsCode);
|
||||
}
|
||||
|
||||
if (optionsArg.fsCode) {
|
||||
await setupFullStory(optionsArg.fsCode);
|
||||
if (this.options.fsCode) {
|
||||
await setupFullStory(this.options.fsCode);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,11 +0,0 @@
|
||||
export const setupServiceWoker = async () => {
|
||||
// serviceworker
|
||||
const script = document.createElement('script');
|
||||
script.onload = () => {
|
||||
console.log(
|
||||
'Loaded Serviceworker. The serviceworker helps us with notifications and offline capabilities, so you can also read this site when your device is offline.'
|
||||
);
|
||||
};
|
||||
script.src = 'serviceworker/mainthread.js';
|
||||
document.head.appendChild(script);
|
||||
};
|
Reference in New Issue
Block a user