-
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.
fix all components to use helmet directly, update example to use serv…
…er side rendering, update readme
- Loading branch information
Jim Skerritt
committed
Nov 27, 2018
1 parent
b4c85d6
commit 9d92e35
Showing
13 changed files
with
197 additions
and
984 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,3 @@ | ||
module.exports = { | ||
presets: ['@babel/preset-env', '@babel/preset-react'], | ||
plugins: ['react-hot-loader/babel'] | ||
presets: ['@babel/preset-env', '@babel/preset-react'] | ||
}; |
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 |
---|---|---|
@@ -1,14 +1,30 @@ | ||
import React, { Fragment } from 'react'; | ||
import { hot } from 'react-hot-loader'; | ||
import Helmet from 'react-helmet'; | ||
import React from 'react'; | ||
import { Ads, Favicons, Gtm, WebFont } from '../src/lib'; | ||
|
||
const App = () => ( | ||
<Fragment> | ||
<Helmet> | ||
<title>Hello World</title> | ||
</Helmet> | ||
<div>Hello World</div> | ||
</Fragment> | ||
<div className="example-app" style={{ fontFamily: 'Roboto, sans-serif', fontSize: '32px' }}> | ||
<Ads | ||
slots={[{ | ||
networkCode: '123456', | ||
name: 'Test_100x100', | ||
width: 100, | ||
height: 100, | ||
elementId: 'testAd' | ||
}]} | ||
/> | ||
<Favicons | ||
favicons={[{ | ||
href: 'favicon-96x96.png', | ||
sizes: '96x96', | ||
type: 'image/png' | ||
}]} | ||
/> | ||
<Gtm containerId="abc123" /> | ||
<WebFont | ||
families={[{ fontName: 'Roboto', weights: [300, 400, 700, 900] }]} | ||
/> | ||
Inspect this page to see beret's rendered elements. | ||
</div> | ||
); | ||
|
||
export default hot(module)(App); | ||
export default App; |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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 |
---|---|---|
@@ -1,5 +1,33 @@ | ||
import React from 'react'; | ||
import { render } from 'react-dom'; | ||
import App from './App'; | ||
require('@babel/register')({ | ||
presets: ['@babel/preset-env', '@babel/preset-react'] | ||
}); | ||
|
||
render(<App />, document.getElementById('app')); | ||
const fs = require('fs'); | ||
const path = require('path'); | ||
const React = require('react'); | ||
const ReactDOMServer = require('react-dom/server'); | ||
const Helmet = require('react-helmet').default; | ||
const App = require('./App').default; | ||
|
||
console.log('rendering example server side react...'); | ||
|
||
const content = ReactDOMServer.renderToString(React.createElement(App)); | ||
const helmet = Helmet.renderStatic(); | ||
|
||
const html = `<!doctype html> | ||
<html lang="en"> | ||
<head> | ||
<meta http-equiv="x-ua-compatible" content="IE=edge"/> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0"/> | ||
<title>beret example</title> | ||
${helmet.link.toString()} | ||
${helmet.script.toString()} | ||
</head> | ||
<body> | ||
${content} | ||
</body> | ||
</html>`; | ||
|
||
fs.writeFileSync(path.join(__dirname, 'index.html'), html); | ||
|
||
console.log('done! open examples/index.html to view'); |
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
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
Oops, something went wrong.