Add example of full-page prerendering via a custom action result

This commit is contained in:
SteveSandersonMS
2016-07-19 15:50:54 +01:00
parent edf1f88398
commit 749c7cb3ce
8 changed files with 115 additions and 4 deletions

View File

@@ -0,0 +1,17 @@
export default function (params: any): Promise<{ html: string, globals?: any }> {
return new Promise((resolve, reject) => {
// Here, you could put any logic that synchronously or asynchronously prerenders
// your SPA components. For example, see the boot-server.ts files in the Angular2Spa
// and ReactReduxSpa templates for ways to prerender Angular 2 and React components.
//
// If you wanted, you could use a property on the 'params.data' object to specify
// which SPA component or template to render.
const html = `
<h1>Hello</h1>
It works! You passed <b>${ JSON.stringify(params.data) }</b>
and are currently requesting <b>${ params.location.path }</b>`;
resolve({ html });
});
};