packages/docs/webpack-docs-plugin.setup.js
function createNav(sources) {
  const defaultCategory = 'Uncategorized';

  const sourcesByCategories = sources.
    // get category names
    reduce((categories, source) => categories.
      concat(source.attrs.category || defaultCategory), []).

    // remove duplicates
    filter((value, i, self) => self.indexOf(value) === i).

    // create category object and fill it with related sources
    reduce((categories, categoryName) => {
      categories.push({
        name: categoryName,
        items: createCategoryItemsFromSources(sources, categoryName)
      });
      return categories;
    }, []);

  sourcesByCategories.sort(categoriesSorter);
  sourcesByCategories.
    forEach(category => category.items.sort(categoryItemsSorter));

  return sourcesByCategories;
}
function createNav(sources) {
  const defaultCategory = 'Uncategorized';

  const sourcesByCategories = sources.
    // get category names
    reduce((categories, source) => categories.
      concat(source.attrs.category || defaultCategory), []).

    // remove duplicates
    filter((value, i, self) => self.indexOf(value) === i).

    // create category object and fill it with related sources
    reduce((categories, categoryName) => {
      categories.push({
        name: categoryName,
        items: createCategoryItemsFromSources(sources, categoryName)
      });
      return categories;
    }, []);

  sourcesByCategories.sort(categoriesSorter);
  sourcesByCategories.
    forEach(category => category.items.sort(categoryItemsSorter));

  return sourcesByCategories;
}
function createNav ( sources ) { const defaultCategory = 'Uncategorized' ; const sourcesByCategories = sources . // get category names reduce ( ( categories , source ) => categories . concat ( source . attrs . category || defaultCategory ) , [ ] ) . // remove duplicates filter ( ( value , i , self ) => self . indexOf ( value ) === i ) . // create category object and fill it with related sources reduce ( ( categories , categoryName ) => { categories . push ( { name : categoryName , items : createCategoryItemsFromSources ( sources , categoryName ) } ) ; return categories ; } , [ ] ) ; sourcesByCategories . sort ( categoriesSorter ) ; sourcesByCategories . forEach ( category => category . items . sort ( categoryItemsSorter ) ) ; return sourcesByCategories ; }
Creates navigation object.
@param {Array<Source>} sources
@returns {Array<Object>}
Creates navigation object .