diff --git a/examples/next/faustwp-getting-started/package.json b/examples/next/faustwp-getting-started/package.json index d2506d851..8cd0f66f4 100644 --- a/examples/next/faustwp-getting-started/package.json +++ b/examples/next/faustwp-getting-started/package.json @@ -13,7 +13,7 @@ "@apollo/client": "^3.6.6", "@faustwp/cli": "^1.2.0", "@faustwp/core": "^1.2.0", - "@wordpress/base-styles": "^4.26.0", + "@wordpress/base-styles": "^4.36.0", "@wordpress/block-library": "^7.19.0", "classnames": "^2.3.1", "graphql": "^16.6.0", diff --git a/package-lock.json b/package-lock.json index 651c4360b..861415a43 100644 --- a/package-lock.json +++ b/package-lock.json @@ -711,7 +711,7 @@ "@apollo/client": "^3.6.6", "@faustwp/cli": "^1.2.0", "@faustwp/core": "^1.2.0", - "@wordpress/base-styles": "^4.26.0", + "@wordpress/base-styles": "^4.36.0", "@wordpress/block-library": "^7.19.0", "classnames": "^2.3.1", "graphql": "^16.6.0", @@ -725,6 +725,11 @@ "npm": ">=8" } }, + "examples/next/faustwp-getting-started/node_modules/@wordpress/base-styles": { + "version": "4.36.0", + "resolved": "https://registry.npmjs.org/@wordpress/base-styles/-/base-styles-4.36.0.tgz", + "integrity": "sha512-N+Hpz6nI06Ji4mmx9vv/YSKR3XCYHnWV6v0mMehQvC9oZVjxBmo3hzWdiMrrjXFxONH9cjJUql0Cht+traFfRA==" + }, "examples/next/getting-started": { "name": "@faustjs/next-headless-getting-started", "version": "0.1.0", @@ -27822,6 +27827,118 @@ "node": ">= 10" } }, + "packages/experimental-app-router/node_modules/@next/swc-linux-arm64-gnu": { + "version": "12.3.4", + "resolved": "https://registry.npmjs.org/@next/swc-linux-arm64-gnu/-/swc-linux-arm64-gnu-12.3.4.tgz", + "integrity": "sha512-kiX0vgJGMZVv+oo1QuObaYulXNvdH/IINmvdZnVzMO/jic/B8EEIGlZ8Bgvw8LCjH3zNVPO3mGrdMvnEEPEhKA==", + "cpu": [ + "arm64" + ], + "dev": true, + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">= 10" + } + }, + "packages/experimental-app-router/node_modules/@next/swc-linux-arm64-musl": { + "version": "12.3.4", + "resolved": "https://registry.npmjs.org/@next/swc-linux-arm64-musl/-/swc-linux-arm64-musl-12.3.4.tgz", + "integrity": "sha512-EETZPa1juczrKLWk5okoW2hv7D7WvonU+Cf2CgsSoxgsYbUCZ1voOpL4JZTOb6IbKMDo6ja+SbY0vzXZBUMvkQ==", + "cpu": [ + "arm64" + ], + "dev": true, + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">= 10" + } + }, + "packages/experimental-app-router/node_modules/@next/swc-linux-x64-gnu": { + "version": "12.3.4", + "resolved": "https://registry.npmjs.org/@next/swc-linux-x64-gnu/-/swc-linux-x64-gnu-12.3.4.tgz", + "integrity": "sha512-4csPbRbfZbuWOk3ATyWcvVFdD9/Rsdq5YHKvRuEni68OCLkfy4f+4I9OBpyK1SKJ00Cih16NJbHE+k+ljPPpag==", + "cpu": [ + "x64" + ], + "dev": true, + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">= 10" + } + }, + "packages/experimental-app-router/node_modules/@next/swc-linux-x64-musl": { + "version": "12.3.4", + "resolved": "https://registry.npmjs.org/@next/swc-linux-x64-musl/-/swc-linux-x64-musl-12.3.4.tgz", + "integrity": "sha512-YeBmI+63Ro75SUiL/QXEVXQ19T++58aI/IINOyhpsRL1LKdyfK/35iilraZEFz9bLQrwy1LYAR5lK200A9Gjbg==", + "cpu": [ + "x64" + ], + "dev": true, + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">= 10" + } + }, + "packages/experimental-app-router/node_modules/@next/swc-win32-arm64-msvc": { + "version": "12.3.4", + "resolved": "https://registry.npmjs.org/@next/swc-win32-arm64-msvc/-/swc-win32-arm64-msvc-12.3.4.tgz", + "integrity": "sha512-Sd0qFUJv8Tj0PukAYbCCDbmXcMkbIuhnTeHm9m4ZGjCf6kt7E/RMs55Pd3R5ePjOkN7dJEuxYBehawTR/aPDSQ==", + "cpu": [ + "arm64" + ], + "dev": true, + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": ">= 10" + } + }, + "packages/experimental-app-router/node_modules/@next/swc-win32-ia32-msvc": { + "version": "12.3.4", + "resolved": "https://registry.npmjs.org/@next/swc-win32-ia32-msvc/-/swc-win32-ia32-msvc-12.3.4.tgz", + "integrity": "sha512-rt/vv/vg/ZGGkrkKcuJ0LyliRdbskQU+91bje+PgoYmxTZf/tYs6IfbmgudBJk6gH3QnjHWbkphDdRQrseRefQ==", + "cpu": [ + "ia32" + ], + "dev": true, + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": ">= 10" + } + }, + "packages/experimental-app-router/node_modules/@next/swc-win32-x64-msvc": { + "version": "12.3.4", + "resolved": "https://registry.npmjs.org/@next/swc-win32-x64-msvc/-/swc-win32-x64-msvc-12.3.4.tgz", + "integrity": "sha512-DQ20JEfTBZAgF8QCjYfJhv2/279M6onxFjdG/+5B0Cyj00/EdBxiWb2eGGFgQhrBbNv/lsvzFbbi0Ptf8Vw/bg==", + "cpu": [ + "x64" + ], + "dev": true, + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": ">= 10" + } + }, "packages/experimental-app-router/node_modules/@swc/helpers": { "version": "0.5.2", "dev": true, diff --git a/packages/faustwp-core/src/getProps.ts b/packages/faustwp-core/src/getProps.ts index b02f841b9..432f030cf 100644 --- a/packages/faustwp-core/src/getProps.ts +++ b/packages/faustwp-core/src/getProps.ts @@ -65,6 +65,7 @@ export async function getNextStaticProps( if (isBoolean(notFound) && notFound === true) { return { notFound, + revalidate: DEFAULT_ISR_REVALIDATE, }; } diff --git a/packages/faustwp-core/src/getWordPressProps.tsx b/packages/faustwp-core/src/getWordPressProps.tsx index c35ea4f5f..aad6aae30 100644 --- a/packages/faustwp-core/src/getWordPressProps.tsx +++ b/packages/faustwp-core/src/getWordPressProps.tsx @@ -16,6 +16,14 @@ function isSSR( return (ctx as GetServerSidePropsContext).req !== undefined; } +const createNotFound = ( + ctx: GetStaticPropsContext, + revalidate?: number | boolean, +) => ({ + notFound: true as const, + ...(!isSSR(ctx) && { revalidate: revalidate ?? DEFAULT_ISR_REVALIDATE }), +}); + export type WordPressTemplate = React.FC & { query?: DocumentNode; variables?: ( @@ -54,6 +62,7 @@ export async function getWordPressProps( } | { notFound: true; + revalidate?: number | boolean | undefined; } > { const { templates } = getConfig(); @@ -84,9 +93,7 @@ export async function getWordPressProps( }) as string | null; if (!resolvedUrl) { - return { - notFound: true, - }; + return createNotFound(ctx, revalidate); } const seedQuery = hooks.applyFilters('seedQueryDocumentNode', SEED_QUERY, { @@ -104,9 +111,7 @@ export async function getWordPressProps( debugLog(`Seed Node for resolved url: "${resolvedUrl}": `, seedNode); if (!seedNode) { - return { - notFound: true, - }; + return createNotFound(ctx, revalidate); } infoLog( @@ -117,9 +122,7 @@ export async function getWordPressProps( const template = getTemplate(seedNode, templates); if (!template) { - return { - notFound: true, - }; + return createNotFound(ctx, revalidate); } let templateQueryRes; diff --git a/packages/faustwp-core/tests/getProps.test.ts b/packages/faustwp-core/tests/getProps.test.ts index 0b0cc076f..0034a73ba 100644 --- a/packages/faustwp-core/tests/getProps.test.ts +++ b/packages/faustwp-core/tests/getProps.test.ts @@ -29,7 +29,7 @@ describe('getProps', () => { expect.assertions(1); expect( await getNextStaticProps({}, { Page: {}, notFound: true }), - ).toStrictEqual({ notFound: true }); + ).toStrictEqual({ notFound: true, revalidate: 900 }); }); test('getNextStaticProps() handles `redirect`', async () => {