From efd455d1d9ee0d9ab079f9a017c8a0044320587f Mon Sep 17 00:00:00 2001 From: Mike Decker Date: Tue, 23 Jan 2024 15:07:18 -0800 Subject: [PATCH] more cacheing --- app/[...slug]/page.tsx | 2 +- src/lib/drupal/get-paths.tsx | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/app/[...slug]/page.tsx b/app/[...slug]/page.tsx index a7acfe80..8b43614d 100644 --- a/app/[...slug]/page.tsx +++ b/app/[...slug]/page.tsx @@ -40,7 +40,7 @@ export const generateStaticParams = async (): Promise => { if (nodePaths) { params = nodePaths.map(path => ({slug: path.split('/')})) } - return process.env.BUILD_COMPLETE === 'true' ? params : params.slice(0, 1); + return process.env.BUILD_COMPLETE === 'true' ? params : []; } export default Page; \ No newline at end of file diff --git a/src/lib/drupal/get-paths.tsx b/src/lib/drupal/get-paths.tsx index 0cdd530d..8732da2b 100644 --- a/src/lib/drupal/get-paths.tsx +++ b/src/lib/drupal/get-paths.tsx @@ -4,6 +4,7 @@ import {PageProps, Params} from "@lib/types"; import {DrupalJsonApiParams} from "drupal-jsonapi-params"; import {getPathFromContext, isDraftMode} from "@lib/drupal/utils"; import {DrupalRedirect} from "@lib/drupal/drupal-jsonapi.types"; +import {cache} from "react"; export const pathIsValid = async (path: string, type?: 'node' | 'redirect') => { if (isDraftMode()) return true; @@ -17,12 +18,12 @@ export const pathIsValid = async (path: string, type?: 'node' | 'redirect') => { return allPaths.includes(path); } -export const getAllDrupalPaths = async (cacheBust?: boolean): Promise> => { +export const getAllDrupalPaths = cache(async (cacheBust?: boolean): Promise> => { const paths = new Map(); paths.set('node', await getNodePaths(cacheBust)) paths.set('redirect', await getRedirectPaths(cacheBust)) return paths; -} +}) const getNodePaths = async (cacheBust?: boolean): Promise => { const params = new DrupalJsonApiParams();