Cleanup build-site script.

This commit is contained in:
John-David Dalton
2016-07-02 09:25:45 -07:00
parent af36d2d8e5
commit 9bc8519656

View File

@@ -1,43 +1,34 @@
'use strict'; 'use strict';
const fs = require('fs'), var _ = require('lodash'),
marky = require('marky-markdown'), fs = require('fs'),
path = require('path'), marky = require('marky-markdown'),
_ = require('lodash'); path = require('path'),
util = require('../common/util');
const basePath = path.join(__dirname, '..', '..'), var basePath = path.join(__dirname, '..', '..'),
docPath = path.join(basePath, 'doc'), docPath = path.join(basePath, 'doc'),
readmePath = path.join(docPath, 'README.md'); readmePath = path.join(docPath, 'README.md');
function onComplete(error) {
if (error) {
throw error;
}
}
function build(type) { function build(type) {
let html = var html = marky(fs.readFileSync(readmePath, 'utf8'), { 'sanitize': false }),
marky(fs.readFileSync(readmePath, 'utf8'), { sanitize: false }); header = html('h1').first(),
const header = html('h1').first(); version = _.trim(header.find('span').first().text());
const version = _.trim(header.find('span').first().text());
header.remove(); header.remove();
html = html.html(); html = html.html().replace(/(<)!--\s*|\s*--(>)/g, '$1$2');
html = html.replace(/<!--\s*/g, '<');
html = html.replace(/\s*-->/g, '>');
html = [ html = [
'---', '---',
'id: docs', 'id: docs',
'layout: docs', 'layout: docs',
'title: lodash Documentation', 'title: Lodash Documentation',
`version: ${version ? version : null}`, 'version: ' + (version || null),
'---', '---',
html, html,
].join('\n'); ].join('\n');
// File output fs.writeFile(path.join(docPath, version + '.html'), html, util.pitch);
fs.writeFile(path.join(docPath, `${version}.html`), html, onComplete);
} }
build(); build();