src/write/collections.js
function walkCollections(patterns, drizzleData, writePromises = []) {
  if (hasCollection(patterns)) {
    writePromises.push(
      writePage(
        patterns.collection.id,
        patterns.collection,
        drizzleData.options.dest.patterns,
        drizzleData.options.keys.collections.plural
      )
    );
  }
  for (const patternKey in patterns) {
    if (!isCollection(patterns[patternKey])) {
      walkCollections(patterns[patternKey], drizzleData, writePromises);
    }
  }
  return writePromises;
}
function walkCollections(patterns, drizzleData, writePromises = []) {
  if (hasCollection(patterns)) {
    writePromises.push(
      writePage(
        patterns.collection.id,
        patterns.collection,
        drizzleData.options.dest.patterns,
        drizzleData.options.keys.collections.plural
      )
    );
  }
  for (const patternKey in patterns) {
    if (!isCollection(patterns[patternKey])) {
      walkCollections(patterns[patternKey], drizzleData, writePromises);
    }
  }
  return writePromises;
}
function walkCollections ( patterns , drizzleData , writePromises = [ ] ) { if ( hasCollection ( patterns ) ) { writePromises . push ( writePage ( patterns . collection . id , patterns . collection , drizzleData . options . dest . patterns , drizzleData . options . keys . collections . plural ) ) ; } for ( const patternKey in patterns ) { if ( ! isCollection ( patterns [ patternKey ] ) ) { walkCollections ( patterns [ patternKey ] , drizzleData , writePromises ) ; } } return writePromises ; }
Traverse patterns object and write out any collection objects to files.

@param {Object} pages   current level of pages tree
@param {Object} drizzleData
@param {Array} writePromises All write promises so far
@return {Array} of Promises
Traverse patterns object and write out any collection objects to files .