@@ -7,6 +7,7 @@ Error.call = (self, ...args) => {
77}
88
99const asciidoctor = require ( 'asciidoctor.js' ) ( )
10+ const File = require ( 'vinyl' )
1011const fs = require ( 'fs-extra' )
1112const handlebars = require ( 'handlebars' )
1213const iconPacks = {
@@ -31,6 +32,7 @@ const iconShims = require('@fortawesome/fontawesome-free/js/v4-shims').reduce((a
3132 accum [ 'fa-' + it [ 0 ] ] = [ it [ 1 ] || 'fas' , 'fa-' + ( it [ 2 ] || it [ 0 ] ) ]
3233 return accum
3334} , { } )
35+ const { inspect } = require ( 'util' )
3436const { obj : map } = require ( 'through2' )
3537const merge = require ( 'merge-stream' )
3638const ospath = require ( 'path' )
@@ -129,6 +131,7 @@ module.exports = (src, previewSrc, previewDest, sink = () => map()) => (done) =>
129131 }
130132 } ,
131133 function ( done ) {
134+ this . push ( exportSiteNavigationData ( baseUiModel . site . components ) )
132135 vfs
133136 . src ( 'js/vendor/fontawesome-icon-defs.js' , { base : src , cwd : src } )
134137 . pipe (
@@ -229,6 +232,23 @@ function copyImages (src, dest) {
229232 return vfs . src ( '**/*.{png,svg}' , { base : src , cwd : src } ) . pipe ( vfs . dest ( dest ) )
230233}
231234
235+ function exportSiteNavigationData ( components ) {
236+ const navigationData = Object . values ( components ) . map ( ( { name, title, versions } ) => ( {
237+ name,
238+ title,
239+ versions : versions . map ( ( { version, displayVersion, navigation : sets = [ ] } ) =>
240+ version === displayVersion ? { version, sets } : { version, displayVersion, sets }
241+ ) ,
242+ } ) )
243+ return new File ( {
244+ contents : Buffer . from (
245+ 'window.siteNavigationData = ' +
246+ inspect ( navigationData , { depth : null , maxArrayLength : null , breakLength : 250 } )
247+ ) ,
248+ path : 'site-navigation-data.js' ,
249+ } )
250+ }
251+
232252function findNavPath ( currentUrl , node = [ ] , current_path = [ ] , root = true ) {
233253 for ( const item of node ) {
234254 const { url, items } = item
0 commit comments