Files
shields/frontend/render-badge-examples.js
T
Paul MelnikowandGitHub b411f08ad1 Generate badge examples from data + code (#1163)
This pull request sets us up to generate the badge examples dynamically from data and code.

Right now, try.html is still checked in, mostly for the benefit of reading this diff, though it should be removed on the next pass to avoid unnecessary complexity at merge time.
2017-10-20 17:33:12 -04:00

19 lines
682 B
JavaScript

'use strict';
const fs = require('fs');
const path = require('path');
const React = require('react');
const ReactDOMServer = require('react-dom/server');
const pretty = require('pretty');
const BadgeExamples = require('./badge-examples');
// const inputPath = path.join(__dirname, '..', 'all-badges.json');
// const badgeExampleData = JSON.parse(fs.readFileSync(inputPath));
const badgeExampleData = require('../lib/all-badge-examples');
const fragment = ReactDOMServer.renderToStaticMarkup(
<BadgeExamples examples={badgeExampleData} />);
const outputPath = path.join(__dirname, '..', 'build', 'badge-examples-fragment.html');
fs.writeFileSync(outputPath, pretty(fragment));