From 13c1ea187bb5e7f5a49c8a7095bba9473edc4f0f Mon Sep 17 00:00:00 2001 From: Jason Bahl Date: Fri, 12 Jan 2024 19:21:32 -0700 Subject: [PATCH] =?UTF-8?q?-=20refactor.=20Thanks=20@jordanmaslyn!=20?= =?UTF-8?q?=F0=9F=99=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- next.config.mjs | 49 +++++++++++++++++++++++++------------------------ 1 file changed, 25 insertions(+), 24 deletions(-) diff --git a/next.config.mjs b/next.config.mjs index a63b261..69561d0 100644 --- a/next.config.mjs +++ b/next.config.mjs @@ -1,33 +1,34 @@ import { withFaust, getWpHostname } from '@faustwp/core'; import withMarkdoc from '@markdoc/next.js' import withSearch from './markdoc/search.mjs' -import atlasCacheHandler from './.atlas/atlas-cache-handler.js' -function experimentalConfig() { - - const experimental = { - scrollRestoration: true, +async function getAtlasCacheHandler() { + if (process.env.ATLAS_CACHE_HANDLER_ENABLED !== "true") { + return {}; } + + const {default: atlasCacheHandler} = await import('./.atlas/atlas-cache-handler.js'); - if (process.env.ATLAS_CACHE_HANDLER_ENABLED !== undefined) { - const atlasExperimentalOptions = { ...experimental, ...{ - incrementalCacheHandlerPath: atlasCacheHandler, - isrMemoryCacheSize: 0 - }} - return atlasExperimentalOptions - } - - return experimental + return { + incrementalCacheHandlerPath: atlasCacheHandler, + isrMemoryCacheSize: 0, + }; } -const nextConfig = { - reactStrictMode: true, - pageExtensions: ['js', 'jsx', 'ts', 'tsx', 'mdx'], - experimental: experimentalConfig(), - trailingSlash: true, - images: { - domains: [getWpHostname()], - }, +const nextConfig = async () => { + return { + reactStrictMode: true, + pageExtensions: ['js', 'jsx', 'ts', 'tsx', 'mdx'], + experimental: { + scrollRestoration: true, + ...(await getAtlasCacheHandler()) + }, + trailingSlash: true, + images: { + domains: [getWpHostname()], + }, + } }; - -export default withFaust( withSearch( withMarkdoc({ schemaPath: './src/markdoc' })(nextConfig) ) ); + + +export default withFaust( withSearch( withMarkdoc({ schemaPath: './src/markdoc' })(nextConfig) ) ); \ No newline at end of file