feat: generateStaticParams for application + news slug pages
Deploy to VPS / deploy (push) Has been cancelled

Pre-render all known slugs at build time so first visits are instant
from cache. New slugs added after deploy render on-demand and get
cached by ISR (revalidate=60). try/catch ensures the build never
fails if the DB is unreachable during docker build — pages just
fall back to on-demand rendering.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-05-06 14:39:57 -05:00
parent ce8a13d7f8
commit 7502c9c674
2 changed files with 28 additions and 6 deletions
+14 -3
View File
@@ -83,9 +83,20 @@ export async function generateMetadata({
} }
} }
// generateStaticParams omitted — slug pages render on-demand and are cached // Pre-render all known application slugs at build time. New slugs added
// by ISR (revalidate=60). The DYNAMIC_SERVER_USAGE issue that previously // after deploy render on-demand and get cached by ISR (revalidate=60).
// blocked this is now fixed via setRequestLocale. // try/catch ensures the build never fails if the DB is unreachable
// during docker build — pages just render on first request instead.
export async function generateStaticParams() {
try {
const apps = await prisma.application.findMany({
select: { slug: true },
});
return apps.map((app) => ({ slug: app.slug }));
} catch {
return [];
}
}
// 🔥 AHORA RECIBIMOS EL LOCALE DESDE LA URL // 🔥 AHORA RECIBIMOS EL LOCALE DESDE LA URL
export default async function ApplicationPage({ params }: { params: Promise<{ slug: string, locale: string }> }) { export default async function ApplicationPage({ params }: { params: Promise<{ slug: string, locale: string }> }) {
+14 -3
View File
@@ -48,9 +48,20 @@ export async function generateMetadata({
} }
} }
// generateStaticParams omitted — slug pages render on-demand and are cached // Pre-render all published news slugs at build time. New articles added
// by ISR (revalidate=60). The DYNAMIC_SERVER_USAGE issue is fixed via // after deploy render on-demand and get cached by ISR (revalidate=60).
// setRequestLocale. // try/catch ensures the build never fails if the DB is unreachable.
export async function generateStaticParams() {
try {
const articles = await prisma.newsArticle.findMany({
where: { isActive: true },
select: { slug: true },
});
return articles.map((a) => ({ slug: a.slug }));
} catch {
return [];
}
}
// ── SÚPER PARSER MARKDOWN (Con Tablas, Imágenes y Dark/Light Mode) ── // ── SÚPER PARSER MARKDOWN (Con Tablas, Imágenes y Dark/Light Mode) ──
// ... (El código del Súper Parser se queda IGUAL, no te preocupes) ... // ... (El código del Súper Parser se queda IGUAL, no te preocupes) ...