2026-02-14 10:30:27 +01:00
|
|
|
|
/**
|
|
|
|
|
|
* Dynamic OG image generator — renders social share previews.
|
|
|
|
|
|
* Uses next/og (ImageResponse) to create 1200×630 cards.
|
feat: theming system, documentation, and photo grid regression tests
- Add configurable theme system with 4 presets (studio, minimal, editorial, classic)
- Theme controls fonts, colors, accent, photo frames, grain, and header dot
- Resolve themes from gallery.yaml: string shorthand or full object override
- Inject theme as CSS custom properties on <html> element
- Dynamic Google Fonts loading based on theme config
- OG image route reads accent/background from theme
- Refactor Studio overrides into conditional CSS via data-attributes
Documentation:
- Add docs/gallery-config.md with comprehensive configuration reference
- Add docs/theming.md with preset reference and custom theme guide
- Slim README to link to detailed docs
Fix CSS regression:
- Fix passepartout frame overflow:visible breaking next/image fill rendering
- Remove duplicate .photo-grid__item block that stripped overflow:hidden
Testing:
- Add e2e/photo-grid.spec.ts with 3 regression tests:
- Grid items render with real dimensions
- overflow:hidden CSS guard (catches the exact bug fixed)
- Images load with real pixel data (not blurhash)
Tooling:
- Add scripts/screenshots.ts for automated theme screenshot generation
- Handles dev server lifecycle, theme cycling, FadeIn + lazy image handling
2026-02-15 12:21:02 +01:00
|
|
|
|
* Reads accent color from theme config.
|
2026-02-14 10:30:27 +01:00
|
|
|
|
*
|
|
|
|
|
|
* GET /api/og?title=Album+Name&subtitle=12+photos
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
import { ImageResponse } from 'next/og';
|
2026-03-27 10:36:25 +01:00
|
|
|
|
import { NextRequest, NextResponse } from 'next/server';
|
feat: theming system, documentation, and photo grid regression tests
- Add configurable theme system with 4 presets (studio, minimal, editorial, classic)
- Theme controls fonts, colors, accent, photo frames, grain, and header dot
- Resolve themes from gallery.yaml: string shorthand or full object override
- Inject theme as CSS custom properties on <html> element
- Dynamic Google Fonts loading based on theme config
- OG image route reads accent/background from theme
- Refactor Studio overrides into conditional CSS via data-attributes
Documentation:
- Add docs/gallery-config.md with comprehensive configuration reference
- Add docs/theming.md with preset reference and custom theme guide
- Slim README to link to detailed docs
Fix CSS regression:
- Fix passepartout frame overflow:visible breaking next/image fill rendering
- Remove duplicate .photo-grid__item block that stripped overflow:hidden
Testing:
- Add e2e/photo-grid.spec.ts with 3 regression tests:
- Grid items render with real dimensions
- overflow:hidden CSS guard (catches the exact bug fixed)
- Images load with real pixel data (not blurhash)
Tooling:
- Add scripts/screenshots.ts for automated theme screenshot generation
- Handles dev server lifecycle, theme cycling, FadeIn + lazy image handling
2026-02-15 12:21:02 +01:00
|
|
|
|
import { getConfig } from '@/lib/config';
|
2026-03-27 10:36:25 +01:00
|
|
|
|
import { checkRateLimit, getClientIp } from '@/lib/rate-limit';
|
2026-02-14 10:30:27 +01:00
|
|
|
|
|
|
|
|
|
|
export async function GET(request: NextRequest) {
|
2026-03-27 10:36:25 +01:00
|
|
|
|
const ip = getClientIp(request);
|
|
|
|
|
|
const { theme, rateLimitRpm } = getConfig();
|
|
|
|
|
|
|
|
|
|
|
|
const { success } = checkRateLimit(`og:${ip}`, rateLimitRpm);
|
|
|
|
|
|
if (!success) {
|
|
|
|
|
|
return new NextResponse('Too many requests', { status: 429 });
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2026-02-14 11:47:26 +01:00
|
|
|
|
const { searchParams } = request.nextUrl;
|
2026-03-08 16:26:05 +01:00
|
|
|
|
const title = (searchParams.get('title') || 'Gallery').slice(0, 200);
|
|
|
|
|
|
const subtitle = (searchParams.get('subtitle') || '').slice(0, 100);
|
2026-02-14 10:30:27 +01:00
|
|
|
|
|
2026-02-14 11:47:26 +01:00
|
|
|
|
return new ImageResponse(
|
|
|
|
|
|
<div
|
|
|
|
|
|
style={{
|
|
|
|
|
|
width: '100%',
|
|
|
|
|
|
height: '100%',
|
|
|
|
|
|
display: 'flex',
|
|
|
|
|
|
flexDirection: 'column',
|
|
|
|
|
|
alignItems: 'center',
|
|
|
|
|
|
justifyContent: 'center',
|
|
|
|
|
|
backgroundColor: '#0a0a0a',
|
|
|
|
|
|
fontFamily: 'system-ui, -apple-system, sans-serif',
|
|
|
|
|
|
padding: '60px',
|
|
|
|
|
|
}}
|
|
|
|
|
|
>
|
|
|
|
|
|
{/* Decorative top line */}
|
|
|
|
|
|
<div
|
|
|
|
|
|
style={{
|
|
|
|
|
|
width: '60px',
|
|
|
|
|
|
height: '2px',
|
feat: theming system, documentation, and photo grid regression tests
- Add configurable theme system with 4 presets (studio, minimal, editorial, classic)
- Theme controls fonts, colors, accent, photo frames, grain, and header dot
- Resolve themes from gallery.yaml: string shorthand or full object override
- Inject theme as CSS custom properties on <html> element
- Dynamic Google Fonts loading based on theme config
- OG image route reads accent/background from theme
- Refactor Studio overrides into conditional CSS via data-attributes
Documentation:
- Add docs/gallery-config.md with comprehensive configuration reference
- Add docs/theming.md with preset reference and custom theme guide
- Slim README to link to detailed docs
Fix CSS regression:
- Fix passepartout frame overflow:visible breaking next/image fill rendering
- Remove duplicate .photo-grid__item block that stripped overflow:hidden
Testing:
- Add e2e/photo-grid.spec.ts with 3 regression tests:
- Grid items render with real dimensions
- overflow:hidden CSS guard (catches the exact bug fixed)
- Images load with real pixel data (not blurhash)
Tooling:
- Add scripts/screenshots.ts for automated theme screenshot generation
- Handles dev server lifecycle, theme cycling, FadeIn + lazy image handling
2026-02-15 12:21:02 +01:00
|
|
|
|
backgroundColor: theme.accent,
|
2026-02-14 11:47:26 +01:00
|
|
|
|
marginBottom: '40px',
|
|
|
|
|
|
}}
|
|
|
|
|
|
/>
|
2026-02-14 10:30:27 +01:00
|
|
|
|
|
2026-02-14 11:47:26 +01:00
|
|
|
|
{/* Title */}
|
|
|
|
|
|
<div
|
|
|
|
|
|
style={{
|
|
|
|
|
|
fontSize: '64px',
|
|
|
|
|
|
fontWeight: 600,
|
|
|
|
|
|
color: '#f0f0f0',
|
|
|
|
|
|
letterSpacing: '0.02em',
|
|
|
|
|
|
textAlign: 'center',
|
|
|
|
|
|
lineHeight: 1.2,
|
|
|
|
|
|
maxWidth: '900px',
|
|
|
|
|
|
}}
|
|
|
|
|
|
>
|
|
|
|
|
|
{title}
|
|
|
|
|
|
</div>
|
2026-02-14 10:30:27 +01:00
|
|
|
|
|
2026-02-14 11:47:26 +01:00
|
|
|
|
{/* Subtitle */}
|
|
|
|
|
|
{subtitle && (
|
|
|
|
|
|
<div
|
|
|
|
|
|
style={{
|
|
|
|
|
|
fontSize: '24px',
|
|
|
|
|
|
color: '#999999',
|
|
|
|
|
|
fontWeight: 300,
|
|
|
|
|
|
marginTop: '16px',
|
|
|
|
|
|
letterSpacing: '0.08em',
|
|
|
|
|
|
textTransform: 'lowercase',
|
|
|
|
|
|
}}
|
|
|
|
|
|
>
|
|
|
|
|
|
{subtitle}
|
|
|
|
|
|
</div>
|
|
|
|
|
|
)}
|
2026-02-14 10:30:27 +01:00
|
|
|
|
|
2026-02-14 11:47:26 +01:00
|
|
|
|
{/* Bottom decorative line */}
|
|
|
|
|
|
<div
|
|
|
|
|
|
style={{
|
|
|
|
|
|
width: '60px',
|
|
|
|
|
|
height: '2px',
|
feat: theming system, documentation, and photo grid regression tests
- Add configurable theme system with 4 presets (studio, minimal, editorial, classic)
- Theme controls fonts, colors, accent, photo frames, grain, and header dot
- Resolve themes from gallery.yaml: string shorthand or full object override
- Inject theme as CSS custom properties on <html> element
- Dynamic Google Fonts loading based on theme config
- OG image route reads accent/background from theme
- Refactor Studio overrides into conditional CSS via data-attributes
Documentation:
- Add docs/gallery-config.md with comprehensive configuration reference
- Add docs/theming.md with preset reference and custom theme guide
- Slim README to link to detailed docs
Fix CSS regression:
- Fix passepartout frame overflow:visible breaking next/image fill rendering
- Remove duplicate .photo-grid__item block that stripped overflow:hidden
Testing:
- Add e2e/photo-grid.spec.ts with 3 regression tests:
- Grid items render with real dimensions
- overflow:hidden CSS guard (catches the exact bug fixed)
- Images load with real pixel data (not blurhash)
Tooling:
- Add scripts/screenshots.ts for automated theme screenshot generation
- Handles dev server lifecycle, theme cycling, FadeIn + lazy image handling
2026-02-15 12:21:02 +01:00
|
|
|
|
backgroundColor: theme.accent,
|
2026-02-14 11:47:26 +01:00
|
|
|
|
marginTop: '40px',
|
|
|
|
|
|
}}
|
|
|
|
|
|
/>
|
|
|
|
|
|
</div>,
|
|
|
|
|
|
{
|
|
|
|
|
|
width: 1200,
|
|
|
|
|
|
height: 630,
|
|
|
|
|
|
headers: {
|
|
|
|
|
|
'Cache-Control': 'public, max-age=86400, s-maxage=86400',
|
|
|
|
|
|
},
|
|
|
|
|
|
},
|
|
|
|
|
|
);
|
2026-02-14 10:30:27 +01:00
|
|
|
|
}
|