mirror of
https://github.com/TheRealOwenRees/echecsfrance.git
synced 2026-11-18 07:22:06 +00:00
upgrade: 1st pass upgrade to Next.js v16
This commit is contained in:
@@ -4,10 +4,11 @@ import SignInClient from "@/app/[locale]/(main)/auth/sign-in/SignInClient";
|
||||
import { baseUrl } from "@/constants";
|
||||
|
||||
export async function generateMetadata({
|
||||
params: { locale },
|
||||
params,
|
||||
}: {
|
||||
params: { locale?: string };
|
||||
params: Promise<{ locale?: string }>;
|
||||
}): Promise<Metadata> {
|
||||
const { locale } = await params;
|
||||
return {
|
||||
alternates: {
|
||||
canonical:
|
||||
|
||||
@@ -12,10 +12,11 @@ import ClubsDisplay from "./ClubsDisplay";
|
||||
export const revalidate = 3600; // Revalidate cache every 6 hours
|
||||
|
||||
export async function generateMetadata({
|
||||
params: { locale },
|
||||
params,
|
||||
}: {
|
||||
params: { locale?: string };
|
||||
params: Promise<{ locale?: string }>;
|
||||
}): Promise<Metadata> {
|
||||
const { locale } = await params;
|
||||
return {
|
||||
alternates: {
|
||||
canonical:
|
||||
|
||||
@@ -4,10 +4,11 @@ import EloClient from "@/app/[locale]/(main)/elo/EloClient";
|
||||
import { baseUrl } from "@/constants";
|
||||
|
||||
export async function generateMetadata({
|
||||
params: { locale },
|
||||
params,
|
||||
}: {
|
||||
params: { locale?: string };
|
||||
params: Promise<{ locale?: string }>;
|
||||
}): Promise<Metadata> {
|
||||
const { locale } = await params;
|
||||
return {
|
||||
alternates: {
|
||||
canonical:
|
||||
|
||||
@@ -20,10 +20,11 @@ import TournamentsDisplay from "./TournamentsDisplay";
|
||||
setDefaultOptions({ locale: fr });
|
||||
|
||||
export async function generateMetadata({
|
||||
params: { locale },
|
||||
params,
|
||||
}: {
|
||||
params: { locale?: string };
|
||||
params: Promise<{ locale?: string }>;
|
||||
}): Promise<Metadata> {
|
||||
const { locale } = await params;
|
||||
return {
|
||||
alternates: {
|
||||
canonical:
|
||||
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 197 KiB |
@@ -21,12 +21,13 @@ const title = Julius_Sans_One({
|
||||
});
|
||||
|
||||
export async function generateMetadata({
|
||||
params: { locale },
|
||||
params,
|
||||
}: {
|
||||
params: { locale?: string };
|
||||
params: Promise<{ locale?: string }>;
|
||||
}) {
|
||||
// While the `locale` is required, the namespace is optional and
|
||||
// identical to the parameter that `useTranslations` accepts.
|
||||
const { locale } = await params;
|
||||
const t = await getTranslations({
|
||||
locale: locale ?? "fr",
|
||||
namespace: "Metadata",
|
||||
@@ -48,11 +49,12 @@ export async function generateMetadata({
|
||||
|
||||
export default async function RootLayout({
|
||||
children,
|
||||
params: { locale },
|
||||
params,
|
||||
}: {
|
||||
children: ReactNode;
|
||||
params: { locale?: string };
|
||||
params: Promise<{ locale?: string }>;
|
||||
}) {
|
||||
const { locale } = await params;
|
||||
let messages;
|
||||
try {
|
||||
messages = (await import(`@/messages/${locale}.json`)).default;
|
||||
|
||||
@@ -5,7 +5,7 @@ import { GrLineChart } from "react-icons/gr";
|
||||
import { HiUserGroup } from "react-icons/hi2";
|
||||
import { twMerge } from "tailwind-merge";
|
||||
|
||||
import bannerImage from "/public/banner.jpeg";
|
||||
import bannerImage from "./banner.jpeg";
|
||||
import { Link } from "@/utils/routing";
|
||||
|
||||
export default function Home() {
|
||||
|
||||
@@ -0,0 +1,21 @@
|
||||
import { defaultCache } from "@serwist/next/worker";
|
||||
import type { PrecacheEntry } from "serwist";
|
||||
import { Serwist } from "serwist";
|
||||
|
||||
declare global {
|
||||
interface WorkerGlobalScope {
|
||||
__SW_MANIFEST: (PrecacheEntry | string)[] | undefined;
|
||||
}
|
||||
}
|
||||
|
||||
declare const self: WorkerGlobalScope;
|
||||
|
||||
const serwist = new Serwist({
|
||||
precacheEntries: self.__SW_MANIFEST,
|
||||
skipWaiting: true,
|
||||
clientsClaim: true,
|
||||
navigationPreload: true,
|
||||
runtimeCaching: defaultCache,
|
||||
});
|
||||
|
||||
serwist.addEventListeners();
|
||||
@@ -193,11 +193,16 @@ export const Map = ({
|
||||
const referencedMarkers = useMemo(
|
||||
() =>
|
||||
markers.map((marker) =>
|
||||
React.cloneElement(marker.component, {
|
||||
ref: (ref: MarkerRef) => {
|
||||
markerRefs.current[marker.markerId] = ref;
|
||||
React.cloneElement(
|
||||
marker.component as React.ReactElement<{
|
||||
ref?: (ref: MarkerRef) => void;
|
||||
}>,
|
||||
{
|
||||
ref: (ref: MarkerRef) => {
|
||||
markerRefs.current[marker.markerId] = ref;
|
||||
},
|
||||
},
|
||||
}),
|
||||
),
|
||||
),
|
||||
[markers],
|
||||
);
|
||||
|
||||
@@ -17,7 +17,7 @@ import { Field, GenericFieldProps } from "./Field";
|
||||
|
||||
export type BaseOption<T = string, D = unknown> = {
|
||||
value: T;
|
||||
label: string | JSX.Element;
|
||||
label: string | React.JSX.Element;
|
||||
disabled?: boolean;
|
||||
data?: D;
|
||||
};
|
||||
|
||||
@@ -8,7 +8,7 @@ import { Prettify } from "@/types";
|
||||
|
||||
export type BaseOption<T = string, D = unknown> = {
|
||||
value: T;
|
||||
label: string | JSX.Element;
|
||||
label: string | React.JSX.Element;
|
||||
disabled?: boolean;
|
||||
data?: D;
|
||||
};
|
||||
|
||||
@@ -91,7 +91,7 @@ export const TournamentSelectField = <
|
||||
background: `${TimeControlColours[option.data!.timeControl]}`,
|
||||
}}
|
||||
>
|
||||
{at("timeControlEnum", { tc: option.data?.timeControl })}
|
||||
{at("timeControlEnum", { tc: option.data!.timeControl })}
|
||||
</div>
|
||||
<div className="text-xs">{option.data?.date}</div>
|
||||
</div>
|
||||
|
||||
@@ -20,7 +20,7 @@ export type ZoneEditorProps = {
|
||||
|
||||
export const ZoneEditor = ({ value, onChange }: ZoneEditorProps) => {
|
||||
const initialFeatures = React.useRef(value?.features);
|
||||
const featureGroup = React.useRef<L.FeatureGroup>();
|
||||
const featureGroup = React.useRef<L.FeatureGroup | null>(null);
|
||||
|
||||
const setFeatureCollectionRef = (element: L.FeatureGroup) => {
|
||||
featureGroup.current = element;
|
||||
|
||||
@@ -6,7 +6,7 @@ const useDatePickerWidth = ({
|
||||
datePickerRef,
|
||||
setDateDirectionState,
|
||||
}: {
|
||||
datePickerRef: RefObject<HTMLDivElement>;
|
||||
datePickerRef: RefObject<HTMLDivElement | null>;
|
||||
setDateDirectionState: Dispatch<SetStateAction<DatePickerDirection>>;
|
||||
}) => {
|
||||
useEffect(() => {
|
||||
|
||||
+5
-3
@@ -3,11 +3,13 @@ import { notFound } from "next/navigation";
|
||||
|
||||
import { routing } from "./utils/routing";
|
||||
|
||||
export default getRequestConfig(async ({ locale }) => {
|
||||
export default getRequestConfig(async ({ requestLocale }) => {
|
||||
// Validate that the incoming `locale` parameter is valid
|
||||
if (!routing.locales.includes(locale as any)) notFound();
|
||||
const locale = await requestLocale;
|
||||
if (!locale || !routing.locales.includes(locale as any)) notFound();
|
||||
|
||||
return {
|
||||
locale,
|
||||
messages: (
|
||||
await (locale === "en"
|
||||
? // When using Turbopack, this will enable HMR for `en`
|
||||
@@ -15,4 +17,4 @@ export default getRequestConfig(async ({ locale }) => {
|
||||
: import(`./messages/${locale}.json`))
|
||||
).default,
|
||||
};
|
||||
});
|
||||
});
|
||||
@@ -1,4 +1,4 @@
|
||||
import { createLocalizedPathnamesNavigation } from "next-intl/navigation";
|
||||
import { createNavigation } from "next-intl/navigation";
|
||||
import { defineRouting } from "next-intl/routing";
|
||||
|
||||
export const routing = defineRouting({
|
||||
@@ -62,4 +62,4 @@ export type Pathnames = keyof typeof routing.pathnames;
|
||||
export type Locale = (typeof routing.locales)[number];
|
||||
|
||||
export const { Link, redirect, usePathname, useRouter, getPathname } =
|
||||
createLocalizedPathnamesNavigation(routing);
|
||||
createNavigation(routing);
|
||||
|
||||
Reference in New Issue
Block a user