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

https://github.com/sergeysova/node-helmet


https://github.com/sergeysova/node-helmet

generator helmet html javascript react server-rendering server-side-rendering template xml

Last synced: about 2 months ago
JSON representation

Awesome Lists containing this project

README

        

# node-helmet [![Build Status](https://travis-ci.org/sergeysova/node-helmet.svg?branch=master)](https://travis-ci.org/sergeysova/node-helmet) [![Codecov](https://img.shields.io/codecov/c/github/sergeysova/node-helmet.svg)](https://codecov.io/gh/sergeysova/node-helmet)

Construct your html for server side rendering without pain.

## Installation

```shell
npm install node-helmet
```

## Usage

```js
const { helmet, meta } = require('node-helmet')

const html = helmet()
.lang('en_US')
.class('mac')
.head(
meta.charset('utf-8'),
meta.referrer('origin'),
meta.httpEquiv('X-UA-Compatible', 'IE=edge'),
meta('google', { value: 'notranslate' }),
meta('custom-meta-name', 'content-of-meta'),
)
.title('Name of your page')
.link('icon', '/favicon/svg/32.svg', { type: 'image/svg' })
.stylesheet('/assets/bundle.css')
.stylesheet('//mycdn.com/static/resolved/foo-bar.css')
.script('/assets/bundle.js')
.inlineScript(myFunc.toString(), { nonce: key }, ['arg1', 'arg2'])

console.log(html.toString()) // or console.log(`${html}`)
```

Result document (formatted):

```html







Name of your page







(function myFunc(a, b) {
console.log('ok', a + b);
})(arg1, arg2)

```