/**
 * Main entry point for the Styleguide Client
 */

import React from 'react';
import ReactDOM from 'react-dom';
import {
  Route,
  Router,
  hashHistory,
} from 'react-router';
import ComponentPreview from './components/ComponentPreview';
import App from './components/App';
const styleguideClientApi = window.STYLEGUIDE_PLUGIN_CLIENT_API;

// Generate a view for every component
const routeViews = {};
Object.keys(styleguideClientApi.scripts).forEach((componentPath) => {
  routeViews[componentPath] = () => (
    <ComponentPreview
      path={componentPath}
    />
  );
});

// Generate a route for every view
const routes = Object.keys(routeViews)
    .map((componentPath) => (
      <Route
        key={componentPath}
        path={componentPath}
        component={routeViews[componentPath]}
      />
    ));

ReactDOM.render(
  <Router history={hashHistory}>
    <Route path="/" component={App}>
      {routes}
    </Route>
  </Router>,
  document.getElementById('styleguide-root')
);

@@ -273,16 +273,95 @@
 s/App';%0A
+import mapValues from 'lodash/mapValues';%0Aimport values from 'lodash/values';%0A%0A
 const st
@@ -472,30 +472,27 @@
 oute
-Views = %7B%7D;%0AObject.key
+s = values(mapValue
 s(st
@@ -520,227 +520,18 @@
 ipts
-).forEach((componentPath) =%3E %7B%0A  routeViews%5BcomponentPath%5D = () =%3E (%0A    %3CComponentPreview%0A      path=%7BcomponentPath%7D%0A    /%3E%0A  );%0A%7D);%0A%0A// Generate a route for every view%0Aconst routes = Object.keys(routeViews)%0A    .map((
+, (value, 
 comp
@@ -546,20 +546,16 @@
 h) =%3E (%0A
-    
   %3CRoute
@@ -555,20 +555,16 @@
  %3CRoute%0A
-    
     key=
@@ -575,28 +575,24 @@
 ponentPath%7D%0A
-    
     path=%7Bco
@@ -608,20 +608,16 @@
 th%7D%0A    
- 
-   
 componen
@@ -623,19 +623,38 @@
 nt=%7B
-routeViews%5B
+() =%3E %3CComponentPreview path=%7B
 comp
@@ -666,24 +666,20 @@
 Path
-%5D%7D%0A    
+%7D /%3E%7D%0A
   /%3E%0A
-    
+)
 ));%0A

refactor client