Skip to content

Commit 8413cef

Browse files
authored
[code-infra] Filter out @mui/joy and @mui/base from search results (#47076)
1 parent 26ee0f7 commit 8413cef

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

docs/src/modules/components/AppSearch.js

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -228,6 +228,8 @@ DocSearchHit.propTypes = {
228228
hit: PropTypes.object.isRequired,
229229
};
230230

231+
const standaloneProducts = ['base-ui', 'joy-ui'];
232+
231233
export default function AppSearch(props) {
232234
useLazyCSS(
233235
'https://cdn.jsdelivr.net/npm/@docsearch/[email protected]/dist/style.min.css',
@@ -323,6 +325,18 @@ export default function AppSearch(props) {
323325
optionalFilters.push(`productCategoryId:${pageContext.productCategoryId}`);
324326
}
325327

328+
// Filter out stand-alone products unless we're on their subsections
329+
let filters = undefined;
330+
if (standaloneProducts.length > 0) {
331+
const filtersPredicates = [];
332+
for (let i = 0; i < standaloneProducts.length; i += 1) {
333+
if (pageContext.productId !== standaloneProducts[i]) {
334+
filtersPredicates.push(`NOT productId:${standaloneProducts[i]}`);
335+
}
336+
}
337+
filters = filtersPredicates.join(' AND ');
338+
}
339+
326340
return (
327341
<React.Fragment>
328342
<SearchButton onRef={searchButtonRef} onClick={onOpen} {...props} />
@@ -335,6 +349,7 @@ export default function AppSearch(props) {
335349
indexName="material-ui"
336350
searchParameters={{
337351
facetFilters: ['version:master', facetFilterLanguage],
352+
filters,
338353
optionalFilters,
339354
attributesToRetrieve: [
340355
// Copied from https://github.com/algolia/docsearch/blob/ce0c865cd8767e961ce3088b3155fc982d4c2e2e/packages/docsearch-react/src/DocSearchModal.tsx#L231

0 commit comments

Comments
 (0)