Spaces:
Build error
Build error
tokens saved grid
Browse files
docs/components/community-stats-header.tsx
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import { fetchCommunityStats, fmtNum, fmtUsd } from '@/lib/telemetry';
|
| 2 |
+
|
| 3 |
+
/**
|
| 4 |
+
* Server component that renders the top-level stats for the community savings page.
|
| 5 |
+
* Fetches live data from Supabase at render time.
|
| 6 |
+
*/
|
| 7 |
+
export async function CommunityStatsHeader() {
|
| 8 |
+
const data = await fetchCommunityStats();
|
| 9 |
+
|
| 10 |
+
const stats = [
|
| 11 |
+
{ value: fmtNum(data.total_tokens_saved), label: 'Tokens Saved' },
|
| 12 |
+
{ value: fmtUsd(data.total_cost_saved), label: 'Cost Saved' },
|
| 13 |
+
{ value: fmtNum(data.total_requests), label: 'Requests Optimized' },
|
| 14 |
+
{ value: fmtNum(data.unique_instances), label: 'Active Instances' },
|
| 15 |
+
];
|
| 16 |
+
|
| 17 |
+
return (
|
| 18 |
+
<div className="grid grid-cols-2 md:grid-cols-4 gap-4 not-prose">
|
| 19 |
+
{stats.map((s) => (
|
| 20 |
+
<div
|
| 21 |
+
key={s.label}
|
| 22 |
+
className="flex flex-col items-center p-5 rounded-xl border border-fd-border bg-fd-card"
|
| 23 |
+
>
|
| 24 |
+
<span className="text-2xl font-bold text-fd-foreground">
|
| 25 |
+
{s.value}
|
| 26 |
+
</span>
|
| 27 |
+
<span className="mt-1 text-sm text-fd-muted-foreground">
|
| 28 |
+
{s.label}
|
| 29 |
+
</span>
|
| 30 |
+
</div>
|
| 31 |
+
))}
|
| 32 |
+
</div>
|
| 33 |
+
);
|
| 34 |
+
}
|
docs/components/live-stats.tsx
ADDED
|
@@ -0,0 +1,43 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import Link from 'next/link';
|
| 2 |
+
import { fetchCommunityStats, fmtNum, fmtUsd } from '@/lib/telemetry';
|
| 3 |
+
|
| 4 |
+
/**
|
| 5 |
+
* Server component that fetches live stats from Supabase at render time.
|
| 6 |
+
* Falls back to hardcoded data if the API is unreachable.
|
| 7 |
+
*/
|
| 8 |
+
export async function LiveStats() {
|
| 9 |
+
const data = await fetchCommunityStats();
|
| 10 |
+
|
| 11 |
+
const stats = [
|
| 12 |
+
{ value: fmtNum(data.total_tokens_saved), label: 'Tokens Saved' },
|
| 13 |
+
{ value: fmtUsd(data.total_cost_saved), label: 'Cost Saved' },
|
| 14 |
+
{ value: fmtNum(data.total_requests), label: 'Requests Optimized' },
|
| 15 |
+
{ value: fmtNum(data.unique_instances), label: 'Active Instances' },
|
| 16 |
+
];
|
| 17 |
+
|
| 18 |
+
return (
|
| 19 |
+
<div className="not-prose">
|
| 20 |
+
<div className="grid grid-cols-2 md:grid-cols-4 gap-4 my-8">
|
| 21 |
+
{stats.map((s) => (
|
| 22 |
+
<div
|
| 23 |
+
key={s.label}
|
| 24 |
+
className="flex flex-col items-center p-5 rounded-xl border border-fd-border bg-fd-card"
|
| 25 |
+
>
|
| 26 |
+
<span className="text-2xl font-bold text-fd-foreground">
|
| 27 |
+
{s.value}
|
| 28 |
+
</span>
|
| 29 |
+
<span className="mt-1 text-sm text-fd-muted-foreground">
|
| 30 |
+
{s.label}
|
| 31 |
+
</span>
|
| 32 |
+
</div>
|
| 33 |
+
))}
|
| 34 |
+
</div>
|
| 35 |
+
<Link
|
| 36 |
+
href="/docs/community-savings"
|
| 37 |
+
className="text-sm font-medium hover:underline"
|
| 38 |
+
>
|
| 39 |
+
View detailed charts and breakdowns →
|
| 40 |
+
</Link>
|
| 41 |
+
</div>
|
| 42 |
+
);
|
| 43 |
+
}
|
docs/components/mdx.tsx
CHANGED
|
@@ -6,10 +6,11 @@ import { createGenerator } from 'fumadocs-typescript';
|
|
| 6 |
import { TypeTable } from 'fumadocs-ui/components/type-table';
|
| 7 |
import { Tab, Tabs } from 'fumadocs-ui/components/tabs';
|
| 8 |
import {
|
| 9 |
-
LiveStats,
|
| 10 |
KeyFeatures,
|
| 11 |
FrameworkIntegrations,
|
| 12 |
} from './marketing';
|
|
|
|
|
|
|
| 13 |
import { StatsSection } from './stats';
|
| 14 |
import { CommunityCharts } from './community-charts';
|
| 15 |
|
|
@@ -27,6 +28,7 @@ export function getMDXComponents(components?: MDXComponents) {
|
|
| 27 |
Tabs,
|
| 28 |
StatsSection,
|
| 29 |
CommunityCharts,
|
|
|
|
| 30 |
LiveStats,
|
| 31 |
KeyFeatures,
|
| 32 |
FrameworkIntegrations,
|
|
|
|
| 6 |
import { TypeTable } from 'fumadocs-ui/components/type-table';
|
| 7 |
import { Tab, Tabs } from 'fumadocs-ui/components/tabs';
|
| 8 |
import {
|
|
|
|
| 9 |
KeyFeatures,
|
| 10 |
FrameworkIntegrations,
|
| 11 |
} from './marketing';
|
| 12 |
+
import { LiveStats } from './live-stats';
|
| 13 |
+
import { CommunityStatsHeader } from './community-stats-header';
|
| 14 |
import { StatsSection } from './stats';
|
| 15 |
import { CommunityCharts } from './community-charts';
|
| 16 |
|
|
|
|
| 28 |
Tabs,
|
| 29 |
StatsSection,
|
| 30 |
CommunityCharts,
|
| 31 |
+
CommunityStatsHeader,
|
| 32 |
LiveStats,
|
| 33 |
KeyFeatures,
|
| 34 |
FrameworkIntegrations,
|
docs/content/docs/community-savings.mdx
CHANGED
|
@@ -7,7 +7,7 @@ Real-time aggregate metrics from Headroom proxy instances worldwide. All data is
|
|
| 7 |
|
| 8 |
## Overview
|
| 9 |
|
| 10 |
-
<
|
| 11 |
|
| 12 |
## Savings Over Time
|
| 13 |
|
|
|
|
| 7 |
|
| 8 |
## Overview
|
| 9 |
|
| 10 |
+
<CommunityStatsHeader />
|
| 11 |
|
| 12 |
## Savings Over Time
|
| 13 |
|