fix: Move future/workflow/[workflow] getStaticProps into separate file (#16124)

This commit is contained in:
Joe Au-Yeung
2024-08-28 08:53:32 -04:00
committed by GitHub
parent 356ecfe2fa
commit 6b244fc5b5
2 changed files with 22 additions and 1 deletions
@@ -1,4 +1,4 @@
import LegacyPage, { getStaticProps } from "@pages/workflows/[workflow]";
import LegacyPage from "@pages/workflows/[workflow]";
import { withAppDirSsg } from "app/WithAppDirSsg";
import type { PageProps } from "app/_types";
import { _generateMetadata } from "app/_utils";
@@ -7,6 +7,8 @@ import { headers, cookies } from "next/headers";
import { buildLegacyCtx } from "@lib/buildLegacyCtx";
import { getStaticProps } from "~/workflows/workflow-single-view.getStaticProps";
export const generateMetadata = async ({ params, searchParams }: PageProps) => {
const { workflow } = await getData(buildLegacyCtx(headers(), cookies(), params, searchParams));
return await _generateMetadata(
@@ -0,0 +1,19 @@
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
};
};