Add comments and cleanup build-site.js.

This commit is contained in:
John-David Dalton
2016-07-06 09:42:50 -07:00
parent 6eeac45d23
commit dbbb3fbb55

View File

@@ -11,12 +11,19 @@ var basePath = path.join(__dirname, '..', '..'),
readmePath = path.join(docPath, 'README.md');
function build(type) {
var $ = marky(fs.readFileSync(readmePath, 'utf8'), { 'sanitize': false }),
// Load markddown and uncomment docdown HTML hints.
var markdown = fs
.readFileSync(readmePath, 'utf8')
.replace(/(<)!--\s*|\s*--(>)/g, '$1$2');
var $ = marky(markdown),
$header = $('h1').first().remove(),
version = _.trim($header.find('span').first().text()).slice(1);
// Remove docdown horizontal rules.
$('hr').remove();
// Remove marky-markdown additions.
$('[id^="user-content-"]')
.attr('class', null)
.attr('id', null);
@@ -26,9 +33,8 @@ function build(type) {
$a.replaceWith($a.html());
});
var html = _.trim($.html().replace(/(<)!--\s*|\s*--(>)/g, '$1$2'));
html = [
// Append YAML front matter.
var html = [
'---',
'id: docs',
'layout: docs',
@@ -36,7 +42,7 @@ function build(type) {
'version: ' + (version || null),
'---',
'',
html,
_.trim($.html()),
].join('\n');
fs.writeFile(path.join(docPath, version + '.html'), html, util.pitch);