@@ -21,6 +21,20 @@ const marked = require('marked')
21
21
const PAT_HEADMATTER = / ^ \+ \+ \+ \n ( [ ^ ] + ) \n \+ \+ \+ /
22
22
const SNIPPET_LENGTH = 220
23
23
24
+ // Temporarily hardcode featured tutorial URLs
25
+ const FEATURED_URLS = [
26
+ "/install-mongodb-on-windows" ,
27
+ "/install-mongodb-on-os-x" ,
28
+ "/install-mongodb-on-ubuntu" ,
29
+ "/connect-to-mongodb-python" ,
30
+ "/connect-to-mongodb-shell" ,
31
+ "/deploy-replica-set" ,
32
+ "/deploy-shard-cluster" ,
33
+ "/manage-users-and-roles" ,
34
+ "/enable-authentication" ,
35
+ "/configure-ldap-sasl-openldap"
36
+ ]
37
+
24
38
function escape ( html , encode ) {
25
39
return html
26
40
. replace ( ! encode ? / & (? ! # ? \w + ; ) / g : / & / g, '&' )
@@ -245,6 +259,24 @@ function processFile(path, addDocument) {
245
259
}
246
260
}
247
261
262
+ function sortFeatured ( tutorials ) {
263
+ let featured = [ ]
264
+ let notFeatured = [ ]
265
+
266
+ let index = - 1
267
+
268
+ tutorials . map ( tutorial => {
269
+ index = FEATURED_URLS . indexOf ( tutorial . url )
270
+ if ( index > - 1 ) {
271
+ featured [ index ] = tutorial
272
+ } else {
273
+ notFeatured . push ( tutorial )
274
+ }
275
+ } )
276
+
277
+ return featured . concat ( notFeatured )
278
+ }
279
+
248
280
function main ( ) {
249
281
const args = docopt . docopt ( __doc__ )
250
282
const tutorials = [ ]
@@ -316,9 +348,11 @@ function main() {
316
348
fs . mkdirSync ( 'public' )
317
349
} catch ( error ) { }
318
350
351
+ let sortedTutorials = sortFeatured ( tutorials )
352
+
319
353
fs . writeFileSync ( 'public/tags.json' , JSON . stringify ( {
320
354
tags : tags ,
321
- tutorials : tutorials
355
+ tutorials : sortedTutorials
322
356
} ) )
323
357
324
358
fs . writeFileSync ( 'public/search.json' , JSON . stringify ( searchIndexJSON ) )
0 commit comments