Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
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.
- Host: GitHub
- URL: https://github.com/viiees/headless-spa-prerender
- Owner: ViieeS
- Created: 2018-06-10T02:27:00.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2019-09-11T12:50:42.000Z (over 5 years ago)
- Last Synced: 2025-01-10T05:21:45.772Z (about 13 hours ago)
- Language: JavaScript
- Size: 11.7 KB
- Stars: 2
- Watchers: 2
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
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)