@@ -21,6 +21,20 @@ const marked = require('marked')
2121const PAT_HEADMATTER = / ^ \+ \+ \+ \n ( [ ^ ] + ) \n \+ \+ \+ /
2222const SNIPPET_LENGTH = 220
2323
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+
2438function escape ( html , encode ) {
2539 return html
2640 . replace ( ! encode ? / & (? ! # ? \w + ; ) / g : / & / g, '&' )
@@ -245,6 +259,24 @@ function processFile(path, addDocument) {
245259 }
246260}
247261
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+
248280function main ( ) {
249281 const args = docopt . docopt ( __doc__ )
250282 const tutorials = [ ]
@@ -316,9 +348,11 @@ function main() {
316348 fs . mkdirSync ( 'public' )
317349 } catch ( error ) { }
318350
351+ let sortedTutorials = sortFeatured ( tutorials )
352+
319353 fs . writeFileSync ( 'public/tags.json' , JSON . stringify ( {
320354 tags : tags ,
321- tutorials : tutorials
355+ tutorials : sortedTutorials
322356 } ) )
323357
324358 fs . writeFileSync ( 'public/search.json' , JSON . stringify ( searchIndexJSON ) )
0 commit comments