@@ -12,9 +12,16 @@ import {
1212  writeSitemapJson , 
1313}  from  '../helpers/s3Bucket.helper' ; 
1414import  {  extractTitleFromMarkdown  }  from  '../helpers/extractTitle.helper' ; 
15- import  {  fetchFromStrapi  }  from  '../helpers/fetchFromStrapi' ; 
15+ import  { 
16+   fetchFromStrapi , 
17+   getResponseFromStrapi , 
18+ }  from  '../helpers/fetchFromStrapi' ; 
1619import  {  sitePathFromS3Path  }  from  '../helpers/sitePathFromS3Path' ; 
1720import  {  StrapiSolution  }  from  '../helpers/guidesMetadataHelper' ; 
21+ import  { 
22+   getSyncedSolutionListPagesResponseJsonPath , 
23+   getSyncedSolutionsResponseJsonPath , 
24+ }  from  '../syncedResponses' ; 
1825
1926// Load environment variables from .env file 
2027dotenv . config ( ) ; 
@@ -24,6 +31,10 @@ const S3_PATH_TO_GITBOOK_DOCS =
2431  process . env . S3_PATH_TO_GITBOOK_DOCS  ||  'devportal-docs/docs' ; 
2532const  S3_SOLUTIONS_METADATA_JSON_PATH  = 
2633  process . env . S3_SOLUTIONS_METADATA_JSON_PATH  ||  'solutions-metadata.json' ; 
34+ const  SYNCED_SOLUTIONS_RESPONSE_JSON_PATH  = 
35+   getSyncedSolutionsResponseJsonPath ( ) ; 
36+ const  SYNCED_SOLUTION_LIST_PAGES_RESPONSE_JSON_PATH  = 
37+   getSyncedSolutionListPagesResponseJsonPath ( ) ; 
2738
2839const  s3Client  =  makeS3Client ( ) ; 
2940function  generateUrlPath ( 
@@ -92,13 +103,28 @@ async function convertSolutionToSitemapItems(
92103async  function  main ( )  { 
93104  console . log ( 'Starting to process Markdown files...' ) ; 
94105
106+   // TODO: remove when Strapi will manage Metadata 
107+   // eslint-disable-next-line functional/no-let 
108+   let  solutionListPagesResponse ; 
109+   try  { 
110+     solutionListPagesResponse  =  await  getResponseFromStrapi ( 
111+       'api/solution-list-page/?populate%5Bsolutions%5D%5Bpopulate%5D%5B0%5D=bannerLinks&populate%5Bsolutions%5D%5Bpopulate%5D%5B1%5D=bannerLinks.icon&populate%5Bsolutions%5D%5Bpopulate%5D%5B2%5D=products.logo&populate%5Bsolutions%5D%5Bpopulate%5D%5B3%5D=icon&populate%5Bsolutions%5D%5Bpopulate%5D%5B4%5D=icon.name&populate%5Bsolutions%5D%5Bpopulate%5D%5B5%5D=stats&populate%5Bsolutions%5D%5Bpopulate%5D%5B6%5D=steps&populate%5Bsolutions%5D%5Bpopulate%5D%5B7%5D=steps.products&populate%5Bsolutions%5D%5Bpopulate%5D%5B8%5D=webinars&populate%5Bsolutions%5D%5Bpopulate%5D%5B9%5D=webinars.coverImage&populate%5Bsolutions%5D%5Bpopulate%5D%5B10%5D=caseHistories&populate%5Bsolutions%5D%5Bpopulate%5D%5B11%5D=caseHistories.case_histories&populate%5Bsolutions%5D%5Bpopulate%5D%5B12%5D=caseHistories.case_histories.image&populate%5BcaseHistories%5D%5Bpopulate%5D%5B0%5D=case_histories&populate%5BcaseHistories%5D%5Bpopulate%5D%5B1%5D=case_histories.image&populate%5Bfeatures%5D%5Bpopulate%5D%5B0%5D=items.icon&populate%5Bseo%5D%5Bpopulate%5D=%2A%2CmetaImage%2CmetaSocial.image' 
112+     ) ; 
113+   }  catch  ( error )  { 
114+     console . error ( 'Error fetching solution list pages from Strapi:' ,  error ) ; 
115+     process . exit ( 1 ) ; 
116+   } 
117+ 
95118  // eslint-disable-next-line functional/no-let 
96119  let  strapiSolutions ; 
120+   // eslint-disable-next-line functional/no-let 
121+   let  responseJson ; 
97122  try  { 
98-     const  {  data  }  =  await  fetchFromStrapi < StrapiSolution > ( 
123+     const  result  =  await  fetchFromStrapi < StrapiSolution > ( 
99124      'api/solutions?pagination[pageSize]=1000&pagination[page]=1' 
100125    ) ; 
101-     strapiSolutions  =  data ; 
126+     strapiSolutions  =  result . data ; 
127+     responseJson  =  result . responseJson ; 
102128  }  catch  ( error )  { 
103129    console . error ( 'Error fetching solutions from Strapi:' ,  error ) ; 
104130    process . exit ( 1 ) ; 
@@ -115,6 +141,22 @@ async function main() {
115141    `${ S3_BUCKET_NAME }  , 
116142    s3Client 
117143  ) ; 
144+ 
145+   // TODO: remove when Strapi will manage Metadata 
146+   await  writeSitemapJson ( 
147+     responseJson , 
148+     SYNCED_SOLUTIONS_RESPONSE_JSON_PATH , 
149+     `${ S3_BUCKET_NAME }  , 
150+     s3Client 
151+   ) ; 
152+ 
153+   // TODO: remove when Strapi will manage Metadata 
154+   await  writeSitemapJson ( 
155+     solutionListPagesResponse , 
156+     SYNCED_SOLUTION_LIST_PAGES_RESPONSE_JSON_PATH , 
157+     `${ S3_BUCKET_NAME }  , 
158+     s3Client 
159+   ) ; 
118160} 
119161
120162// Execute the function 
0 commit comments