Load the full free Google Fonts gallery in Zona de marca typography.
Browse ~1950 OFL fonts with search, category filters and live preview; one click adds a font to the brand kit. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
44
src/app/api/brandbook/google-fonts/route.ts
Normal file
44
src/app/api/brandbook/google-fonts/route.ts
Normal file
@@ -0,0 +1,44 @@
|
||||
/**
|
||||
* GET ?q=&category=&limit=&offset= — full free Google Fonts catalog.
|
||||
*/
|
||||
import { NextRequest, NextResponse } from 'next/server';
|
||||
import { createClient } from '@/lib/supabase/server';
|
||||
import { listGoogleFonts } from '@/lib/google-fonts-catalog';
|
||||
|
||||
export const dynamic = 'force-dynamic';
|
||||
|
||||
export async function GET(req: NextRequest) {
|
||||
const supabase = await createClient();
|
||||
const {
|
||||
data: { user },
|
||||
} = await supabase.auth.getUser();
|
||||
if (!user) {
|
||||
return NextResponse.json({ error: 'Unauthorized' }, { status: 401 });
|
||||
}
|
||||
|
||||
const sp = req.nextUrl.searchParams;
|
||||
try {
|
||||
const result = await listGoogleFonts({
|
||||
q: sp.get('q') || undefined,
|
||||
category: sp.get('category') || undefined,
|
||||
limit: Number(sp.get('limit') || 80) || 80,
|
||||
offset: Number(sp.get('offset') || 0) || 0,
|
||||
});
|
||||
return NextResponse.json({
|
||||
ok: true,
|
||||
source: 'google-fonts',
|
||||
license: 'All Google Fonts are free and open source (OFL / Apache / Ubuntu…)',
|
||||
...result,
|
||||
});
|
||||
} catch (e) {
|
||||
return NextResponse.json(
|
||||
{
|
||||
error:
|
||||
e instanceof Error
|
||||
? e.message
|
||||
: 'No se pudo cargar el catálogo de Google Fonts',
|
||||
},
|
||||
{ status: 502 }
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user