awesome-cordova-plugins/scripts/docs/processors/jekyll.js
Jan Piotrowski 4e0673c8e9 only add trailing slash on plugin pages
fixes that the trailing slash would have been added to the root and browser-usage.html as well
2017-08-05 17:37:16 +02:00

55 lines
1.5 KiB
JavaScript

"use strict";
module.exports = function jekyll(renderDocsProcessor) {
return {
name: 'jekyll',
description: 'Create jekyll includes',
$runAfter: ['paths-computed'],
$runBefore: ['rendering-docs'],
$process: docs => {
// pretty up and sort the docs object for menu generation
docs = docs.filter(doc => (!!doc.name && !!doc.outputPath) || doc.docType === 'index-page');
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;
});
docs.forEach(doc => {
doc.outputPath = doc.outputPath.toLowerCase().replace(/\s/g, '-');
doc.URL = doc.outputPath.replace('docs//', 'docs/')
.replace('/index.md', '')
.replace('content/', '');
// add trailing slash to plugin pages
if(!doc.URL.endsWith("/") && !doc.URL.endsWith(".html")) {
doc.URL = doc.URL+'/';
}
});
const betaDocs = [];
docs = docs.filter(doc => {
if (doc.beta === true) {
betaDocs.push(doc);
return false;
}
return true;
});
docs = docs.concat(betaDocs);
// add side menu
docs.push({
docType: 'nativeMenu',
id: 'native_menu',
template: 'native_menu.template.html',
outputPath: 'content/_includes/fluid/native_menu.html'
});
return docs;
}
};
};