From 66315cfc40b9c9620c4ccc2fde0965e187399cb8 Mon Sep 17 00:00:00 2001 From: Sam Carlton Date: Sat, 11 Sep 2021 16:16:37 -0500 Subject: [PATCH] Fix passing props at wrong level --- pages/formula/[...slug].js | 27 +++++++++++++++++++-------- 1 file changed, 19 insertions(+), 8 deletions(-) diff --git a/pages/formula/[...slug].js b/pages/formula/[...slug].js index 4f472a5..fe18f3c 100644 --- a/pages/formula/[...slug].js +++ b/pages/formula/[...slug].js @@ -36,14 +36,20 @@ export async function getStaticProps({ params }) { // } try { - const allEndpointListings = await fs.readFile('./static/eleventy-endpoints.json', 'utf-8') - .then( endpointsJson => { - return JSON.parse(endpointsJson) - }) + // const allEndpointListings = await fs.readFile('./static/eleventy-endpoints.json', 'utf-8') + // .then( endpointsJson => { + // return JSON.parse(endpointsJson) + // }) + + const allEndpointListings = await fs.stat('./static/eleventy-endpointsdddd.json') + const currentDirectory = await fs.readdir('./') // console.log('endpointListings', endpointListings[0]) - let pageListing = { allEndpointListings } + let pageListing = { + allEndpointListings, + currentDirectory + } const start = '/formula/' @@ -64,13 +70,18 @@ export async function getStaticProps({ params }) { console.log('pageListing', pageListing) return pageListing ? { - props: pageListing, - ...defaultStaticProps + props: { + ...pageListing + }, + revalidate: ONE_MINUTE } : { notFound: true } } catch (error) { // The Twitter API most likely died console.error(error) - return { notFound: true, error } + return { + notFound: true, + props: { error } + } } }