@@ -320,3 +320,80 @@ export function Search({path, autoFocus, searchPlatforms = [], showChatBot}: Pro
320320 </ div >
321321 ) ;
322322}
323+
324+ // const exampleDocsHit = {
325+ // id: 'f2274542a8fefa5e95bae958c36b97bd',
326+ // site: 'docs',
327+ // url: 'https://docs.sentry.io/platforms/javascript/guides/koa/troubleshooting/',
328+ // index: 'sentry-docs-v2',
329+ // context: {
330+ // context1: 'Platforms > JavaScript > Guides > Koa > Troubleshooting',
331+ // },
332+ // title: 'Troubleshooting',
333+ // text: 'If you need additional help, you can ask on GitHub . Customers on a paid plan …',
334+ // queryID: '021f95330896bc64cb93b22741badb26',
335+ // };
336+
337+ // const platformsByTraffic = [
338+ // 'nextjs',
339+ // 'react',
340+ // 'react-native',
341+ // 'python',
342+ // 'laravel',
343+ // 'node',
344+ // 'vue',
345+ // 'ios',
346+ // 'angular',
347+ // 'nestjs',
348+ // 'django',
349+ // 'spring',
350+ // 'go',
351+ // 'ruby',
352+ // 'kotlin',
353+ // 'dart',
354+ // 'unity',
355+ // ];
356+
357+ // function sortPlatforms(hits: Hit[]) {
358+ // console.log('👉 unsorted hits', hits);
359+
360+ // const getPlatform = (hit: Hit) => {
361+ // const url = new URL(hit.url);
362+ // const pathname = url.pathname.slice(1);
363+ // let sdkOrFramework: string | undefined;
364+ // if (pathname.includes('/guides/')) {
365+ // sdkOrFramework = pathname.split('/')[3];
366+ // } else if (pathname.includes('platforms/')) {
367+ // sdkOrFramework = pathname.split('/')[1];
368+ // }
369+ // return sdkOrFramework;
370+ // };
371+
372+ // const hitsWithPlatform = hits.map(h => ({...h, platform: getPlatform(h)}));
373+
374+ // const nonPlatformHits = hitsWithPlatform.filter(hit => !hit.platform);
375+ // const platformHits = hitsWithPlatform.filter(hit => !!hit.platform);
376+
377+ // const sortedPlatformHits = platformHits.slice().sort((a, b) => {
378+ // const aPlatform = a.platform ?? '';
379+ // const bPlatform = b.platform ?? '';
380+ // // some platforms are missing, we should prioritize the ones in the platformsByTraffic array
381+ // const aIndex = platformsByTraffic.indexOf(aPlatform);
382+ // const bIndex = platformsByTraffic.indexOf(bPlatform);
383+ // debugger;
384+ // let tie = 0;
385+ // if (aIndex === -1 && bIndex !== -1) {
386+ // tie = -1;
387+ // }
388+ // if (bIndex === -1 && aIndex !== -1) {
389+ // tie = 1;
390+ // }
391+ // // smaller index has more weight
392+ // const diff = bIndex - aIndex;
393+ // tie = diff < 0 ? -1 : diff > 0 ? 1 : 0;
394+ // console.log('👉 comparing', a.platform, b.platform, 'diff', diff, 'tie', tie);
395+ // return tie;
396+ // });
397+ // console.log('👉 sorted hits', sortedPlatformHits.concat(nonPlatformHits));
398+ // return sortedPlatformHits;
399+ // }
0 commit comments