diff --git a/src/lib/datocms-bypass.ts b/src/lib/datocms-bypass.ts index f07b549..65e92ea 100644 --- a/src/lib/datocms-bypass.ts +++ b/src/lib/datocms-bypass.ts @@ -77,11 +77,11 @@ function getListingQueryDirectories() { //directories['allCategories'] = 'category'; - directories['allEvents'] = 'event'; - directories['allPositions'] = 'position'; - directories['allPressReleases'] = 'pressRelease'; - directories['allTeams'] = 'team'; - directories['allTestimonials'] = 'testimonial'; + directories['allEvents'] : string = 'event'; + directories['allPositions'] : string = 'position'; + directories['allPressReleases'] : string = 'pressRelease'; + directories['allTeams'] : string = 'team'; + directories['allTestimonials'] : string = 'testimonial'; return directories; @@ -91,7 +91,7 @@ function getListingDirectoryByQueryParent(parent : string) { //-----this acts as a whitelist and a mapping to the folder name... let directories : any[] = getListingQueryDirectories() ; - let directory = ''; + let directory : string = ''; if (typeof directories[parent] === 'undefined') { directory = ''; @@ -105,19 +105,19 @@ function getListingDirectoryByQueryParent(parent : string) { function pluckFirstParentFromQuery(query : any) { //-----only plucks the FIRST parent, if there are multiple parents in the query they will be ignored. - let parent = ((query.replace(/[\W_]+/g," ")).trim()).split(" ")[0]; + let parent : string = ((query.replace(/[\W_]+/g," ")).trim()).split(" ")[0]; return parent; } async function datocmsPageQueryIntercept(query : any) { - let parent = pluckFirstParentFromQuery(query); - let jsonDirectory = path.join(process.cwd(), 'json/site_content'); - let jsonPath = jsonDirectory + '/' + parent + '.json'; - let fileRawContents = ''; - let fileJson = {} - let jsonData = {} + let parent : string = pluckFirstParentFromQuery(query); + let jsonDirectory : string = path.join(process.cwd(), 'json/site_content'); + let jsonPath : string = jsonDirectory + '/' + parent + '.json'; + let fileRawContents : string = ''; + let fileJson : object = {} + let jsonData : object = {} try { fileRawContents = await fs.readFile(jsonPath, 'utf8'); @@ -137,8 +137,8 @@ async function datocmsPageQueryIntercept(query : any) { async function datocmsListingQueryIntercept(query : any) { - let parent = pluckFirstParentFromQuery(query); - let jsonData = {}; + let parent : string = pluckFirstParentFromQuery(query); + let jsonData : object = {}; switch(parent) { case 'allBlogPosts':