nl_tokens: Get the images in the source and sort them by types . We are interested in three types of images : - the header starting with header . - the logos starting with logo . - And the rest ( what we call screenshots ) .
pl_tokens: function getImages ( source ) { if ( ! fs . existsSync ( source ) ) { console . error ( ` ${ source } ` , '🤔') return } const images = { <mask> : null , screenshots : [ ] , logos : [ ] } sfs . findAllFiles ( source ) . forEach ( filePathWithSource => { // Remove 'path/to/images' from 'path/to/images/filename'. // ie, 'data/product/images/burger01.png' becomes 'burger01.png'. // This is super important. We only need this portion for: // - the comparison below // - the url on the site // - the copy to the built presskit const f = path . relative ( source , filePathWithSource ) // Authorize only these formats. const ext = path . extname ( f ) if ( ! authorizedImageFormats . includes ( ext ) ) return // Ignore favicon. if ( f . toLowerCase ( ) === 'favicon.ico' ) return // And put in the correct category. if ( f . toLowerCase ( ) . startsWith ( 'header' ) ) { images . header = f } else if ( f . toLowerCase ( ) . startsWith ( 'logo' ) ) { images . logos . push ( f ) } else { images . screenshots . push ( f ) } } ) return images }