Skip to content

Commit

Permalink
Merge pull request #6060 from aws-amplify/algolia-index
Browse files Browse the repository at this point in the history
update algolia index function to remove INTEGRATION_FILTER_OPTIONS fr…
  • Loading branch information
jacoblogan authored Oct 23, 2023
2 parents f39de14 + 9367ad6 commit 643a2fe
Showing 1 changed file with 17 additions and 2 deletions.
19 changes: 17 additions & 2 deletions tasks/build-algolia-search.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,7 @@ async function tryParseImports(
if (Object.keys(fragments).length !== 0) {
// add platform specific fragments to source
await Promise.all(
fragments[platform].map(async (fragment) => {
fragments[platform]?.map(async (fragment) => {
const fragmentPath = path.join(__dirname, '..', fragment);
const fragmentFile = sanitizeMDX(
fs.readFileSync(fragmentPath, 'utf8')
Expand All @@ -274,7 +274,7 @@ async function tryParseImports(
platform
);
source = source + '\n' + allFragments;
})
}) || []
);

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

// remove INTEGRATION_FILTER_OPTIONS variables
source = source.split('\n');
source = source.map((line) => {
if (line.includes('INTEGRATION_FILTER_OPTIONS')) {
if(line.includes('import')){
line = '';
}else {
line = line.replaceAll('INTEGRATION_FILTER_OPTIONS',"''");
}
}
return line;
});

source = source.join('\n');

const meta = await extractMdxMeta(source);

meta.title = platformMap[platform]
Expand Down

0 comments on commit 643a2fe

Please sign in to comment.