nl_tokens: Metalsmith Plugin that collates a list of pages that are to be included in the site navigation into the metadata along with their URLs .
pl_tokens: function getPages ( files , metalsmith , done ) { var metadata = metalsmith . metadata ( ) ; var pages = [ ] ; var order = { } ; if ( metadata . site . pages ) metadata . site . pages . forEach ( ( url , index ) => typeof url == "string" ? order [ url ] = index : null ) ; var unorderedPages = [ ] ; function addPage ( url , title ) { var page = { url : url , title : title } ; var index = order [ url ] ; if ( index !== undefined ) pages [ index ] = page ; else unorderedPages . <mask> ( page ) ; } for ( var filename in files ) { var file = files [ filename ] ; if ( filename == "index.html" ) addPage ( "/" , file . title || "Home Page" ) ; else if ( file . permalink || file . navigation ) addPage ( file . permalink || filename , file . title || "Home Page" ) ; } unorderedPages . forEach ( page => pages . push ( page ) ) ; metadata . site . pages = pages ; done ( ) ; }