Next.js Discord

Discord Forum

Is there a safe place to put files to read them as a directory structure?

Unanswered
Large garden bumble bee posted this in #help-forum
Open in Discord
Large garden bumble beeOP
Pretext: this is hacky, I know
I am currently using a CMS but want to get rid of it in favor of an app router with markdown files
I might have a structure like this:
./
├── public/
│   └── documents/
│       ├── articles/
│       │   ├── first-article/
│       │   │   └── page.md
│       │   └── second-article/
│       │       └── page.md
│       └── knowledge-base/
│           └── how-to-get-started/
│               └── page.md
├── src/
│   ├── app/
│   │   ├── [[...slugs]]/
│   │   │   ├── layout.tsx
│   │   │   └── page.tsx
│   │   └── page.tsx
│   └── components/
│       └── article-list/
│           ├── article-list.tsx
│           └── index.ts
├── next.config.mjs
└── package.json

In my src/app/[[...slugs]]/layout.tsx, I have the following:
export async function generateStaticPaths() {
  const files = Array.fromAsync(await walk(getRootPath(), {
    filter: filterByExtension('.md'),
    maxDepth: 2,
  }));
}

The problem seems like, when it's built, it won't be able to resolve this correctly. Is there a way around this? I need to dynamically load this directory

0 Replies