react-helmet-with-visor
DefinitelyTyped icon, indicating that this package has TypeScript declarations provided by the separate @types/react-helmet-with-visor package

5.4.2 • Public • Published

React Helmet With Visor

Fork of the famous react-helmet v5 library with the goal to inject SEO-like scripts at runtime. For main documentation, please refer to original repository (https://github.com/nfl/react-helmet). One of the possible issues it can solve: https://github.com/nfl/react-helmet/issues/323 . The plans are marge it back to react-helmet repository as soon as possible, if they would like to accept our PR. Unfortanat

Unfortunately, for technical reasons, HelmetsOpenedVisor doesn't support toComponent functionality and no full support for PhantomJS browser.

Example

import React from "react";
import {Helmet} from "react-helmet";
 
class Application extends React.Component {
  render () {
    return (
        <div className="application">
            <Helmet>
                <meta charSet="utf-8" />
                <title>My Title</title>
                <link rel="canonical" href="http://mysite.com/example" />
                <HelmetsOpenedVisor>
                {`<script>
                        !function (f, b, e, v, n, t, s) {
                            if (f.fbq) return; n = f.fbq = function () {
                                n.callMethod ?
                                    n.callMethod.apply(n, arguments) : n.queue.push(arguments)
                            };
                            if (!f._fbq) f._fbq = n; n.push = n; n.loaded = !0; n.version = \'2.0\';
                            n.queue = []; t = b.createElement(e); t.async = !0;
                            t.src = v; s = b.getElementsByTagName(e)[0];
                            s.parentNode.insertBefore(t, s)
                        }(window, document, \'script\',
                            \'https://connect.facebook.net/en_US/fbevents.js\');
                        fbq(\'init\'\'*************\');
                        fbq(\'track\'\'PageView\');
                    </script><noscript>
                            &lt;img height="1" width="1" style="display:none"
                                    src="https://www.facebook.com/tr?id=************&amp;ev=PageView&amp;noscript=1"/&gt;
                    </noscript>`}
                </HelmetsOpenedVisor>
            </Helmet>
            ...
        </div>
    );
  }
};

As string output

const html = `
    <!doctype html>
    <html ${helmet.htmlAttributes.toString()}>
        <head>
            ${helmet.title.toString()}
            ${helmet.meta.toString()}
            ${helmet.link.toString()}
            ${helmet.openedVisor.toString()}
        </head>
        <body ${helmet.bodyAttributes.toString()}>
            <div id="content">
                // React stuff here
            </div>
        </body>
    </html>
`;

Versions

Current Tags

  • Version
    Downloads (Last 7 Days)
    • Tag
  • 5.4.2
    19
    • latest

Version History

Package Sidebar

Install

npm i react-helmet-with-visor

Weekly Downloads

17

Version

5.4.2

License

MIT

Unpacked Size

554 kB

Total Files

18

Last publish

Collaborators

  • nikolai.kulikov.dev