React Helmet无法使用Build Command

时间:2018-06-18 12:12:39

标签: reactjs react-helmet

我的布局文件中有以下内容来呈现元数据。当我运行build命令时,我注意到它并没有在index.html中创建这个信息。所以标题的信息是默认的标题=" React App" 。

我在这里想要在构建中渲染这个是什么?

import React from 'react'
import PropTypes from 'prop-types'
import Helmet from 'react-helmet'

import Site from './layout/Site'
import Header from './layout/Header'
import Content from './layout/Content'
import Footer from './layout/Footer'
import Router from './layout/Router'

const Layout = ({ children }) => (

  <Site>
    <Helmet
      title="Site name"
      meta={[
        { name: 'description', content: 'Site description goes here.' },
        { name: 'keywords', content: 'content, goes, here' },
        { name: 'msapplication-TileColor', content: '#ff4e35' },
        { name: 'theme-color', content: '#ffffff' }
      ]}
      script={[
        { 'src': ''},
      ]}
      link={[
        {'rel':'apple-touch-icon', 'size': '180x180', 'href': 'appleIcon'},
        {'rel':'icon', 'type': 'image/png', 'size': '32x32', 'href': 'icon32'},
        {'rel':'icon', 'type': 'image/png', 'size': '16x16', 'href': 'icon16'},
        {'rel':'manifest', 'href': 'webmanifest'},
        {'rel':'mask-icon', 'href': 'safari'}
      ]}
    />


        <header className="stuckinmud">
          <Header />
        </header>


        <Content>
          <Router />
        </Content>
        <Footer />


  </Site>
)

Layout.propTypes = {
  children: PropTypes.func,
}

export default Layout

0 个答案:

没有答案