diff --git a/src/lib/datocms-bypass.ts b/src/lib/datocms-bypass.ts index 28c1aaa..aefb741 100644 --- a/src/lib/datocms-bypass.ts +++ b/src/lib/datocms-bypass.ts @@ -67,21 +67,15 @@ function getPageQueryBypassWhitelist() { } function getListingQueryDirectories() { - //-----acts as a whitelist, but also points to the directory name of the listing if ever desired to make code less WET. + //-----whitelist the listying types of content... - let directories : any[] = []; + let directories : string[] = []; - //-----blog + category is handled in its own annoyingly special way - //-----could bundle it in here to be DRY and verbose but will not in the intrest of current time/budget - //directories['allBlogPosts'] = 'blogPost'; - //directories['allCategories'] = 'category'; - - - directories['allEvents'] : any = 'event'; - directories['allPositions'] : any = 'position'; - directories['allPressReleases'] : any = 'pressRelease'; - directories['allTeams'] : any = 'team'; - directories['allTestimonials'] : any = 'testimonial'; + directories.push('allEvents'); + directories.push('allPositions)'; + directories.push('allPressReleases'); + directories.push('allTeams'); + directories.push('allTestimonials'); return directories; @@ -90,12 +84,11 @@ function getListingQueryDirectories() { function getListingDirectoryByQueryParent(parent : string) { //-----this acts as a whitelist and a mapping to the folder name... - let directories : any[] = getListingQueryDirectories() ; + let directories : string[] = getListingQueryDirectories() ; let directory : string = ''; - if (typeof directories[parent] === 'undefined') { - directory = ''; - } else { + + if (directories.includes(parent)) { directory = directories[parent]; }