From ab7a720899a845e9b01c340cfcbceb301e860d72 Mon Sep 17 00:00:00 2001 From: Frank Date: Wed, 4 Oct 2023 19:50:45 -0600 Subject: [PATCH] Testing fix found on github for revalidate possibly --- src/pages/blog/[slug]/index.tsx | 42 +++++++++++++++++++++++---------- 1 file changed, 30 insertions(+), 12 deletions(-) diff --git a/src/pages/blog/[slug]/index.tsx b/src/pages/blog/[slug]/index.tsx index 06d1aea..921b60d 100644 --- a/src/pages/blog/[slug]/index.tsx +++ b/src/pages/blog/[slug]/index.tsx @@ -19,19 +19,37 @@ export const getStaticPaths = async () => { }; }; -export const getStaticProps = wrapper.getStaticProps( - (store) => async (context) => { - store.dispatch(getPost.initiate(context?.params?.slug)); - const [post] = await Promise.all(store.dispatch(getRunningQueriesThunk())); +const addRevalidateAndRedux = async ( + props: any, + reduxStaticProps: any, + revalidateSeconds = 50 +) => { + const getStaticProps = await reduxStaticProps(props); + getStaticProps.revalidate = revalidateSeconds; + return getStaticProps; +}; - return { - props: { - post: post.data[0], - }, - revalidate: 60, - }; - } -); +export const getStaticProps = async (props: any) => + addRevalidateAndRedux( + props, + wrapper.getStaticProps((store) => async (context) => { + store.dispatch(getPost.initiate(context?.params?.slug)); + const [post] = await Promise.all( + store.dispatch(getRunningQueriesThunk()) + ); + + return { + props: { + post: post.data[0], + }, + revalidate: 60, + }; + }) + ); + +// export const getStaticProps = wrapper.getStaticProps( +// (store) => async (context) => {} +// ); const Post = ({ post }: any) => { const dateUploaded = new Date(post.date).toDateString();