forked from xpepermint/isomorphic-react-relay-boilerplate
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
app title and meta tags with react-helmet
- Loading branch information
1 parent
50c8ab8
commit b6a24a0
Showing
4 changed files
with
54 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
React does not handle the page title and meta tags. We will use the power of the [react-helmet](https://github.com/nfl/react-helmet) package. | ||
|
||
Start by installing the dependencies. | ||
|
||
``` | ||
npm install --save react-helmet | ||
``` | ||
|
||
Put the `<Helmet/>` tag inside components. | ||
|
||
```js | ||
// app/components/App | ||
... | ||
import Helmet from "react-helmet"; | ||
|
||
let App = React.createClass({ | ||
render() { | ||
return ( | ||
<div> | ||
<Helmet title="App" /> | ||
... | ||
</div> | ||
) | ||
} | ||
}); | ||
... | ||
``` | ||
|
||
Open `app/server.js` and upgrade the server-side logic. | ||
|
||
```js | ||
import Helmet from 'react-helmet'; | ||
... | ||
let markup = renderToString(...); | ||
let helmet = Helmet.rewind(); | ||
let html = [ | ||
... | ||
`<head>`, | ||
`<title>${helmet.title}</title>`, | ||
helmet.meta, | ||
helmet.link, | ||
... | ||
`</head>`, | ||
... | ||
].join(''); | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters