Skip to content

Commit 134b151

Browse files
authored
Revert "fixup!"
This reverts commit b6ad990.
1 parent a223af8 commit 134b151

File tree

6 files changed

+137
-85
lines changed

6 files changed

+137
-85
lines changed

apps/site/components/Common/Partners/PartnerButton/index.module.css

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,8 @@
2121
.small {
2222
@apply h-9
2323
w-auto
24-
min-w-9;
24+
min-w-9
25+
p-2;
2526

2627
svg {
2728
@apply !h-4

apps/site/package.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -50,16 +50,16 @@
5050
"@types/node": "catalog:",
5151
"@types/react": "catalog:",
5252
"@vcarl/remark-headings": "~0.1.0",
53-
"@vercel/analytics": "~1.5.0",
53+
"@vercel/analytics": "~1.6.1",
5454
"@vercel/otel": "~2.1.0",
55-
"@vercel/speed-insights": "~1.2.0",
55+
"@vercel/speed-insights": "~1.3.1",
5656
"classnames": "catalog:",
5757
"cross-env": "catalog:",
5858
"feed": "~5.1.0",
5959
"github-slugger": "~2.0.0",
6060
"gray-matter": "~4.0.3",
6161
"mdast-util-to-string": "^4.0.0",
62-
"next": "16.0.10",
62+
"next": "16.1.0",
6363
"next-intl": "~4.5.3",
6464
"next-themes": "~0.4.6",
6565
"postcss-calc": "~10.1.1",
@@ -80,7 +80,7 @@
8080
},
8181
"devDependencies": {
8282
"@flarelabs-net/wrangler-build-time-fs-assets-polyfilling": "^0.0.1",
83-
"@next/eslint-plugin-next": "16.0.7",
83+
"@next/eslint-plugin-next": "16.1.0",
8484
"@node-core/remark-lint": "workspace:*",
8585
"@opennextjs/cloudflare": "^1.14.4",
8686
"@playwright/test": "^1.56.1",

apps/site/public/static/partners/constants.json

Lines changed: 23 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -3,48 +3,56 @@
33
"id": "CLOUDFLARE",
44
"name": "Cloudflare",
55
"href": "https://www.cloudflare.com",
6+
"weight": 3,
7+
"categories": ["infrastructure"]
8+
},
9+
{
10+
"id": "VERCEL",
11+
"name": "Vercel",
12+
"href": "https://vercel.com",
13+
"weight": 2,
614
"categories": ["infrastructure"]
715
},
816
{
917
"id": "HERODEVS",
1018
"name": "HeroDevs",
1119
"href": "https://herodevs.com",
20+
"weight": 3,
1221
"categories": ["security", "esp", "release"]
1322
},
1423
{
1524
"id": "DIGITALOCEAN",
1625
"name": "DigitalOcean",
1726
"href": "https://www.digitalocean.com",
18-
"categories": ["infrastructure"]
19-
},
20-
{
21-
"id": "NODESOURCE",
22-
"name": "NodeSource",
23-
"href": "https://nodesource.com",
24-
"categories": ["security", "esp", "release"]
25-
},
26-
{
27-
"id": "VERCEL",
28-
"name": "Vercel",
29-
"href": "https://vercel.com",
30-
"categories": ["infrastructure"]
27+
"categories": ["infrastructure"],
28+
"weight": 3
3129
},
3230
{
3331
"id": "MICROSOFT",
3432
"name": "Microsoft Azure",
3533
"href": "https://microsoft.com",
36-
"categories": ["infrastructure"]
34+
"categories": ["infrastructure"],
35+
"weight": 2
3736
},
3837
{
3938
"id": "MACSTADIUM",
4039
"name": "MacStadium",
4140
"href": "https://macstadium.com",
42-
"categories": ["infrastructure"]
41+
"categories": ["infrastructure"],
42+
"weight": 2
43+
},
44+
{
45+
"id": "NODESOURCE",
46+
"name": "NodeSource",
47+
"href": "https://nodesource.com",
48+
"weight": 3,
49+
"categories": ["security", "esp", "release"]
4350
},
4451
{
4552
"id": "CODEMOD",
4653
"name": "Codemod",
4754
"href": "https://codemod.com",
55+
"weight": 1,
4856
"categories": []
4957
}
5058
]

apps/site/util/array.ts

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
// Fisher-Yates shuffle algorithm with a seed for deterministic results
2+
export const shuffle = async <T>(
3+
array: Array<T>,
4+
seed: number
5+
): Promise<Array<T>> => {
6+
const shuffled = [...array];
7+
const encoder = new TextEncoder();
8+
const buffer = encoder.encode(String(seed));
9+
const hashBuffer = await crypto.subtle.digest('SHA-256', buffer);
10+
const hash = new Uint8Array(hashBuffer);
11+
12+
for (let i = shuffled.length - 1; i > 0; i--) {
13+
// Use hash bytes to generate deterministic "random" index
14+
const hashIndex = (i + seed) % 32;
15+
// Normalize to 0-1
16+
const randomValue = hash[hashIndex] / 255;
17+
18+
const j = Math.floor(randomValue * (i + 1));
19+
[shuffled[i], shuffled[j]] = [shuffled[j], shuffled[i]];
20+
}
21+
22+
return shuffled;
23+
};

docs/partners.md

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ To add or remove a partner:
1515
- `categories`: An array of categories the partner belongs to. These are used to filter partners on the Partners and Downloads pages. Valid categories include:
1616
- `infrastructure`: Partners providing infrastructure for the Node.js project.
1717
- `esp`: Partners offering support for EOL Node.js versions through the Ecosystem Sustainability Program (ESP).
18+
- `weight`: A number representing the partner's visibility weight. This is used in the randomization algorithm — higher values increase the partner's likelihood of being shown.
1819

1920
2. Add the partner's logo to the `packages/ui-components/icons/PartnersLogos/` directory.
2021
The filename must match the partner's `id`, in lowercase.
@@ -28,7 +29,7 @@ To add or remove a partner:
2829

2930
## Home Page
3031

31-
On the homepage, partners are displayed regardless of category. Partners are sorted according to their order in the `partners.json` file.
32+
On the homepage, all partners are displayed regardless of category. The `weight` field is used by the randomization algorithm to determine how likely a partner is to appear e.g., a partner with a `weight` of 3 will be three times more likely to be shown than one with a `weight` of 1.
3233

3334
## Partners Page
3435

@@ -52,3 +53,14 @@ The same randomization algorithm used on the homepage is applied here as well.
5253
> Donations made through GitHub Sponsors are not displayed yet; they will be added soon.
5354
5455
Supporters are individuals and organizations that provide financial support to the Node.js project through OpenCollective and GitHub Sponsors. They are displayed on the Partner page, but not on the homepage or Downloads section.
56+
57+
## Partner Randomization Algorithm
58+
59+
The randomization algorithm determines the order in which partners are displayed on both the homepage and the Downloads section. It takes into account:
60+
61+
- The `weight` of each partner (higher weight = higher probability of being shown).
62+
- A time-based seed: the order is refreshed every 5 minutes, not on every request.
63+
This ensures that the display remains consistent for a short period, rather than changing constantly. E.g., if a user visits the homepage multiple times within 5 minutes, they will see the same order of partners.
64+
65+
> [!NOTE]
66+
> Partner randomization and rendering is performed on the client side, not during server-side rendering (SSR).

0 commit comments

Comments
 (0)