Files
shields/frontend/render-badge-examples.js
T
Paul MelnikowandThaddée Tyl a2f5cbb03a Push frontend to production servers at /index.html (#1222)
* Push frontend to production servers at /index.html

Local production builds will use local server instead of img.shields.io, to support local testing

* Restore https://img.shields.io to example URIs
2017-11-01 20:48:01 +01:00

23 lines
869 B
JavaScript

'use strict';
const fs = require('fs');
const path = require('path');
const envFlag = require('node-env-flag');
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 baseUri = process.env.BASE_URL;
const isProductionBuild = envFlag(process.env.PRODUCTION_BUILD, false);
const fragment = ReactDOMServer.renderToStaticMarkup(
<BadgeExamples examples={badgeExampleData} {...{baseUri, isProductionBuild}} />);
const outputPath = path.join(__dirname, '..', 'build', 'badge-examples-fragment.html');
fs.writeFileSync(outputPath, pretty(fragment));