Skip to content

Instantly share code, notes, and snippets.

@chrisui
Created April 14, 2016 12:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save chrisui/7df5579bcff7a3a1692f89bf8425b074 to your computer and use it in GitHub Desktop.
Save chrisui/7df5579bcff7a3a1692f89bf8425b074 to your computer and use it in GitHub Desktop.
Redocs Playground
/* global MATCH_COMPONENTS */
import React from 'react';
import ReactDOM from 'react-dom';
import 'styles/master.css';
import Playground from 'redocs/lib/playground/components/playground';
const reqCoreManifests = require.context('./core/components', true, MATCH_COMPONENTS);
const reqAthenaManifests = require.context('./athena/components', true, MATCH_COMPONENTS);
const reqHeraManifests = require.context('./hera/components', true, MATCH_COMPONENTS);
const reqHermesManifests = require.context('./hermes/components', true, MATCH_COMPONENTS);
const reqAphroditeManifests = require.context('./aphrodite/components', true, MATCH_COMPONENTS);
const manifestModules = [].concat(
reqCoreManifests.keys().map(reqCoreManifests),
reqAthenaManifests.keys().map(reqAthenaManifests),
reqHeraManifests.keys().map(reqHeraManifests),
reqHermesManifests.keys().map(reqHermesManifests),
reqAphroditeManifests.keys().map(reqAphroditeManifests),
);
const componentManifests = manifestModules
// normalise modules to just look at manifests
.map(module => module.default)
// ensure docs are parsed json
.map(manifest => ({...manifest, docs: JSON.parse(manifest.docs)}));
const playground = (
<Playground manifests={componentManifests} />
);
ReactDOM.render(playground, document.getElementById('root'));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment