Skip to content

Commit 643a2fe

Browse files
authored
Merge pull request aws-amplify#6060 from aws-amplify/algolia-index
update algolia index function to remove INTEGRATION_FILTER_OPTIONS fr…
2 parents f39de14 + 9367ad6 commit 643a2fe

File tree

1 file changed

+17
-2
lines changed

1 file changed

+17
-2
lines changed

tasks/build-algolia-search.mjs

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -264,7 +264,7 @@ async function tryParseImports(
264264
if (Object.keys(fragments).length !== 0) {
265265
// add platform specific fragments to source
266266
await Promise.all(
267-
fragments[platform].map(async (fragment) => {
267+
fragments[platform]?.map(async (fragment) => {
268268
const fragmentPath = path.join(__dirname, '..', fragment);
269269
const fragmentFile = sanitizeMDX(
270270
fs.readFileSync(fragmentPath, 'utf8')
@@ -274,7 +274,7 @@ async function tryParseImports(
274274
platform
275275
);
276276
source = source + '\n' + allFragments;
277-
})
277+
}) || []
278278
);
279279

280280
// remove unused fragments and imports from markdown
@@ -289,6 +289,21 @@ async function tryParseImports(
289289
source = source.join('\n');
290290
}
291291

292+
// remove INTEGRATION_FILTER_OPTIONS variables
293+
source = source.split('\n');
294+
source = source.map((line) => {
295+
if (line.includes('INTEGRATION_FILTER_OPTIONS')) {
296+
if(line.includes('import')){
297+
line = '';
298+
}else {
299+
line = line.replaceAll('INTEGRATION_FILTER_OPTIONS',"''");
300+
}
301+
}
302+
return line;
303+
});
304+
305+
source = source.join('\n');
306+
292307
const meta = await extractMdxMeta(source);
293308

294309
meta.title = platformMap[platform]

0 commit comments

Comments
 (0)