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

64 lines
1.7 KiB
JavaScript
Raw Normal View History

2020-05-16 20:40:49 +08:00
'use strict';
module.exports = function jekyll(renderDocsProcessor) {
return {
name: 'jekyll',
description: 'Create jekyll includes',
$runAfter: ['paths-computed'],
$runBefore: ['rendering-docs'],
2021-09-28 04:09:05 +08:00
$process: (docs) => {
2017-03-24 10:07:59 +08:00
// pretty up and sort the docs object for menu generation
2021-09-28 04:09:05 +08:00
docs = docs.filter((doc) => (!!doc.name && !!doc.outputPath) || doc.docType === 'index-page');
docs.push({
docType: 'class',
URL: 'https://github.com/ionic-team/ionic-native-google-maps/blob/master/documents/README.md',
name: 'Google Maps',
});
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() : '';
2020-05-16 20:40:49 +08:00
return textA < textB ? -1 : textA > textB ? 1 : 0;
});
2017-01-10 03:59:03 +08:00
2021-09-28 04:09:05 +08:00
docs.forEach((doc) => {
if (!doc.outputPath) {
return;
}
2017-03-24 10:07:59 +08:00
doc.outputPath = doc.outputPath.toLowerCase().replace(/\s/g, '-');
2020-05-16 20:40:49 +08:00
doc.URL = doc.outputPath.replace('docs//', 'docs/').replace('/index.md', '').replace('content/', '');
// add trailing slash to plugin pages
2020-05-16 20:40:49 +08:00
if (!doc.URL.endsWith('/') && !doc.URL.endsWith('.html')) {
doc.URL = doc.URL + '/';
}
doc.URL = '/' + doc.URL;
});
2017-07-07 17:49:45 +08:00
const betaDocs = [];
2021-09-28 04:09:05 +08:00
docs = docs.filter((doc) => {
2017-07-07 17:49:45 +08:00
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',
2020-05-16 20:40:49 +08:00
outputPath: 'content/_includes/fluid/native_menu.html',
});
return docs;
2020-05-16 20:40:49 +08:00
},
};
};