Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,4 @@ packages/*/*.tsbuildinfo
coverage/
.vscode/
.idea/
.gstack/
7 changes: 7 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
"prepare": "husky || true"
},
"dependencies": {
"@lobehub/icons-static-svg": "^1.91.0",
"ejs": "^3.1.10",
"express": "^4.19.2",
"js-yaml": "^4.1.0",
Expand Down
2 changes: 2 additions & 0 deletions src/build/build.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import { modelId, type Model } from "../schema/model.js";
import { buildModelJsonSchema } from "../schema/generate.js";
import { bundleClientScript, compileStyles, copyStaticAssets } from "./assets.js";
import { renderIndex } from "./render.js";
import { renderApiPage } from "./render-api.js";
import { renderGlossaryPage } from "./render-glossary.js";
import { renderModelPage } from "./render-model.js";
import { renderProviderPage } from "./render-provider.js";
Expand Down Expand Up @@ -93,6 +94,7 @@ async function writeHtmlPages(models: Model[]): Promise<void> {
}

await fs.writeFile(path.join(DIST_DIR, "glossary.html"), await renderGlossaryPage(models), "utf8");
await fs.writeFile(path.join(DIST_DIR, "api.html"), await renderApiPage(models), "utf8");
}

async function writeApiIndex(modelCount: number): Promise<void> {
Expand Down
28 changes: 28 additions & 0 deletions src/build/render-api.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import path from "node:path";
import ejs from "ejs";
import { VIEWS_DIR } from "../data/paths.js";
import { SITE_NAME, SITE_URL } from "../data/site.js";
import { absolute } from "../data/urls.js";
import { type Model } from "../schema/model.js";
import { hubLinks, renderShell, viewHelpers } from "./render.js";

const API_TITLE = `API documentation · ${SITE_NAME}`;
const API_DESCRIPTION =
"How to use the modelparams.dev JSON API, npm package, and provider logos. Static, CORS-enabled, served from the edge.";

export async function renderApiPage(allModels: Model[]): Promise<string> {
const body = await ejs.renderFile(path.join(VIEWS_DIR, "api.ejs"), {
helpers: viewHelpers,
});

return renderShell(
{
title: API_TITLE,
description: API_DESCRIPTION,
canonicalUrl: absolute(SITE_URL, "/api"),
structuredData: "{}",
providerHubs: hubLinks(allModels),
},
body,
);
}
1 change: 1 addition & 0 deletions src/build/render-model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ export async function renderModelPage(model: Model, allModels: Model[]): Promise
modelName: modelLabel(model),
providerPath: providerPagePath(model.provider),
jsonPath: modelJsonPath(model),
modelJson: JSON.stringify({ $schema: "https://modelparams.dev/api/v1/schema.json", ...model }, null, 2),
isSubscription: model.authType === "subscription",
});

Expand Down
8 changes: 8 additions & 0 deletions src/build/render.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
authLabel,
conditionIcon,
modelLabel,
paramGroupColor,

Check failure on line 9 in src/build/render.ts

View workflow job for this annotation

GitHub Actions / Lint + typecheck + test + build

Duplicate identifier 'paramGroupColor'.
paramGroupColor,

Check failure on line 10 in src/build/render.ts

View workflow job for this annotation

GitHub Actions / Lint + typecheck + test + build

Duplicate identifier 'paramGroupColor'.
paramGroupIcon,
paramGroupLabel,
paramLabel,
Expand All @@ -28,6 +30,7 @@
modelLabel,
providerLabel,
authLabel,
paramGroupColor,
paramGroupLabel,
paramGroupIcon,
paramLabel,
Expand All @@ -42,13 +45,17 @@
export interface HubLink {
href: string;
label: string;
provider: string;
count: number;
}

/** Sitewide footer links to each provider hub, ordered by model count. */
export function hubLinks(models: Model[]): HubLink[] {
return buildProviderFacets(models).map((facet) => ({
href: providerPagePath(facet.provider),
label: providerLabel(facet.provider),
provider: facet.provider,
count: facet.count,
}));
}

Expand All @@ -71,6 +78,7 @@
structuredData: meta.structuredData,
ogImageUrl: absolute(SITE_URL, OG_IMAGE_PATH),
providerHubs: meta.providerHubs,
helpers: viewHelpers,
usageGuide: usageGuideMarkdown(SITE_URL),
initialThemeClass: meta.initialThemeClass ?? "",
analytics: meta.analytics ?? false,
Expand Down
25 changes: 17 additions & 8 deletions src/client/favicon.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
22 changes: 22 additions & 0 deletions src/client/logo-full.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
19 changes: 19 additions & 0 deletions src/client/logo.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions src/client/logos/alibaba.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 1 addition & 3 deletions src/client/logos/anthropic.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
6 changes: 1 addition & 5 deletions src/client/logos/cohere.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 1 addition & 3 deletions src/client/logos/deepseek.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Loading