Skip to content

Commit 2ea179e

Browse files
committed
try again
1 parent e0c903c commit 2ea179e

File tree

5 files changed

+54
-24
lines changed

5 files changed

+54
-24
lines changed

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,4 +27,5 @@ pnpm-debug.log*
2727
/assets/secrets
2828
/worker/functions/
2929

30-
.idea
30+
.idea
31+
/public/*

package-lock.json

Lines changed: 21 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
"devDependencies": {
2828
"@actions/core": "1.11.1",
2929
"@actions/github": "6.0.0",
30+
"@anthropic-ai/claude-code": "0.2.59",
3031
"@apidevtools/swagger-parser": "10.1.1",
3132
"@astrojs/check": "0.9.4",
3233
"@astrojs/react": "4.2.1",

src/components/ModelCatalog.tsx

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { useEffect, useState } from "react";
1+
import { useEffect, useState, useMemo } from "react";
22
import ModelInfo from "./models/ModelInfo";
33
import ModelBadges from "./models/ModelBadges";
44
import { authorData } from "./models/data";
@@ -25,28 +25,28 @@ const ModelCatalog = ({ models }: { models: WorkersAIModelsSchema[] }) => {
2525
"@cf/meta/llama-3.1-8b-instruct-fast",
2626
];
2727

28-
// Sort models by pinned status first, then by created_at date
29-
const sortedModels = [...models].sort((a, b) => {
30-
// First check if either model is pinned
31-
const isPinnedA = pinnedModelNames.includes(a.name);
32-
const isPinnedB = pinnedModelNames.includes(b.name);
33-
34-
// If pinned status differs, prioritize pinned models
35-
if (isPinnedA && !isPinnedB) return -1;
36-
if (!isPinnedA && isPinnedB) return 1;
37-
38-
// If both are pinned, sort by position in pinnedModelNames array (for manual ordering)
39-
if (isPinnedA && isPinnedB) {
40-
return (
41-
pinnedModelNames.indexOf(a.name) - pinnedModelNames.indexOf(b.name)
42-
);
43-
}
28+
// Only sort by pinned status (models should already be sorted by created_at in index.astro)
29+
const sortedModels = useMemo(() => {
30+
return [...models].sort((a, b) => {
31+
// First check if either model is pinned
32+
const isPinnedA = pinnedModelNames.includes(a.name);
33+
const isPinnedB = pinnedModelNames.includes(b.name);
34+
35+
// If pinned status differs, prioritize pinned models
36+
if (isPinnedA && !isPinnedB) return -1;
37+
if (!isPinnedA && isPinnedB) return 1;
38+
39+
// If both are pinned, sort by position in pinnedModelNames array (for manual ordering)
40+
if (isPinnedA && isPinnedB) {
41+
return (
42+
pinnedModelNames.indexOf(a.name) - pinnedModelNames.indexOf(b.name)
43+
);
44+
}
4445

45-
// If neither is pinned, sort by created_at date (newest first)
46-
const dateA = a.created_at ? new Date(a.created_at) : new Date(0);
47-
const dateB = b.created_at ? new Date(b.created_at) : new Date(0);
48-
return dateB.getTime() - dateA.getTime();
49-
});
46+
// For non-pinned models, maintain the original order
47+
return 0;
48+
});
49+
}, [models]);
5050

5151
useEffect(() => {
5252
const params = new URLSearchParams(window.location.search);

src/pages/workers-ai/models/index.astro

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,14 @@ import StarlightPage from "@astrojs/starlight/components/StarlightPage.astro";
55
import ModelCatalog from "~/components/ModelCatalog.tsx";
66
77
const modelData = await getCollection("workers-ai-models");
8-
const models = modelData.map(({ data }) => data);
8+
let models = modelData.map(({ data }) => data);
9+
10+
// Sort models by created_at date (newest first)
11+
models = models.sort((a, b) => {
12+
const dateA = a.created_at ? new Date(a.created_at) : new Date(0);
13+
const dateB = b.created_at ? new Date(b.created_at) : new Date(0);
14+
return dateB.getTime() - dateA.getTime();
15+
});
916
---
1017

1118
<StarlightPage frontmatter={{ title: "Models", tableOfContents: false }}>

0 commit comments

Comments
 (0)