Skip to content

Commit

Permalink
fix: Move future/workflow/[workflow] getStaticProps into separate…
Browse files Browse the repository at this point in the history
… file (#16124)
  • Loading branch information
joeauyeung authored and zomars committed Aug 29, 2024
1 parent 51f669d commit bf3a929
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 1 deletion.
4 changes: 3 additions & 1 deletion apps/web/app/future/workflows/[workflow]/page.tsx
Original file line number Diff line number Diff line change
@@ -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";
Expand All @@ -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(
Expand Down
19 changes: 19 additions & 0 deletions apps/web/modules/workflows/workflow-single-view.getStaticProps.tsx
Original file line number Diff line number Diff line change
@@ -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
};
};

0 comments on commit bf3a929

Please sign in to comment.