awesome-cordova-plugins/scripts/docs/processors/jekyll.js

51 lines
1.3 KiB
JavaScript
Raw Normal View History

2017-03-24 10:07:59 +08:00
"use strict";
module.exports = function jekyll(renderDocsProcessor) {
return {
name: 'jekyll',
description: 'Create jekyll includes',
$runAfter: ['paths-computed'],
$runBefore: ['rendering-docs'],
2017-03-24 10:07:59 +08:00
$process: docs => {
2017-03-24 10:07:59 +08:00
// pretty up and sort the docs object for menu generation
docs = docs.filter(doc => (!!doc.name && !!doc.outputPath) || doc.docType === 'index-page');
2017-03-24 10:07:59 +08:00
docs.sort((a, b) => {
const textA = a.name ? a.name.toUpperCase() : '',
textB = b.name ? b.name.toUpperCase() : '';
return (textA < textB) ? -1 : (textA > textB) ? 1 : 0;
});
2017-01-10 03:59:03 +08:00
2017-03-24 10:07:59 +08:00
docs.forEach(doc => {
doc.outputPath = doc.outputPath.toLowerCase().replace(/\s/g, '-');
doc.URL = doc.outputPath.replace('docs//', 'docs/')
2017-03-24 10:07:59 +08:00
.replace('/index.md', '')
.replace('content/', '');
});
2017-07-07 17:49:45 +08:00
const betaDocs = [];
docs = docs.filter(doc => {
if (doc.beta === true) {
betaDocs.push(doc);
return false;
}
return true;
});
docs = docs.concat(betaDocs);
2017-03-24 10:07:59 +08:00
// add side menu
docs.push({
2017-03-24 03:18:35 +08:00
docType: 'nativeMenu',
id: 'native_menu',
2016-02-06 06:04:48 +08:00
template: 'native_menu.template.html',
outputPath: 'content/_includes/fluid/native_menu.html'
});
return docs;
}
};
};