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
3 changes: 3 additions & 0 deletions src/components/docs/RateLimits.astro
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@ const lang = Astro.url.pathname.startsWith('/es/') ? 'es' : 'en';
const T = rateLimitsLabels(lang);
---

<!-- The h2 gives the card stack a place in the docs layout's 'On this page' index, which is scraped from rendered h2/h3 (see Docs.astro): without it the rate limits section was invisible there. -->
<h2 id="rate-limits" data-toc-text={T.sectionHeading}>{T.sectionHeading}</h2>

<div class="rounded-xl border border-neutral-800/60 bg-[#0a0a0a] p-6 mb-6">
<p class="font-mono text-[10px] text-violet-400 uppercase tracking-widest mb-4">
{T.perKey}
Expand Down
6 changes: 6 additions & 0 deletions src/lib/rateLimits.ts
Original file line number Diff line number Diff line change
Expand Up @@ -410,6 +410,11 @@ export function rateLimitsToSpecMarkdown(config: RateLimitsConfig): string {
export function rateLimitsLabels(lang: DocsLocale) {
return {
en: {
// The section heading above the card stack. RateLimits renders it as a real
// h2 because the docs layout builds "On this page" by scraping rendered
// h2/h3 — the card stack had no heading at all, so /docs/models' TOC never
// mentioned the rate limits. data-toc-text keeps the TOC entry readable.
sectionHeading: 'Rate limits',
perKey: 'rate limits per API key',
requestsPerMin: 'Requests / min',
// The per-key concurrency row: concurrency is enforced per model, so the
Expand Down Expand Up @@ -439,6 +444,7 @@ export function rateLimitsLabels(lang: DocsLocale) {
tierPremium: 'premium plan',
},
es: {
sectionHeading: 'Límites de peticiones',
perKey: 'límites por API key',
requestsPerMin: 'Peticiones / min',
perKeyConcurrency: 'Peticiones en paralelo',
Expand Down
14 changes: 14 additions & 0 deletions src/lib/rateLimitsI18n.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ function wordsIn(text: string, words: string[]): string[] {
function visible(lang: 'en' | 'es'): string {
const t = rateLimitsLabels(lang);
return [
t.sectionHeading,
t.perKey,
t.requestsPerMin,
t.perKeyConcurrency,
Expand Down Expand Up @@ -135,6 +136,19 @@ describe('the card renders no hardcoded copy', () => {
expect(markup).toContain('{T.perKeyAcrossModels}');
expect(markup).toContain('{T.concurrencyPointer}');
});

it('gives the card stack a heading the On this page index can find', () => {
// The docs layout builds "On this page" client-side by scraping rendered
// h2/h3 inside .docs-content (Docs.astro). The card stack had no heading
// at all, so /docs/models' TOC never mentioned the rate limits. The
// heading must stay an h2 carrying data-toc-text, and its text must come
// from the label table so each locale keeps its own wording.
const here = dirname(fileURLToPath(import.meta.url));
const source = readFileSync(resolve(here, '../components/docs/RateLimits.astro'), 'utf-8');
const markup = source.slice(source.lastIndexOf('---') + 3);
expect(markup).toContain('<h2 id="rate-limits" data-toc-text={T.sectionHeading}>');
expect(markup).toContain('{T.sectionHeading}</h2>');
});
});

/**
Expand Down
Loading