How to use react-helmet - 10 common examples

To help you get started, we’ve selected a few react-helmet examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github geotrev / undernet / app / components / SetMeta / __tests__ / SetMeta.spec.js View on Github external
it("creates correct 404 meta and title data", () => {
      // Given
      const meta = [
        { name: "description", content: "" },
        { name: "prerender-status-code", content: "404" },
      ]
      const title = "Page Not Found"
      const links = []
      wrapper = mount()
      // Then
      expect(Helmet.peek().metaTags).toEqual(meta)
      expect(Helmet.peek().linkTags).toEqual(links)
      expect(Helmet.peek().title).toEqual(titleTemplate(title))
    })
  })
github geotrev / undernet / app / components / SetMeta / __tests__ / SetMeta.spec.js View on Github external
it("creates correct meta, link, and title data", () => {
      // Given
      const meta = [{ name: "description", content: "Test description" }]
      const title = "Test title"
      const links = [{ rel: "canonical", href: jestConfig.testURL }]
      wrapper = mount()
      // Then
      expect(Helmet.peek().metaTags).toEqual(meta)
      expect(Helmet.peek().linkTags).toEqual(links)
      expect(Helmet.peek().title).toEqual(titleTemplate(title))
    })
github mozilla / addons-frontend / tests / server / amo / TestDetailsPage.js View on Github external
before(() => {
    // Tell helmet to run as if it's a server render.
    // This is caused by the jsdom env.
    Helmet.canUseDOM = false;
    return runTestServer({ app: 'amo' })
      .then((server) => {
        app = server;
      });
  });
github LLK / scratch-www / src / views / preview / meta.jsx View on Github external
const React = require('react');
const Helmet = require('react-helmet').default;

const projectShape = require('./projectshape.jsx').projectShape;

const Meta = props => {
    const {title, instructions, author} = props.projectInfo;

    // Do not want to render any meta tags unless all the info is loaded
    // Check only author (object) because it is ok to have empty string instructions
    if (!author) return null;

    const truncatedInstructions = instructions.split(' ')
        .slice(0, 50)
        .join(' ');

    return (
github Nebo15 / annon.web / app / server / page.js View on Github external
.then(() => {
        const reduxState = escape(JSON.stringify(getState()));
        const css = new Set();
        /* eslint-disable no-underscore-dangle */
        const html = ReactDOMServer.renderToString(
           { css.add(styles._getCss()); }}>
            
              { }
            
          
        );
        const head = Helmet.rewind();
        res.render('index', {
          html,
          reduxState,
          inlineCss: arrayFrom(css).join(''),
          head,
          isMobile,
        });
      })
      .catch(err => next(err));
github lifechurch / melos / feature-server.js View on Github external
getRenderProps(feature, params.url).then(nr.createTracer('getRenderProps', (renderProps) => {
						let html = null
						try {
							html = renderToString()
						} catch (ex) {
								// throw new Error(`Error: 3 - Could Not Render ${feature} view`, ex)
							Raven.captureException(ex)
							nr.endTransaction()
							res.status(500).send({ error: 3, message: `Could Not Render ${feature} view`, ex, stack: ex.stack })
						}

						const initialState = Object.assign({}, startingState, store.getState(), { hosts: { nodeHost: getNodeHost(req), railsHost: params.railsHost } })

						let head = Helmet.rewind()

						head = {
							base: head.base.toString(),
							meta: head.meta.toString(),
							link: head.link.toString(),
							title: head.title.toString(),
							script: head.script.toString()
						}

							// for lookinside stuff
						let referrer = null
						if (params.referrer) {
							referrer = params.referrer
						}

						res.setHeader('Cache-Control', 'public')
github reactGo / reactGo / app / components / Meta.jsx View on Github external
// in development mode
if (__DEVSERVER__) {
  config.link = config.link.filter(l => l.rel !== 'stylesheet');
}

const Meta = () => (
  
)


ReactDOMServer.renderToString();
const header = Helmet.rewind();

export default header;
github LearningLocker / learninglocker / ui / src / components / Html / index.js View on Github external
const html = ({
  protocol, // http or https
  style, // raw styles to be embedded directly into the document
  scripts, // scripts to be linked in the document body
  state, // initial state of the client side store
  children, // output of server side route render
}) => {
  const head = Helmet.rewind();

  return (
    
      
        {head.base.toComponent()}
        {head.title.toComponent()}
        {head.meta.toComponent()}
        {head.link.toComponent()}
        {head.script.toComponent()}
        
        
        
        {style &&
github wellyshen / react-cool-starter / src / utils / renderHtmlPage.js View on Github external
export default (store: Store, htmlApp: string = '') => {
  const head = Helmet.rewind();
  const assets = webpackIsomorphicTools.assets();

  // Setup html page
  return `
    
    
      
        
        
        
        
        

        ${head.base.toString()}
        ${head.title.toString()}
        ${head.meta.toString()}
github interledger-deprecated / ilp-kit / src / helpers / Html.js View on Github external
render () {
    const {assets, component, store} = this.props
    const content = component ? ReactDOM.renderToString(component) : ''
    const helmet = Helmet.rewind()

    return (
      
        
          {helmet.base.toComponent()}
          {helmet.title.toComponent()}
          {helmet.meta.toComponent()}
          {helmet.link.toComponent()}
          {helmet.script.toComponent()}

          
          
          
          {/* styles (will be present only in production with webpack extract text plugin) */}