Skip to content

Commit 545c769

Browse files
authored
[WIP]
1 parent 77f675c commit 545c769

File tree

20 files changed

+579
-0
lines changed

20 files changed

+579
-0
lines changed
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
import partners from '#site/util/partners/constants.json' with { type: 'json' };
2+
3+
export const GET = async () => {
4+
const list = partners.map(({ ...data }) => {
5+
return data;
6+
});
7+
8+
return Response.json(list);
9+
};
10+
11+
// Enforces that this route is used as static rendering
12+
// Except whenever on the Development mode as we want instant-refresh when making changes
13+
// @see https://nextjs.org/docs/app/api-reference/file-conventions/route-segment-config#dynamic
14+
export const dynamic = 'force-static';
15+
16+
// Ensures that this endpoint is invalidated and re-executed every X minutes
17+
// so that when new deployments happen, the data is refreshed
18+
// @see https://nextjs.org/docs/app/api-reference/file-conventions/route-segment-config#revalidate
19+
export const revalidate = 5000;
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
import type { FC, ReactElement } from 'react';
2+
import { cloneElement } from 'react';
3+
4+
import type { Partners } from '#site/types';
5+
6+
import Button from '../../Button';
7+
8+
const PartnersIcon: FC<Partners> = ({ href, logo }) => {
9+
return (
10+
<Button href={href} kind="secondary">
11+
{cloneElement(logo as ReactElement)}
12+
</Button>
13+
);
14+
};
15+
16+
export default PartnersIcon;
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
'use client';
2+
3+
import { type FC } from 'react';
4+
5+
import type { Partners } from '#site/types';
6+
import { partnersList } from '#site/util/partners';
7+
import partnersData from '#site/util/partners/constants.json';
8+
9+
import PartnerIcon from '../PartnerIcon';
10+
11+
type PartnersIconListProps = {
12+
partners: Array<Partners>;
13+
maxLength?: number;
14+
};
15+
16+
const PartnersIconList: FC<PartnersIconListProps> = ({
17+
// @ts-expect-error I don't know
18+
partners = partnersList(partnersData),
19+
maxLength = 4,
20+
}) => {
21+
return (
22+
<div>
23+
{partners.slice(0, maxLength).map((supporter, index) => (
24+
<PartnerIcon {...supporter} key={index} />
25+
))}
26+
</div>
27+
);
28+
};
29+
30+
export default PartnersIconList;

apps/site/next.mdx.use.mjs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
import BadgeGroup from '@node-core/ui-components/Common/BadgeGroup';
44

5+
import PartnersIconList from './components/Common/Partners/PartnersIconList';
56
import DownloadReleasesTable from './components/Downloads/DownloadReleasesTable';
67
import UpcomingMeetings from './components/MDX/Calendar/UpcomingMeetings';
78
import WithBadgeGroup from './components/withBadgeGroup';
@@ -21,6 +22,7 @@ export const mdxComponents = {
2122
WithBanner,
2223
// HOC for providing Badge Data
2324
WithBadgeGroup,
25+
PartnersIconList,
2426
// Standalone Badge Group
2527
BadgeGroup,
2628
// Renders an container for Upcoming Node.js Meetings

apps/site/pages/en/about/partners.mdx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
---
2+
title: TODO
3+
layout: about
4+
---

apps/site/pages/en/index.mdx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,4 +137,6 @@ layout: home
137137
138138
</div>
139139
Learn more what Node.js is able to offer with our [Learning materials](/learn).
140+
141+
<PartnersIconList />
140142
</section>

apps/site/types/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ export * from './redirects';
1010
export * from './server';
1111
export * from './github';
1212
export * from './calendar';
13+
export * from './partners';
1314
export * from './author';
1415
export * from './download';
1516
export * from './userAgent';

apps/site/types/partners.ts

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
// import type { ReactElement, SVGProps } from 'react';
2+
3+
import type { ReactElement, SVGProps } from 'react';
4+
5+
export interface Partners {
6+
id: string;
7+
// The name of the partner
8+
name: string;
9+
// A logo to render on the partners page
10+
logo: ReactElement<SVGProps<SVGSVGElement>>;
11+
// The promoted link to their website or social media
12+
href: string;
13+
// The categories this partner belongs to
14+
categories: Array<PartnerCategory>;
15+
// An optional description of the partner
16+
description?: string;
17+
}
18+
19+
export type PartnerCategory = 'infrastructure' | 'security' | 'esp partner';
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
[
2+
{
3+
"id": "RACKSPACE",
4+
"name": "Rackspace",
5+
"href": "https://www.rackspace.com",
6+
"categories": ["infrastructure"]
7+
},
8+
{
9+
"id": "CLOUDFLARE",
10+
"name": "Cloudflare",
11+
"href": "https://www.cloudflare.com",
12+
"categories": ["infrastructure"]
13+
},
14+
{
15+
"id": "VERCEL",
16+
"name": "Vercel",
17+
"href": "https://vercel.com",
18+
"categories": ["infrastructure"]
19+
},
20+
{
21+
"id": "SENTRY",
22+
"name": "Sentry",
23+
"href": "https://sentry.io",
24+
"categories": ["infrastructure"]
25+
},
26+
{
27+
"id": "CROWDIN",
28+
"name": "Crowdin",
29+
"href": "https://crowdin.com",
30+
"categories": ["infrastructure"]
31+
},
32+
{
33+
"id": "HERODEVS",
34+
"name": "HeroDevs",
35+
"href": "https://herodevs.com",
36+
"categories": ["security", "esp partner"]
37+
},
38+
{
39+
"id": "NODESOURCE",
40+
"name": "NodeSource",
41+
"href": "https://nodesource.com",
42+
"categories": ["security"]
43+
},
44+
{
45+
"id": "DATADOG",
46+
"name": "Datadog",
47+
"href": "https://www.datadoghq.com",
48+
"categories": ["security"]
49+
}
50+
]

apps/site/util/partners/index.tsx

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
import * as PartnersLogo from '@node-core/ui-components/Icons/PartnerLogos';
2+
import type { ElementType } from 'react';
3+
4+
import type { Partners } from '#site/types';
5+
6+
// import partners from './constants.json';
7+
8+
/**
9+
* Creates an icon element for a component
10+
*/
11+
const createIcon = (
12+
IconModule: Record<string, ElementType>,
13+
iconName: string
14+
) => {
15+
const IconComponent = IconModule[iconName];
16+
return <IconComponent width={16} height={16} />;
17+
};
18+
19+
// Package Manager dropdown items
20+
export const partnersList = (partnerLists: Array<Omit<Partners, 'logo'>>) =>
21+
partnerLists.map(({ id, ...partner }) => {
22+
return {
23+
id: id,
24+
logo: createIcon(PartnersLogo, id),
25+
...partner,
26+
};
27+
});

0 commit comments

Comments
 (0)