Fixed notfound headers, r2storage

This commit is contained in:
2026-10-13 15:57:59 +02:00
parent 86c873e4e7
commit 786dd346a9
24 changed files with 1506 additions and 2765 deletions
+32
View File
@@ -0,0 +1,32 @@
'use client'
import type { ReactNode } from 'react'
// '.js' is required: `next` has no package.json "exports", so NodeNext resolution
// (this plugin's tsconfig) can't find 'next/navigation' without the extension.
// Bundlers in the project resolve the same file either way.
import { usePathname } from 'next/navigation.js'
type LocaleViewProps = {
/** Used when the URL has no locale segment (single-locale site) or an unknown one. */
defaultLocale: string
/**
* One pre-rendered view per locale, e.g. { pl: <RenderBlocks …/>, en: … }.
* Rendered on the SERVER (RSC) and passed in as props — this component only
* picks one, so the content can come from the panel and the route stays static.
*/
views: Record<string, ReactNode>
}
/**
* Shows the view matching the locale in the current URL (`/en/...` → `en`).
*
* Made for `not-found.tsx`, which receives no `params`: reading the locale with
* `headers()` there turns an SSG/ISR route dynamic ("Page changed from static
* to dynamic at runtime"). `usePathname()` is client-side and static-safe, and
* it also runs during SSR, so the HTML already contains the right language.
*/
export function LocaleView({ defaultLocale, views }: LocaleViewProps) {
const pathname = usePathname() ?? ''
const segment = pathname.split('/').filter(Boolean)[0] ?? ''
const locale = segment in views ? segment : defaultLocale
return <>{views[locale] ?? views[defaultLocale] ?? null}</>
}