包详细信息

apeman-react-head

apeman react package for head component.

React, apeman, react-component, head

自述文件

apeman-react-head

Build Status Code Climate Code Coverage npm Version JS Standard

apeman react package for head component.

Installation

$ npm install apeman-react-head --save

Usage

Render head tag with meta tags.

'use strict'

import React from 'react'
import {ApHead} from 'apeman-react-head'

const ExampleComponent = React.createClass({
  render() {
    return (
      <html>
      <ApHead charset="utf-8"
              title='foo'
              icon='./favicon.png'
              meta={ {'description': 'This is description.'} }
              version='1.0.0'
              css={ ['css/lib.css', 'css/app.css'] }
              js={ ['js/lib.js', 'js/app.js'] }
              globals={ {
                appProps: {/* ... */}
            } }
      >
        <meta name="example-child-elm"/>
      </ApHead>
      <body>
      </body>
      </html>
    )
  }
})

Results like:

<!DOCTYPE html>
<html>
<head class="ap-head">
    <meta class="ap-head-meta" charset="utf-8"/>
    <title class="ap-head-title">foo</title>
    <meta name="description" content="This is description."/>
    <link rel="icon" href="./favicon.png?v=1.0.0"/>
    <script type="text/js" src="js/lib.js?v=1.0.0"></script>
    <script type="text/js" src="js/app.js?v=1.0.0"></script>
    <link rel="stylesheet" type="text/css" href="css/lib.css?v=1.0.0"/>
    <link rel="stylesheet" type="text/css" href="css/app.css?v=1.0.0"/>

    <meta name="example-child-elm"/>
</head>
</html>

Components

ApHead

Props

Name Type Default Description
charSet string 'utf-8' CharSet
title string Document Title
icon string Favicon
meta arrayOf object Meta data
itemProps arrayOf object Micro data settings
css array CSS file urls
js array JS file urls
version string 'unknown' Version string
versionKey string 'v' Query string key for version
globals object Global variables
viewPort object {

width: 'device-width', initialScale: '1.0' } | | View port settings | | base | string | null | | Base url | | baseTarget | string | undefined | | Target of base url. '_blank', '_parent', '_self', '_top' or frame name | | manifest | string | | | Path of manifest.json | | color | string | | | Theme color |

Props

Name Type Default Description
charset string null Charset value.
title string null Title value.
icon string null Favicon file path.
meta object null Meta values.
css array null Css file urls.
js array null Js file urls.
version string 'unknown' Version number.
versionKey string 'v' Key of version in query string.

License

This software is released under the MIT License.

Links