-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
/
Copy pathhome.tsx
73 lines (64 loc) · 1.72 KB
/
home.tsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
import {notFound} from 'next/navigation';
import {extractPlatforms, getDocsRootNode} from 'sentry-docs/docTree';
import {Platform, PlatformGuide} from 'sentry-docs/types';
import {HomeClient} from './homeClient';
const HIGHLIGHTED_PLATFORMS = [
'javascript',
'node',
'python',
'php',
'ruby',
'java',
'javascript.react',
'react-native',
'python.django',
'dotnet',
'go',
'php.laravel',
'android',
'apple',
'javascript.nextjs',
'ruby.rails',
'flutter',
'unity',
'unreal',
];
export async function Home() {
const rootNode = await getDocsRootNode();
if (!rootNode) {
console.warn('no root node');
return notFound();
}
const platformList = extractPlatforms(rootNode);
let totalPlatformCount = 0;
const visiblePlatforms: Array<Platform | PlatformGuide> = [];
platformList.forEach(platform => {
totalPlatformCount += 1;
if (HIGHLIGHTED_PLATFORMS.indexOf(platform.key) !== -1) {
visiblePlatforms.push(platform);
}
platform.guides?.forEach(guide => {
totalPlatformCount += 1;
if (HIGHLIGHTED_PLATFORMS.indexOf(guide.key) !== -1) {
visiblePlatforms.push(guide);
}
});
});
visiblePlatforms.sort(
(a, b) => HIGHLIGHTED_PLATFORMS.indexOf(a.key) - HIGHLIGHTED_PLATFORMS.indexOf(b.key)
);
// this regex deals with names like .NET that would otherwise be sorted at the top
const leadingNonAlphaRegex = /^[^\w]/;
platformList.sort((a, b) =>
(a.title ?? a.name)
.replace(leadingNonAlphaRegex, '')
.localeCompare((b.title ?? b.name).replace(leadingNonAlphaRegex, ''))
);
return (
<HomeClient
visiblePlatforms={visiblePlatforms}
totalPlatformCount={totalPlatformCount}
platforms={platformList}
/>
);
}