fix: gracefaul fallback + force-dynamic for build
This commit is contained in:
@@ -4,6 +4,7 @@ import { hardware, performanceEntries, gameVersions, games } from "@/lib/db/sche
|
|||||||
import { eq, and, sql } from "drizzle-orm"
|
import { eq, and, sql } from "drizzle-orm"
|
||||||
|
|
||||||
export const runtime = "nodejs"
|
export const runtime = "nodejs"
|
||||||
|
export const dynamic = "force-dynamic"
|
||||||
export const alt = "Device benchmarks on DeckyVault"
|
export const alt = "Device benchmarks on DeckyVault"
|
||||||
export const size = { width: 1200, height: 630 }
|
export const size = { width: 1200, height: 630 }
|
||||||
export const contentType = "image/png"
|
export const contentType = "image/png"
|
||||||
|
|||||||
@@ -8,10 +8,16 @@ import type { Metadata } from "next"
|
|||||||
export const revalidate = 3600
|
export const revalidate = 3600
|
||||||
|
|
||||||
export async function generateStaticParams() {
|
export async function generateStaticParams() {
|
||||||
|
try {
|
||||||
const devices = await db
|
const devices = await db
|
||||||
.select({ slug: hardware.slug })
|
.select({ slug: hardware.slug })
|
||||||
.from(hardware)
|
.from(hardware)
|
||||||
return devices.map((d) => ({ slug: d.slug }))
|
return devices.map((d) => ({ slug: d.slug }))
|
||||||
|
} catch {
|
||||||
|
// DB unreachable during build (e.g. Docker builder without network access).
|
||||||
|
// Return empty — pages will be generated on first request via ISR.
|
||||||
|
return []
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function generateMetadata({
|
export async function generateMetadata({
|
||||||
|
|||||||
@@ -4,6 +4,9 @@ import { eq, sql, desc } from "drizzle-orm"
|
|||||||
import { DevicesPageClient } from "./page-client"
|
import { DevicesPageClient } from "./page-client"
|
||||||
import type { Metadata } from "next"
|
import type { Metadata } from "next"
|
||||||
|
|
||||||
|
// This page needs live data — skip static generation at build time
|
||||||
|
export const dynamic = "force-dynamic"
|
||||||
|
|
||||||
export const metadata: Metadata = {
|
export const metadata: Metadata = {
|
||||||
title: "Devices — DeckyVault",
|
title: "Devices — DeckyVault",
|
||||||
description:
|
description:
|
||||||
|
|||||||
@@ -5,6 +5,9 @@ import { eq, and, sql } from "drizzle-orm"
|
|||||||
import { readFile } from "node:fs/promises"
|
import { readFile } from "node:fs/promises"
|
||||||
import { join } from "node:path"
|
import { join } from "node:path"
|
||||||
|
|
||||||
|
// This needs live data — skip static generation at build time
|
||||||
|
export const dynamic = "force-dynamic"
|
||||||
|
|
||||||
export const alt = "DeckyVault - Game Benchmarks"
|
export const alt = "DeckyVault - Game Benchmarks"
|
||||||
export const size = { width: 1200, height: 630 }
|
export const size = { width: 1200, height: 630 }
|
||||||
export const contentType = "image/png"
|
export const contentType = "image/png"
|
||||||
|
|||||||
@@ -15,6 +15,9 @@ import { and, desc, eq, sql } from "drizzle-orm"
|
|||||||
import { isSyncStale, syncSteamGame } from "@/lib/steam/sync"
|
import { isSyncStale, syncSteamGame } from "@/lib/steam/sync"
|
||||||
import { GamePageClient } from "./game-page-client"
|
import { GamePageClient } from "./game-page-client"
|
||||||
|
|
||||||
|
// This page needs live data — skip static generation at build time
|
||||||
|
export const dynamic = "force-dynamic"
|
||||||
|
|
||||||
async function resolveGame(id: string) {
|
async function resolveGame(id: string) {
|
||||||
const isNumeric = /^\d+$/.test(id)
|
const isNumeric = /^\d+$/.test(id)
|
||||||
let game
|
let game
|
||||||
|
|||||||
@@ -4,6 +4,9 @@ import { games, gameVersions } from "@/lib/db/schema"
|
|||||||
import { eq, sql } from "drizzle-orm"
|
import { eq, sql } from "drizzle-orm"
|
||||||
import { GameEntryWizard } from "@/components/wizard/game-entry-wizard"
|
import { GameEntryWizard } from "@/components/wizard/game-entry-wizard"
|
||||||
|
|
||||||
|
// This page needs live data — skip static generation at build time
|
||||||
|
export const dynamic = "force-dynamic"
|
||||||
|
|
||||||
export const metadata = {
|
export const metadata = {
|
||||||
title: "Submit Benchmark",
|
title: "Submit Benchmark",
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -10,6 +10,9 @@ import {
|
|||||||
import { sql, eq, and, desc, inArray } from "drizzle-orm"
|
import { sql, eq, and, desc, inArray } from "drizzle-orm"
|
||||||
import { GamesPageClient } from "./games-page-client"
|
import { GamesPageClient } from "./games-page-client"
|
||||||
|
|
||||||
|
// This page needs live data — skip static generation at build time
|
||||||
|
export const dynamic = "force-dynamic"
|
||||||
|
|
||||||
export const metadata: Metadata = {
|
export const metadata: Metadata = {
|
||||||
title: "Games — DeckyVault",
|
title: "Games — DeckyVault",
|
||||||
description:
|
description:
|
||||||
|
|||||||
@@ -4,6 +4,9 @@ import { user, performanceEntries, games, gameVersions, hardware } from "@/lib/d
|
|||||||
import { eq, sql, and, desc } from "drizzle-orm"
|
import { eq, sql, and, desc } from "drizzle-orm"
|
||||||
import { ProfilePageClient } from "./profile-page-client"
|
import { ProfilePageClient } from "./profile-page-client"
|
||||||
|
|
||||||
|
// This page needs live data — skip static generation at build time
|
||||||
|
export const dynamic = "force-dynamic"
|
||||||
|
|
||||||
export const metadata = {
|
export const metadata = {
|
||||||
title: "Profile",
|
title: "Profile",
|
||||||
}
|
}
|
||||||
|
|||||||
+20
-10
@@ -4,7 +4,21 @@ import { games, hardware } from "@/lib/db/schema"
|
|||||||
|
|
||||||
const BASE_URL = "https://deckyvault.xyz"
|
const BASE_URL = "https://deckyvault.xyz"
|
||||||
|
|
||||||
|
// Skip static generation — rebuild sitemap at request time with fresh data
|
||||||
|
export const dynamic = "force-dynamic"
|
||||||
|
|
||||||
export default async function sitemap(): Promise<MetadataRoute.Sitemap> {
|
export default async function sitemap(): Promise<MetadataRoute.Sitemap> {
|
||||||
|
// Static pages that don't need DB
|
||||||
|
const staticEntries: MetadataRoute.Sitemap = [
|
||||||
|
{ url: BASE_URL, lastModified: new Date(), changeFrequency: "weekly" as const, priority: 1 },
|
||||||
|
{ url: `${BASE_URL}/games`, lastModified: new Date(), changeFrequency: "weekly" as const, priority: 0.7 },
|
||||||
|
{ url: `${BASE_URL}/devices`, lastModified: new Date(), changeFrequency: "monthly" as const, priority: 0.6 },
|
||||||
|
{ url: `${BASE_URL}/contact`, lastModified: new Date(), changeFrequency: "monthly" as const, priority: 0.3 },
|
||||||
|
{ url: `${BASE_URL}/login`, lastModified: new Date(), changeFrequency: "monthly" as const, priority: 0.3 },
|
||||||
|
{ url: `${BASE_URL}/signup`, lastModified: new Date(), changeFrequency: "monthly" as const, priority: 0.3 },
|
||||||
|
]
|
||||||
|
|
||||||
|
try {
|
||||||
const [allGames, allDevices] = await Promise.all([
|
const [allGames, allDevices] = await Promise.all([
|
||||||
db.select({ id: games.id, updatedAt: games.updatedAt, capsuleImage: games.capsuleImage }).from(games),
|
db.select({ id: games.id, updatedAt: games.updatedAt, capsuleImage: games.capsuleImage }).from(games),
|
||||||
db.select({ slug: hardware.slug, createdAt: hardware.createdAt }).from(hardware),
|
db.select({ slug: hardware.slug, createdAt: hardware.createdAt }).from(hardware),
|
||||||
@@ -25,14 +39,10 @@ export default async function sitemap(): Promise<MetadataRoute.Sitemap> {
|
|||||||
priority: 0.6,
|
priority: 0.6,
|
||||||
}))
|
}))
|
||||||
|
|
||||||
return [
|
return [...staticEntries, ...gameEntries, ...deviceEntries]
|
||||||
{ url: BASE_URL, lastModified: new Date(), changeFrequency: "weekly" as const, priority: 1 },
|
} catch {
|
||||||
{ url: `${BASE_URL}/games`, lastModified: new Date(), changeFrequency: "weekly" as const, priority: 0.7 },
|
// DB unreachable during build — return static sitemap only.
|
||||||
{ url: `${BASE_URL}/devices`, lastModified: new Date(), changeFrequency: "monthly" as const, priority: 0.6 },
|
// Dynamic entries will be available at request time.
|
||||||
{ url: `${BASE_URL}/contact`, lastModified: new Date(), changeFrequency: "monthly" as const, priority: 0.3 },
|
return staticEntries
|
||||||
{ url: `${BASE_URL}/login`, lastModified: new Date(), changeFrequency: "monthly" as const, priority: 0.3 },
|
}
|
||||||
{ url: `${BASE_URL}/signup`, lastModified: new Date(), changeFrequency: "monthly" as const, priority: 0.3 },
|
|
||||||
...gameEntries,
|
|
||||||
...deviceEntries,
|
|
||||||
]
|
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user