chore: App router migration (/workflows) fix metadata and remove duplicate file for getStaticProps (#16452)
* Fix metadata * add use client directive to workflow component
This commit is contained in:
1 parent
779eb19e7a
commit
55d75a9786
6 files changed
+67
-72
No files matched your search
@@ -1,18 +1,21 @@
|
||||
import LegacyPage from "@pages/workflows/[workflow]";
|
||||
import { withAppDirSsg } from "app/WithAppDirSsg";
|
||||
import type { PageProps } from "app/_types";
|
||||
import { _generateMetadata } from "app/_utils";
|
||||
import { WithLayout } from "app/layoutHOC";
|
||||
import { headers, cookies } from "next/headers";
|
||||
|
||||
import { buildLegacyCtx } from "@lib/buildLegacyCtx";
|
||||
import LegacyPage from "@calcom/features/ee/workflows/pages/workflow";
|
||||
import { WorkflowRepository } from "@calcom/lib/server/repository/workflow";
|
||||
|
||||
import { getStaticProps } from "~/workflows/workflow-single-view.getStaticProps";
|
||||
import { buildLegacyCtx } from "@lib/buildLegacyCtx";
|
||||
import { getStaticProps } from "@lib/workflows/[workflow]/getStaticProps";
|
||||
|
||||
export const generateMetadata = async ({ params, searchParams }: PageProps) => {
|
||||
const { workflow } = await getData(buildLegacyCtx(headers(), cookies(), params, searchParams));
|
||||
const { workflow: id } = await getData(buildLegacyCtx(headers(), cookies(), params, searchParams));
|
||||
const workflow = await WorkflowRepository.getById({ id: +id });
|
||||
|
||||
return await _generateMetadata(
|
||||
() => workflow ?? "Untitled",
|
||||
() => (workflow && workflow.name ? workflow.name : "Untitled"),
|
||||
() => ""
|
||||
);
|
||||
};
|
||||
@@ -21,7 +24,6 @@ const getData = withAppDirSsg(getStaticProps);
|
||||
|
||||
export const generateStaticParams = () => [];
|
||||
|
||||
// @ts-expect-error TODO: fix this
|
||||
export default WithLayout({ getLayout: null, getData, Page: LegacyPage })<"P">;
|
||||
export const dynamic = "force-static";
|
||||
// generate segments on demand
|
||||
|
||||
@@ -1,19 +0,0 @@
|
||||
import type { GetStaticProps } from "next";
|
||||
import { z } from "zod";
|
||||
|
||||
const querySchema = z.object({
|
||||
workflow: z.string(),
|
||||
});
|
||||
|
||||
export const getStaticProps: GetStaticProps = (ctx) => {
|
||||
const params = querySchema.safeParse(ctx.params);
|
||||
console.log("Built workflow page:", params);
|
||||
if (!params.success) return { notFound: true };
|
||||
|
||||
return {
|
||||
props: {
|
||||
workflow: params.data.workflow,
|
||||
},
|
||||
revalidate: 10, // seconds
|
||||
};
|
||||
};
|
||||
Reference in new issue
Block a user