Use NodeJS NPM package markdownlint instead of Ruby gem mdl

This commit is contained in:
Igor Shubovych
2016-01-19 21:44:37 +02:00
parent 5f6b09b04b
commit 72196b030d
13 changed files with 97 additions and 120 deletions

47
scripts/build-index.js Normal file
View File

@@ -0,0 +1,47 @@
'use strict';
var glob = require("glob");
function parsePlatform(pagefile) {
return pagefile.split(/\//)[1];
}
function parsePagename(pagefile) {
return pagefile.split(/\//)[2].replace(/\.md$/, '');
}
function buildShortPagesIndex(files) {
var reducer = function(index, file) {
var os = parsePlatform(file);
var page = parsePagename(file);
if (index[page]) {
index[page].push(os);
} else {
index[page] = [os];
}
return index;
};
return files.reduce(reducer, {});
}
function buildPagesIndex(shortIndex) {
return Object.keys(shortIndex)
.sort()
.map(function(page) {
return {
name: page,
platform: shortIndex[page]
};
});
}
function saveIndex(index) {
console.log(JSON.stringify(index));
}
glob("pages/**/*.md", function (er, files) {
var shortIndex = buildShortPagesIndex(files);
var index = buildPagesIndex(shortIndex);
saveIndex(index);
});