-
-
Notifications
You must be signed in to change notification settings - Fork 6.3k
/
Copy pathwithDownloadCategories.tsx
61 lines (55 loc) · 1.96 KB
/
withDownloadCategories.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
import { getTranslations } from 'next-intl/server';
import type { FC, PropsWithChildren } from 'react';
import LinkTabs from '@/components/Common/LinkTabs';
import WithNodeRelease from '@/components/withNodeRelease';
import { useClientContext } from '@/hooks/react-server';
import getReleaseData from '@/next-data/releaseData';
import { ReleaseProvider } from '@/providers/releaseProvider';
import type { NodeReleaseStatus } from '@/types';
import { getDownloadCategory, mapCategoriesToTabs } from '@/util/downloadUtils';
const WithDownloadCategories: FC<PropsWithChildren> = async ({ children }) => {
const t = await getTranslations();
const releases = await getReleaseData();
const { pathname } = useClientContext();
const { page, category, subCategory } = getDownloadCategory(pathname);
const initialRelease: Array<NodeReleaseStatus> = pathname.includes('current')
? ['Current']
: ['Active LTS', 'Maintenance LTS'];
return (
<LinkTabs
activeTab={category}
label={t('layouts.download.selectCategory')}
tabs={mapCategoriesToTabs({
page: page,
categories: [
{
category: 'download',
label: t('layouts.download.categories.download'),
},
{
category: 'prebuilt-binaries',
label: t('layouts.download.categories.prebuilt-binaries'),
},
{
category: 'package-manager',
label: t('layouts.download.categories.package-manager'),
},
{
category: 'source-code',
label: t('layouts.download.categories.source-code'),
},
],
subCategory: subCategory,
})}
>
<WithNodeRelease status={initialRelease}>
{({ release }) => (
<ReleaseProvider initialRelease={release} releases={releases}>
{children}
</ReleaseProvider>
)}
</WithNodeRelease>
</LinkTabs>
);
};
export default WithDownloadCategories;