import _startcase from 'lodash.startcase' ; const caseString = ( str , caseFilename = true ) => { return str . split ( '/' ) . map ( ( item , index , arr ) => { if ( ! caseFilename && index === arr . length - 1 ) { return item ; } return _startcase ( item ) ; } ) . join ( '/' ) ; } ; export const getTitle = ( filename , caseFilename ? ) => { const directoryPrefix = 'src/stories/' ; const storySuffix = /.stories.(tsx|mdx)/ ; const strippedFileName = filename . replace ( directoryPrefix , '' ) . replace ( storySuffix , '' ) ; return caseString ( strippedFileName , caseFilename ) ; } ;