feat: render portfolio routes from live localized database content

This commit is contained in:
2026-09-15 21:48:07 +03:30
parent 7830784694
commit 131f7efbf3
36 changed files with 272 additions and 376 deletions

15
src/server/public.ts Normal file
View File

@@ -0,0 +1,15 @@
import 'server-only';
import { cache } from 'react';
import { connection } from 'next/server';
import { notFound } from 'next/navigation';
import { getDatabase } from './db';
import { ContentError, readContent, resolvePublicRoute } from './content';
export const readPublicSnapshot = cache(async () => {
await connection();
return readContent(getDatabase());
});
export async function getPublicRoute(segments: string[] = []) {
try { return resolvePublicRoute(await readPublicSnapshot(), segments); }
catch (error) { if (error instanceof ContentError && error.status === 404) notFound(); throw error; }
}