typescript appeasment vol 3

Signed-off-by: Traxus <shyidx@gmail.com>
This commit is contained in:
Traxus 2023-04-21 19:32:26 -04:00
parent 149c77017a
commit fc5d0bc7f7

View File

@ -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':