fix(cms): extract serverFunction to separate 'use server' file for Next.js 15.5 server action registration
This commit is contained in:
@@ -2,26 +2,17 @@
|
||||
/* DO NOT MODIFY IT BECAUSE IT COULD BE REWRITTEN AT ANY TIME. */
|
||||
import config from "@payload-config";
|
||||
import "@payloadcms/next/css";
|
||||
import type { ServerFunctionClient } from "payload";
|
||||
import { handleServerFunctions, RootLayout } from "@payloadcms/next/layouts";
|
||||
import { RootLayout } from "@payloadcms/next/layouts";
|
||||
import React from "react";
|
||||
|
||||
import { importMap } from "./admin/importMap.js";
|
||||
import { serverFunction } from "./serverFunction";
|
||||
import "./custom.scss";
|
||||
|
||||
type Args = {
|
||||
children: React.ReactNode;
|
||||
};
|
||||
|
||||
const serverFunction: ServerFunctionClient = async function (args) {
|
||||
"use server";
|
||||
return handleServerFunctions({
|
||||
...args,
|
||||
config,
|
||||
importMap,
|
||||
});
|
||||
};
|
||||
|
||||
const Layout = ({ children }: Args) => (
|
||||
<RootLayout
|
||||
config={config}
|
||||
|
||||
14
apps/cms/src/app/(payload)/serverFunction.ts
Normal file
14
apps/cms/src/app/(payload)/serverFunction.ts
Normal file
@@ -0,0 +1,14 @@
|
||||
"use server";
|
||||
|
||||
import config from "@payload-config";
|
||||
import { handleServerFunctions } from "@payloadcms/next/layouts";
|
||||
import { importMap } from "./admin/importMap.js";
|
||||
import type { ServerFunctionClient } from "payload";
|
||||
|
||||
export const serverFunction: ServerFunctionClient = async (args) => {
|
||||
return handleServerFunctions({
|
||||
...args,
|
||||
config,
|
||||
importMap,
|
||||
});
|
||||
};
|
||||
Reference in New Issue
Block a user