Compare commits
4 Commits
Author | SHA1 | Date | |
---|---|---|---|
74d73a0d21 | |||
5496c8c482 | |||
c748c5102c | |||
308133fe4f |
2
package-lock.json
generated
2
package-lock.json
generated
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@pushrocks/websetup",
|
"name": "@pushrocks/websetup",
|
||||||
"version": "1.0.7",
|
"version": "2.0.0",
|
||||||
"lockfileVersion": 1,
|
"lockfileVersion": 1,
|
||||||
"requires": true,
|
"requires": true,
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@pushrocks/websetup",
|
"name": "@pushrocks/websetup",
|
||||||
"version": "1.0.7",
|
"version": "2.0.0",
|
||||||
"private": false,
|
"private": false,
|
||||||
"description": "setup basic page properties",
|
"description": "setup basic page properties",
|
||||||
"main": "dist/index.js",
|
"main": "dist/index.js",
|
||||||
|
22
ts/index.ts
22
ts/index.ts
@ -2,36 +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 { setupServiceWoker } from './serviceworker';
|
|
||||||
import { IMetaObject, setupMetaInformation } from './meta';
|
import { IMetaObject, setupMetaInformation } from './meta';
|
||||||
|
|
||||||
export interface IWebSetupConstructorOptions {
|
export interface IWebSetupConstructorOptions {
|
||||||
googleAnalyticsCode?: string;
|
googleAnalyticsCode?: string;
|
||||||
fsCode?: string;
|
fsCode?: string;
|
||||||
metaObject: IMetaObject;
|
metaObject: IMetaObject;
|
||||||
serviceworker?: boolean;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* the main WebSetup class
|
* the main WebSetup class
|
||||||
*/
|
*/
|
||||||
export class WebSetup {
|
export class WebSetup {
|
||||||
|
public options: IWebSetupConstructorOptions;
|
||||||
constructor(optionsArg: IWebSetupConstructorOptions) {
|
constructor(optionsArg: IWebSetupConstructorOptions) {
|
||||||
// most important, lets get the meta information in place
|
this.options = optionsArg;
|
||||||
this.setup(optionsArg);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
async setup(optionsArg: IWebSetupConstructorOptions) {
|
public async setup() {
|
||||||
if (optionsArg.serviceworker) {
|
await setupMetaInformation(this.options.metaObject);
|
||||||
await setupServiceWoker();
|
|
||||||
|
if (this.options.googleAnalyticsCode) {
|
||||||
|
await setupGoogleAnalytics(this.options.googleAnalyticsCode);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (optionsArg.googleAnalyticsCode) {
|
if (this.options.fsCode) {
|
||||||
await setupGoogleAnalytics(optionsArg.googleAnalyticsCode);
|
await setupFullStory(this.options.fsCode);
|
||||||
}
|
|
||||||
|
|
||||||
if (optionsArg.fsCode) {
|
|
||||||
await setupFullStory(optionsArg.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