Compare commits
4 Commits
Author | SHA1 | Date | |
---|---|---|---|
f5f51ac1a6 | |||
eb4a4288ed | |||
56bcfcdae4 | |||
50b33a5f88 |
2
package-lock.json
generated
2
package-lock.json
generated
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@pushrocks/websetup",
|
"name": "@pushrocks/websetup",
|
||||||
"version": "1.0.3",
|
"version": "1.0.5",
|
||||||
"lockfileVersion": 1,
|
"lockfileVersion": 1,
|
||||||
"requires": true,
|
"requires": true,
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@pushrocks/websetup",
|
"name": "@pushrocks/websetup",
|
||||||
"version": "1.0.3",
|
"version": "1.0.5",
|
||||||
"private": false,
|
"private": false,
|
||||||
"description": "setup basic page properties",
|
"description": "setup basic page properties",
|
||||||
"main": "dist/index.js",
|
"main": "dist/index.js",
|
||||||
@ -12,6 +12,10 @@
|
|||||||
"build": "(tsbuild)",
|
"build": "(tsbuild)",
|
||||||
"format": "(gitzone format)"
|
"format": "(gitzone format)"
|
||||||
},
|
},
|
||||||
|
"keywords": [
|
||||||
|
"lossless",
|
||||||
|
"websafe"
|
||||||
|
],
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@gitzone/tsbuild": "^2.0.22",
|
"@gitzone/tsbuild": "^2.0.22",
|
||||||
"@gitzone/tstest": "^1.0.15",
|
"@gitzone/tstest": "^1.0.15",
|
||||||
|
@ -2,7 +2,7 @@ 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();
|
||||||
|
20
ts/index.ts
20
ts/index.ts
@ -1,10 +1,15 @@
|
|||||||
import * as plugins from './websetup.plugins';
|
import * as plugins from './websetup.plugins';
|
||||||
|
|
||||||
import { setupGoogleAnalytics } from './tools/ganalytics';
|
import { setupGoogleAnalytics } from './tools/ganalytics';
|
||||||
|
import { setupFullStory } from './tools/fullstory';
|
||||||
|
import { setupServiceWoker } from './serviceworker';
|
||||||
|
import { IMetaObject, setupMetaInformation } from './meta';
|
||||||
|
|
||||||
export interface IWebSetupConstructorOptions {
|
export interface IWebSetupConstructorOptions {
|
||||||
googleAnalyticsCode?: string;
|
googleAnalyticsCode?: string;
|
||||||
fsCode?: string;
|
fsCode?: string;
|
||||||
|
metaObject: IMetaObject;
|
||||||
|
serviceworker?: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -12,12 +17,21 @@ export interface IWebSetupConstructorOptions {
|
|||||||
*/
|
*/
|
||||||
export class WebSetup {
|
export class WebSetup {
|
||||||
constructor(optionsArg: IWebSetupConstructorOptions) {
|
constructor(optionsArg: IWebSetupConstructorOptions) {
|
||||||
if (optionsArg.googleAnalyticsCode) {
|
// most important, lets get the meta information in place
|
||||||
setupGoogleAnalytics(optionsArg.googleAnalyticsCode);
|
this.setup(optionsArg);
|
||||||
|
}
|
||||||
|
|
||||||
|
async setup(optionsArg: IWebSetupConstructorOptions) {
|
||||||
|
if(optionsArg.serviceworker) {
|
||||||
|
await setupServiceWoker()
|
||||||
}
|
}
|
||||||
|
|
||||||
if () {
|
if (optionsArg.googleAnalyticsCode) {
|
||||||
|
await setupGoogleAnalytics(optionsArg.googleAnalyticsCode);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (optionsArg.fsCode) {
|
||||||
|
await setupFullStory(optionsArg.fsCode)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
18
ts/meta/index.ts
Normal file
18
ts/meta/index.ts
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
export interface IMetaObject {
|
||||||
|
title: string;
|
||||||
|
description: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
export const setupMetaInformation = async (metaObjectArg: IMetaObject) => {
|
||||||
|
document.title = metaObjectArg.title;
|
||||||
|
addMetaTag('description', metaObjectArg.description);
|
||||||
|
addMetaTag('google', 'notranslate');
|
||||||
|
addMetaTag('revisited-after', '1 days');
|
||||||
|
};
|
||||||
|
|
||||||
|
const addMetaTag = async (linkNameArg: string, contentArg: string) => {
|
||||||
|
const metaElement = document.createElement('meta');
|
||||||
|
metaElement.name = linkNameArg;
|
||||||
|
metaElement.content = contentArg;
|
||||||
|
document.getElementsByTagName('head')[0].appendChild(metaElement);
|
||||||
|
};
|
9
ts/serviceworker/index.ts
Normal file
9
ts/serviceworker/index.ts
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
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);
|
||||||
|
};
|
@ -4,13 +4,13 @@ declare global {
|
|||||||
_fs_host: any;
|
_fs_host: any;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
export const setupFullStory = async () => {
|
export const setupFullStory = async (fsCodeArg: string) => {
|
||||||
// tslint:disable-next-line: no-string-literal
|
// tslint:disable-next-line: no-string-literal
|
||||||
window['_fs_debug'] = false;
|
window['_fs_debug'] = false;
|
||||||
// tslint:disable-next-line: no-string-literal
|
// tslint:disable-next-line: no-string-literal
|
||||||
window['_fs_host'] = 'fullstory.com';
|
window['_fs_host'] = 'fullstory.com';
|
||||||
// tslint:disable-next-line: no-string-literal
|
// tslint:disable-next-line: no-string-literal
|
||||||
window['_fs_org'] = 'G6FC5';
|
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) {
|
(function(m, n, e, t, l, o, g, y) {
|
||||||
|
Reference in New Issue
Block a user