Skip to content

Commit cb72cc4

Browse files
committed
Limit sections which are indexed and lowercase title
1 parent 1069a8e commit cb72cc4

File tree

1 file changed

+15
-21
lines changed
  • lib/node_modules/@stdlib/_tools/search/pkg-index/lib

1 file changed

+15
-21
lines changed

lib/node_modules/@stdlib/_tools/search/pkg-index/lib/create.js

Lines changed: 15 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -22,13 +22,14 @@
2222

2323
var logger = require( 'debug' );
2424
var lunr = require( 'lunr' );
25+
var lowercase = require( '@stdlib/string/lowercase' );
2526
var sectionText = require( './section_text.js' );
2627

2728

2829
// VARIABLES //
2930

3031
var debug = logger( 'seach:pkg-index:create' );
31-
var TITLE_REGEXP = /#[ ]*([^\n]+)\r?\n/;
32+
var TITLE_REGEXP = /^#[ ]*([^\n]+)\r?\n$/;
3233
var DESCR_REGEXP = />[ ]*([^\n]+)\r?\n/;
3334

3435

@@ -52,8 +53,10 @@ function createIndex( files ) {
5253
*/
5354
function initialize() {
5455
/* eslint-disable no-invalid-this */
56+
var title;
5557
var file;
5658
var blob;
59+
var desc;
5760
var i;
5861

5962
this.field( 'title', {
@@ -62,35 +65,26 @@ function createIndex( files ) {
6265
this.field( 'description', {
6366
'boost': 5
6467
});
65-
this.field( 'intro', {
68+
this.field( 'introduction', {
6669
'boost': 3
6770
});
68-
this.field( 'usage', {
69-
'boost': 3
70-
});
71-
this.field( 'notes', {
72-
'boost': 2
73-
} );
74-
this.field( 'cli', {
75-
'boost': 1
76-
});
77-
this.field( 'references', {
78-
'boost': 1
79-
});
8071
this.ref( 'id' );
8172

8273
// Add documents to search index:
8374
for ( i = 0; i < files.length; i++ ) {
8475
debug( 'Indexing file: %s', files[ i ].file );
8576
file = files[ i ].data;
77+
78+
title = lowercase( file.match( TITLE_REGEXP )[ 1 ] );
79+
debug( 'Title: %s', title );
80+
81+
desc = file.match( DESCR_REGEXP )[ 1 ];
82+
debug( 'Description: %s', desc );
83+
8684
blob = {
87-
'title': file.match( TITLE_REGEXP )[ 1 ],
88-
'description': file.match( DESCR_REGEXP )[ 1 ],
89-
'intro': sectionText( file, 'intro' ),
90-
'usage': sectionText( file, 'usage' ),
91-
'notes': sectionText( file, 'notes' ),
92-
'cli': sectionText( file, 'cli' ),
93-
'references': sectionText( file, 'references' ),
85+
'title': title,
86+
'description': desc,
87+
'introduction': sectionText( file, 'intro' ),
9488
'id': files[ i ].file
9589
};
9690
debug( 'File data: %s', JSON.stringify( blob ) );

0 commit comments

Comments
 (0)