lib/index.js
function generateCollectionFiles(fileName, collectionQuery, callback, ctx) {
            if (collectionQuery != null) {
                var file = files[fileName];
                var newFiles = {};
                var fileExtension = file.prismic[collectionQuery].collection.fileExtension;
                var fileSuffix = (fileExtension != undefined && fileExtension !== "")? "." + fileExtension:"";
                // for every result in the collection query
                for (var i = 0; i < file.prismic[collectionQuery].results.length; i++) {

                    // clone the file and replace the original collectionQuery results with the current result
                    var newFile = clone(file);
                    newFile.prismic[collectionQuery].results = [file.prismic[collectionQuery].results[i]];

                    // add the filename to the ctx object to make it available for use in the linkResolver function
                    ctx.path = fileName;

                    // use the linkResolver to generate the filename removing the leading slash if present
                    newFiles[(ctx.linkResolver(file.prismic[collectionQuery].results[i]) + fileSuffix).replace(/^\//g, '')] = newFile;
                }

                delete files[fileName];
                _.extend(files, newFiles);
            }

            callback();
        }
function generateCollectionFiles(fileName, collectionQuery, callback, ctx) {
            if (collectionQuery != null) {
                var file = files[fileName];
                var newFiles = {};
                var fileExtension = file.prismic[collectionQuery].collection.fileExtension;
                var fileSuffix = (fileExtension != undefined && fileExtension !== "")? "." + fileExtension:"";
                // for every result in the collection query
                for (var i = 0; i < file.prismic[collectionQuery].results.length; i++) {

                    // clone the file and replace the original collectionQuery results with the current result
                    var newFile = clone(file);
                    newFile.prismic[collectionQuery].results = [file.prismic[collectionQuery].results[i]];

                    // add the filename to the ctx object to make it available for use in the linkResolver function
                    ctx.path = fileName;

                    // use the linkResolver to generate the filename removing the leading slash if present
                    newFiles[(ctx.linkResolver(file.prismic[collectionQuery].results[i]) + fileSuffix).replace(/^\//g, '')] = newFile;
                }

                delete files[fileName];
                _.extend(files, newFiles);
            }

            callback();
        }
function generateCollectionFiles ( fileName , collectionQuery , callback , ctx ) { if ( collectionQuery != null ) { var file = files [ fileName ] ; var newFiles = { } ; var fileExtension = file . prismic [ collectionQuery ] . collection . fileExtension ; var fileSuffix = ( fileExtension != undefined && fileExtension !== "" ) ? "." + fileExtension : "" ; // for every result in the collection query for ( var i = 0 ; i < file . prismic [ collectionQuery ] . results . length ; i ++ ) { // clone the file and replace the original collectionQuery results with the current result var newFile = clone ( file ) ; newFile . prismic [ collectionQuery ] . results = [ file . prismic [ collectionQuery ] . results [ i ] ] ; // add the filename to the ctx object to make it available for use in the linkResolver function ctx . path = fileName ; // use the linkResolver to generate the filename removing the leading slash if present newFiles [ ( ctx . linkResolver ( file . prismic [ collectionQuery ] . results [ i ] ) + fileSuffix ) . replace ( / ^\/ / g , '' ) ] = newFile ; } delete files [ fileName ] ; _ . extend ( files , newFiles ) ; } callback ( ) ; }
if any of the queries are designated the collection query, then generate a file for each of the results
if any of the queries are designated the collection query then generate a file for each of the results