mirror of
https://github.com/ionic-team/ionic-framework.git
synced 2025-08-18 19:21:34 +08:00
chore(docs): docs search index gulp task
This commit is contained in:
@ -22,6 +22,7 @@
|
||||
"del": "~1.1.1",
|
||||
"dgeni": "^0.4.1",
|
||||
"dgeni-packages": "^0.10.18",
|
||||
"event-stream": "^3.3.1",
|
||||
"glob": "^5.0.14",
|
||||
"gulp": "~3.8.10",
|
||||
"gulp-autoprefixer": "^2.3.0",
|
||||
@ -37,11 +38,14 @@
|
||||
"gulp-typescript": "^2.7.7",
|
||||
"gulp-util": "^3.0.6",
|
||||
"gulp-watch": "^4.2.4",
|
||||
"htmlparser2": "^3.8.3",
|
||||
"js-yaml": "^3.4.2",
|
||||
"karma": "^0.12.31",
|
||||
"karma-chrome-launcher": "^0.1.7",
|
||||
"karma-jasmine": "^0.3.5",
|
||||
"lazypipe": "^0.2.3",
|
||||
"lodash": "^2.4.1",
|
||||
"lunr": "^0.5.12",
|
||||
"minimist": "^1.1.3",
|
||||
"mkdirp": "^0.5.1",
|
||||
"node-html-encoder": "0.0.2",
|
||||
|
@ -33,6 +33,14 @@ module.exports = function(gulp, flags) {
|
||||
|
||||
|
||||
gulp.task('docs.index', function() {
|
||||
var lunr = require('lunr');
|
||||
var gutil = require('gulp-util');
|
||||
var es = require('event-stream');
|
||||
var yaml = require('js-yaml');
|
||||
var htmlparser = require('htmlparser2');
|
||||
var mkdirp = require('mkdirp');
|
||||
var fs = require('fs');
|
||||
|
||||
var idx = lunr(function() {
|
||||
this.field('path');
|
||||
this.field('title', {boost: 10});
|
||||
@ -49,22 +57,19 @@ module.exports = function(gulp, flags) {
|
||||
refId++;
|
||||
}
|
||||
|
||||
var docPath = buildConfig.dist + '/ionic-site';
|
||||
var docPath = 'dist/ionic-site/docs/v2';
|
||||
gutil.log('Reading docs from', gutil.colors.cyan(docPath));
|
||||
|
||||
return gulp.src([
|
||||
docPath + '/docs/{components,guide,api,overview}/**/*.{md,html,markdown}',
|
||||
docPath + '/docs/index.html',
|
||||
docPath + '/getting-started/index.html',
|
||||
docPath + '/tutorials/**/*.{md,html,markdown}',
|
||||
docPath + '/_posts/**/*.{md,html,markdown}'
|
||||
docPath + '/{guide,api,overview, what-is,utilities,ui,theming,native}/**/*.{md,html,markdown}',
|
||||
docPath + '/index.md',
|
||||
])
|
||||
.pipe(es.map(function(file, callback) {
|
||||
//docs for gulp file objects: https://github.com/wearefractal/vinyl
|
||||
var contents = file.contents.toString(); //was buffer
|
||||
|
||||
// Grab relative path from ionic-site root
|
||||
var relpath = file.path.replace(RegExp('^.*?' + docPath + '/'), '');
|
||||
var relpath = file.path.replace(RegExp('^.*?' + docPath.replace('/docs/v2', '') + '/'), '');
|
||||
|
||||
// Read out the yaml portion of the Jekyll file
|
||||
var yamlStartIndex = contents.indexOf('---');
|
||||
|
Reference in New Issue
Block a user