From 4bfc89302fb54fe0a393f7210aa5f487bcaf394c Mon Sep 17 00:00:00 2001 From: tresabhi <43380238+tresabhi@users.noreply.github.com> Date: Wed, 19 Mar 2025 00:48:35 -0500 Subject: [PATCH] feat: test button --- .../src/pages/[...locale]/api/_index.tsx | 35 +++++--- .../src/pages/[...locale]/api/index.astro | 84 +++++++++++-------- .../src/pages/api/gallery/[avatar].webp.ts | 3 +- .../website/src/pages/api/tanks/[id].json.ts | 5 +- 4 files changed, 82 insertions(+), 45 deletions(-) diff --git a/packages/website/src/pages/[...locale]/api/_index.tsx b/packages/website/src/pages/[...locale]/api/_index.tsx index 9e13dc3ec..99099c18d 100644 --- a/packages/website/src/pages/[...locale]/api/_index.tsx +++ b/packages/website/src/pages/[...locale]/api/_index.tsx @@ -1,14 +1,16 @@ -import { Code, Link, Table } from '@radix-ui/themes'; +import { OpenInNewWindowIcon } from '@radix-ui/react-icons'; +import { Code, IconButton, Link, Table } from '@radix-ui/themes'; import { useState } from 'react'; import type { APIPath } from './index.astro'; interface SlugsTableProps { slugs: APIPath['slugs']; + path: string; } const MAX_UNEXPANDED = 5; -export function SlugsTable({ slugs }: SlugsTableProps) { +export function SlugsTable({ slugs, path }: SlugsTableProps) { if (slugs === undefined) return null; const [expanded, setExpanded] = useState(false); @@ -17,25 +19,29 @@ export function SlugsTable({ slugs }: SlugsTableProps) { - - - # - - + # {slugs.titles.map((title) => ( - - {title} - + {title} ))} + + Test {slugs.groups.map((group, groupIndex) => { if (!expanded && groupIndex >= MAX_UNEXPANDED) return null; + let draftPath = path; + + slugs.titles.forEach((title) => { + draftPath = draftPath.replace( + `[${title}]`, + `${group[title] ?? ''}`, + ); + }); return ( @@ -52,12 +58,21 @@ export function SlugsTable({ slugs }: SlugsTableProps) { ))} + + + + + + + + ); })} + a.path.localeCompare(b.path)); --- - + { apis.map((api, index) => ( <> - - - {api.path} - - - - - {api.comment} - + + + {api.path} + + {!api.slugs && ( + + )} + + + + + {api.comment} {api.tags.length > 0 && ( - {api.tags.map(({ tag, description, discriminator }) => ( - - - {tag} - + {api.tags.map(({ tag, description, discriminator }) => { + let color: CodeProps['color'] | undefined = undefined; - {discriminator && ( - - {discriminator} - - )} + switch (tag) { + case '@warning': + color = 'amber'; + break; + } - {description && ( - - {description} + return ( + + + {tag} - )} - - ))} + + {discriminator && ( + + {discriminator} + + )} + + {description && {description}} + + ); + })} )} - + {index < apis.length - 1 && ( diff --git a/packages/website/src/pages/api/gallery/[avatar].webp.ts b/packages/website/src/pages/api/gallery/[avatar].webp.ts index fbd147204..15a20f9e2 100644 --- a/packages/website/src/pages/api/gallery/[avatar].webp.ts +++ b/packages/website/src/pages/api/gallery/[avatar].webp.ts @@ -15,7 +15,8 @@ export const getStaticPaths = (async () => { const glossary = await fetchGlossary(DEFAULT_LOCALE); /** - * Returns an in-game avatar image. + * Returns an in-game avatar image. Use gallery/list.json to get all valid ids. + * Not all ids may have images due to poor Wargaming CDNs. * * @param avatar The avatar id. * @returns A webp image. diff --git a/packages/website/src/pages/api/tanks/[id].json.ts b/packages/website/src/pages/api/tanks/[id].json.ts index 044f0d360..c3b7eaa8a 100644 --- a/packages/website/src/pages/api/tanks/[id].json.ts +++ b/packages/website/src/pages/api/tanks/[id].json.ts @@ -7,7 +7,10 @@ export const getStaticPaths = (async () => { }) satisfies GetStaticPaths; /** - * Returns the meta data on a tank which includes its modules, characteristics, ancestry, descendants, equipment, characteristics, etc. However, this does not include information on the tank model. + * Returns the meta data on a tank which includes its modules, characteristics, + * ancestry, descendants, equipment, characteristics, etc. However, this does + * not include information on the tank model. Use tanks/list.json to get all + * valid ids. * * @param avatar The avatar id. * @returns A webp image.