diff --git a/projects/sampleBlog/src/app/app.component.html b/projects/sampleBlog/src/app/app.component.html
index a1a440888..5aa52aae3 100644
--- a/projects/sampleBlog/src/app/app.component.html
+++ b/projects/sampleBlog/src/app/app.component.html
@@ -1,5 +1,5 @@
- Scully demo blog app!
+ Scully demo blog app! {{currentState}}
🏠
diff --git a/projects/sampleBlog/src/app/app.component.ts b/projects/sampleBlog/src/app/app.component.ts
index 8932f84c8..af8ea21a4 100644
--- a/projects/sampleBlog/src/app/app.component.ts
+++ b/projects/sampleBlog/src/app/app.component.ts
@@ -1,5 +1,5 @@
import {Component} from '@angular/core';
-import { IdleMonitorService } from '@scullyio/ng-lib';
+import {IdleMonitorService, isScullyGenerated, isScullyRunning} from '@scullyio/ng-lib';
@Component({
selector: 'app-root',
@@ -7,6 +7,10 @@ import { IdleMonitorService } from '@scullyio/ng-lib';
styleUrls: ['./app.component.css'],
})
export class AppComponent {
- title = 'sampleBlog';
+ currentState = isScullyRunning()
+ ? 'rendering inside scully'
+ : isScullyGenerated()
+ ? 'Loaded from static HTML'
+ : 'SPA mode';
constructor(private idle: IdleMonitorService) {}
}
diff --git a/projects/scullyio/ng-lib/package.json b/projects/scullyio/ng-lib/package.json
index c29beff60..7b9cc203e 100644
--- a/projects/scullyio/ng-lib/package.json
+++ b/projects/scullyio/ng-lib/package.json
@@ -1,6 +1,6 @@
{
"name": "@scullyio/ng-lib",
- "version": "0.0.5",
+ "version": "0.0.6",
"repository": {
"type": "GIT",
"url": "https://github.com/scullyio/scully/tree/master/projects/scullyio/ng-lib"
diff --git a/projects/scullyio/ng-lib/src/lib/utils/isScully.ts b/projects/scullyio/ng-lib/src/lib/utils/isScully.ts
new file mode 100644
index 000000000..5140aff6a
--- /dev/null
+++ b/projects/scullyio/ng-lib/src/lib/utils/isScully.ts
@@ -0,0 +1,3 @@
+// tslint:disable: no-string-literal
+export const isScullyRunning = () => window && window['ScullyIO'] === 'running';
+export const isScullyGenerated = () => window && window['ScullyIO'] === 'generated';
diff --git a/projects/scullyio/ng-lib/src/public-api.ts b/projects/scullyio/ng-lib/src/public-api.ts
index cd7638cfb..645f07518 100644
--- a/projects/scullyio/ng-lib/src/public-api.ts
+++ b/projects/scullyio/ng-lib/src/public-api.ts
@@ -5,5 +5,6 @@
export * from './lib/components.module';
export * from './lib/idleMonitor/idle-monitor.service';
export * from './lib/route-service/scully-routes.service';
-export * from './lib/scully-content/scully-content.component'
+export * from './lib/scully-content/scully-content.component';
+export * from './lib/utils/isScully'
diff --git a/scully/renderPlugins/puppeteerRenderPlugin.ts b/scully/renderPlugins/puppeteerRenderPlugin.ts
index 06e50ec94..adf2aa668 100644
--- a/scully/renderPlugins/puppeteerRenderPlugin.ts
+++ b/scully/renderPlugins/puppeteerRenderPlugin.ts
@@ -1,3 +1,4 @@
+// tslint:disable: no-string-literal
// const puppeteer = require('puppeteer');
import {Browser, Page} from 'puppeteer';
import {HandledRoute} from '../routerPlugins/addOptionalRoutesPlugin';
@@ -26,8 +27,13 @@ export const puppeteerRender = async (route: HandledRoute): Promise => {
/** Inject this into the running page, runs in browser*/
await page.evaluateOnNewDocument(() => {
+ /** set "running" mode */
+ window['ScullyIO'] = 'running';
window.addEventListener('AngularReady', () => {
- // setTimeout(() => window['onCustomEvent'](),10000);
+ /** add a small script tag to set "generated" mode */
+ const d = document.createElement('script');
+ d.innerHTML = `window['ScullyIO']='generated';`;
+ document.head.appendChild(d);
window['onCustomEvent']();
});
});
@@ -35,7 +41,7 @@ export const puppeteerRender = async (route: HandledRoute): Promise => {
// enter url in page
await page.goto(path);
- await Promise.race([pageReady, waitForIt(25 * 1000)] );
+ await Promise.race([pageReady, waitForIt(25 * 1000)]);
/**
* The stange notation is needed bcs typescript messes
diff --git a/scully/utils/validateConfig.ts b/scully/utils/validateConfig.ts
index 344bbe72a..3d4908ea1 100644
--- a/scully/utils/validateConfig.ts
+++ b/scully/utils/validateConfig.ts
@@ -51,7 +51,7 @@ export async function validateConfig(config: ScullyConfig) {
})
);
} else {
- logWarn('No routes defined in "scully.config"');
+ logWarn('No routes defined in "scully.config.js "');
}
if (hasErrors) {
/** stop everything if there are errors in the config. */