UNPKG

libre

Version:
41 lines (30 loc) 977 B
import React, {Component} from 'react'; import _ from 'lodash'; import {StaticRouter, Route, Switch} from 'react-router'; export default class SEO extends Component { constructor(props) { super(props); this.og = props.og; } render() { const props = _.extend({user: null}, this.props); const App = this.props.app; const routes = this.props.routes; return ( <StaticRouter context={{}} location={this.props.location}> <Route render={(r) => ( <App {...props} {...r} og={this.og}> <Switch> {Object.keys(routes).map(key => this.renderRoute(key, routes[key]) )} </Switch> </App> )}/> </StaticRouter> ); } renderRoute(key, route) { const routeProps = {exact: key === '/', key, path: key}; const Component = route.component; return <Route {...routeProps} render={(r) => <Component {...r} libre={this.props.libre} og={this.og} /> } /> } }