fix(core): update
This commit is contained in:
parent
56bcfcdae4
commit
eb4a4288ed
@ -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();
|
||||||
|
17
ts/index.ts
17
ts/index.ts
@ -2,10 +2,14 @@ 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';
|
||||||
|
|
||||||
export interface IWebSetupConstructorOptions {
|
export interface IWebSetupConstructorOptions {
|
||||||
googleAnalyticsCode?: string;
|
googleAnalyticsCode?: string;
|
||||||
fsCode?: string;
|
fsCode?: string;
|
||||||
|
metaObject: IMetaObject;
|
||||||
|
serviceworker?: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -13,12 +17,21 @@ export interface IWebSetupConstructorOptions {
|
|||||||
*/
|
*/
|
||||||
export class WebSetup {
|
export class WebSetup {
|
||||||
constructor(optionsArg: IWebSetupConstructorOptions) {
|
constructor(optionsArg: IWebSetupConstructorOptions) {
|
||||||
|
// most important, lets get the meta information in place
|
||||||
|
this.setup(optionsArg);
|
||||||
|
}
|
||||||
|
|
||||||
|
async setup(optionsArg: IWebSetupConstructorOptions) {
|
||||||
|
if(optionsArg.serviceworker) {
|
||||||
|
await setupServiceWoker()
|
||||||
|
}
|
||||||
|
|
||||||
if (optionsArg.googleAnalyticsCode) {
|
if (optionsArg.googleAnalyticsCode) {
|
||||||
setupGoogleAnalytics(optionsArg.googleAnalyticsCode);
|
await setupGoogleAnalytics(optionsArg.googleAnalyticsCode);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (optionsArg.fsCode) {
|
if (optionsArg.fsCode) {
|
||||||
setupFullStory(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);
|
||||||
|
};
|
Loading…
Reference in New Issue
Block a user