Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/ekoeryanto/server-push-generator
Generate HTTP/2 Server Push link headers from generated static HTML.
https://github.com/ekoeryanto/server-push-generator
firebase generator http2-push netlify server-push vuepress zeit
Last synced: 10 days ago
JSON representation
Generate HTTP/2 Server Push link headers from generated static HTML.
- Host: GitHub
- URL: https://github.com/ekoeryanto/server-push-generator
- Owner: ekoeryanto
- License: mit
- Created: 2018-09-30T14:45:02.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2018-10-02T01:23:42.000Z (over 6 years ago)
- Last Synced: 2025-02-01T02:14:23.000Z (11 days ago)
- Topics: firebase, generator, http2-push, netlify, server-push, vuepress, zeit
- Language: JavaScript
- Homepage:
- Size: 67.4 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Server Push Generator
Generate HTTP/2 Server Push link headers from generated static HTML.
## Install
```sh
npm add server-push-generator
```> You can replace npm with yarn if needed
## Usage
```js
const spg = require('server-push-generator')spg({
cwd: 'path/to/generated/html/files/dir',
urlTransformer: file => `/${file.replace(/index\.html$/, '')}`, // function to generate url from file path
contentTransformer: ({html, matches}) => html.replace('x', 'y'), // function to manipulate html string
backup: false, // default to backup when `contentTransformer` exists
raw: false, // return object[] in headers instead of string[]
})/* output
[
{
source: '/zh/guide/',
headers: [
'; rel=prefetch',
'; rel=preload; as=script',
]
}
]
*/
```## Options
All options for [globby](https://npm.im/globby) plus :
- `raw` : boolean
- default to `true`
- customize type of returned `headers` property
- `urlTransformer` : function (singleFilePath)
- `contentTransformer`: function ({html, matches}),
- `backup`: string | boolean