mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-02-06 09:47:48 +00:00
Add comments and cleanup build-site.js.
This commit is contained in:
@@ -11,12 +11,19 @@ var basePath = path.join(__dirname, '..', '..'),
|
|||||||
readmePath = path.join(docPath, 'README.md');
|
readmePath = path.join(docPath, 'README.md');
|
||||||
|
|
||||||
function build(type) {
|
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(),
|
$header = $('h1').first().remove(),
|
||||||
version = _.trim($header.find('span').first().text()).slice(1);
|
version = _.trim($header.find('span').first().text()).slice(1);
|
||||||
|
|
||||||
|
// Remove docdown horizontal rules.
|
||||||
$('hr').remove();
|
$('hr').remove();
|
||||||
|
|
||||||
|
// Remove marky-markdown additions.
|
||||||
$('[id^="user-content-"]')
|
$('[id^="user-content-"]')
|
||||||
.attr('class', null)
|
.attr('class', null)
|
||||||
.attr('id', null);
|
.attr('id', null);
|
||||||
@@ -26,9 +33,8 @@ function build(type) {
|
|||||||
$a.replaceWith($a.html());
|
$a.replaceWith($a.html());
|
||||||
});
|
});
|
||||||
|
|
||||||
var html = _.trim($.html().replace(/(<)!--\s*|\s*--(>)/g, '$1$2'));
|
// Append YAML front matter.
|
||||||
|
var html = [
|
||||||
html = [
|
|
||||||
'---',
|
'---',
|
||||||
'id: docs',
|
'id: docs',
|
||||||
'layout: docs',
|
'layout: docs',
|
||||||
@@ -36,7 +42,7 @@ function build(type) {
|
|||||||
'version: ' + (version || null),
|
'version: ' + (version || null),
|
||||||
'---',
|
'---',
|
||||||
'',
|
'',
|
||||||
html,
|
_.trim($.html()),
|
||||||
].join('\n');
|
].join('\n');
|
||||||
|
|
||||||
fs.writeFile(path.join(docPath, version + '.html'), html, util.pitch);
|
fs.writeFile(path.join(docPath, version + '.html'), html, util.pitch);
|
||||||
|
|||||||
Reference in New Issue
Block a user