2017-03-24 10:07:59 +08:00
|
|
|
"use strict";
|
2016-01-26 06:20:36 +08:00
|
|
|
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 06:20:10 +08:00
|
|
|
|
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 06:20:10 +08:00
|
|
|
|
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() : '';
|
2016-01-26 06:20:36 +08:00
|
|
|
|
|
|
|
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, '-');
|
2017-03-30 00:19:31 +08:00
|
|
|
doc.URL = doc.outputPath.replace('docs//', 'docs/')
|
2017-03-24 10:07:59 +08:00
|
|
|
.replace('/index.md', '')
|
|
|
|
.replace('content/', '');
|
2017-08-05 23:37:16 +08:00
|
|
|
// add trailing slash to plugin pages
|
|
|
|
if(!doc.URL.endsWith("/") && !doc.URL.endsWith(".html")) {
|
|
|
|
doc.URL = doc.URL+'/';
|
|
|
|
}
|
2016-01-26 06:20:36 +08:00
|
|
|
});
|
|
|
|
|
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
|
2016-01-26 06:20:36 +08:00
|
|
|
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',
|
2017-03-30 00:19:31 +08:00
|
|
|
outputPath: 'content/_includes/fluid/native_menu.html'
|
2016-01-26 06:20:36 +08:00
|
|
|
});
|
|
|
|
|
|
|
|
return docs;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
};
|