diff --git a/packages/cms/keystatic/README.md b/packages/cms/keystatic/README.md index eff076560..a99c644dc 100644 --- a/packages/cms/keystatic/README.md +++ b/packages/cms/keystatic/README.md @@ -32,11 +32,16 @@ KEYSTATIC_STORAGE_KIND=github KEYSTATIC_STORAGE_REPO=makerkit/next-supabase-saas-kit-turbo-demo KEYSTATIC_GITHUB_TOKEN=github_***************************************************** KEYSTATIC_PATH_PREFIX=apps/web -KEY_STATIC_PATH_PREFIX=content ``` Of course, you need to replace the `KEYSTATIC_STORAGE_REPO` and `KEYSTATIC_GITHUB_TOKEN` with your own values. GitHub mode requires the installation of a GitHub app for displaying the admin. -Please refer to the [Keystatic documentation](https://keystatic.com/docs/github-model) for more information. \ No newline at end of file +Please refer to the [Keystatic documentation](https://keystatic.com/docs/github-model) for more information. + +If your content folder is not at `content`, you can set the `KEYSTATIC_CONTENT_PATH` environment variable to the correct path. For example, if your content folder is at `data/content`, you can set the `KEYSTATIC_CONTENT_PATH` environment variable as: + +``` +KEYSTATIC_CONTENT_PATH=data/content +``` \ No newline at end of file diff --git a/packages/cms/keystatic/src/create-reader.ts b/packages/cms/keystatic/src/create-reader.ts index 1ed2b2615..58531638d 100644 --- a/packages/cms/keystatic/src/create-reader.ts +++ b/packages/cms/keystatic/src/create-reader.ts @@ -1,15 +1,23 @@ import { z } from 'zod'; +const STORAGE_KIND = process.env.KEYSTATIC_STORAGE_KIND ?? 'local'; + /** * Create a KeyStatic reader based on the storage kind. */ export async function createKeystaticReader() { - switch (process.env.KEYSTATIC_STORAGE_KIND ?? 'local') { + switch (STORAGE_KIND) { case 'local': { - const { default: config } = await import('./keystatic.config'); - const { createReader } = await import('@keystatic/core/reader'); + if (process.env.NEXT_RUNTIME === 'nodejs') { + const { default: config } = await import('./keystatic.config'); + const { createReader } = await import('@keystatic/core/reader'); - return createReader('.', config); + return createReader('.', config); + } else { + // we should never get here but the compiler requires the check + // to ensure we don't parse the package at build time + throw new Error(); + } } case 'github': diff --git a/packages/cms/keystatic/src/keystatic.config.ts b/packages/cms/keystatic/src/keystatic.config.ts index 2cf0b89ac..70b250b9e 100644 --- a/packages/cms/keystatic/src/keystatic.config.ts +++ b/packages/cms/keystatic/src/keystatic.config.ts @@ -30,7 +30,7 @@ const storage = z.union([local, cloud, github]).parse({ pathPrefix: process.env.KEYSTATIC_PATH_PREFIX, }); -const path = process.env.KEY_STATIC_PATH ?? 'content'; +const path = process.env.KEYSTATIC_CONTENT_PATH ?? 'content'; const keyStaticConfig = createKeyStaticConfig(path);