Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/viiees/headless-spa-prerender

Pre-render single page application states and save as static HTML pages.
https://github.com/viiees/headless-spa-prerender

Last synced: about 13 hours ago
JSON representation

Pre-render single page application states and save as static HTML pages.

Awesome Lists containing this project

README

        

# headless-spa-prerender

Pre-render single page application states and save as static HTML pages.

```bash
$ npm install headless-spa-prerender --save-dev
```

## Synopsis
`prerender(...pages: Array, destination: string, options?: Object)`

### Parameters
* `pages` \ - list of URLs to parse.
* `destination` \ - output directory.
* `options` \ - optional.
* pendingScripts \ - list of script names to load before parsing. You can also specify a part of the names (e.g. "bundle" for "bundle-1.js", "bundle-2.js", etc.).
* clearTags \ - list of tags to remove before saving. Default: `['scripts']`.
* renderTimeout \ - timeout for render page DOM before parsing. Default: 1000ms.

## Example

```js
const prerender = require('headless-spa-prerender');

const host = 'https://promonavigator.co.id';

const pageUrls = [
`${host}/about`,
`${host}/contacts`,
`${host}/faq`,
`${host}/index`,
`${host}/prices`,
`${host}/ref-land`,
];

prerender(pageUrls, './prerendered', {
pendingScripts: ['core.js', 'front-office-2.js'],
clearTags: ['script', 'iframe'],
renderTimeout: 2000
});
```

## License

[MIT License](http://en.wikipedia.org/wiki/MIT_License)