Thinkmill / keystatic

First class CMS experience, TypeScript API, Markdown & YAML/JSON based, no DB
https://keystatic.com
MIT License
1.23k stars 79 forks source link

Reader fails in Dynamic Route inside app router root directory on production #1333

Open bastienrobert opened 1 month ago

bastienrobert commented 1 month ago

When trying to use the Keystatic reader to fetch content within a dynamic route under the app/ directory, the reader does not function as expected. This issue occurs specifically when the route is dynamic ([slug], [id], etc.), and the Keystatic reader is called to fetch content dynamically based on the route parameters.

Steps to Reproduce:

  1. Set up a Next.js project using the app/ directory structure.
  2. Install and configure Keystatic to manage static content (e.g., Markdown files).
  3. Create a dynamic route, such as app/[slug]/page.tsx, and call the Keystatic reader inside it to fetch content based on the slug.
  4. Try accessing the route with different dynamic values (/post-1, /post-2, etc.).

REPO https://github.com/bastienrobert/nextjs-keystatic-test-params-repro

Workaround: Dynamic import using the standard import() method, put every mdx and markdoc inline and format files to JSON.