VulcanJS / vulcan-npm

The full-stack JavaScript App Framework
https://vulcan-docs.vercel.app
MIT License
31 stars 8 forks source link

@vulcan/mdx recursive list mdx files #26

Closed Neobii closed 3 years ago

Neobii commented 3 years ago

In order to make ListMdxFiles recursive, we should decide how we handle the index.md files, or if we handle them.

For example, /docs/nest/index.md should resolve to /docs/nest instead of /docs/nest/index.

This was the object planned... if I'm correct.

interface MdxFile {
  fileName: string; // filename with extension
  relativePath: string;
  pageName: String
}
eric-burel commented 3 years ago

Yeah good question. I definitely buy the /docs/nest in this specific scenario, because this is how pages works in Next.js (whatever the page extension is, so including .md, .mdx or whatever). I wonder how Next handles conflicting names like /docs/nest.md and /docs/nest/index.md, never tried it yet. But we could simply fail in this specific scenario with an error message.

Neobii commented 3 years ago

I have the nested documents working on this branch.

Do you think this functionality still belongs in vulcan-npm and not in vulcan-next?

eric-burel commented 3 years ago

Initially it was in vulcan-next indeed. I wanted something easy to remove though to unbloat the starter, as we may want to add more features to @vulcan/mdx in the future.

eric-burel commented 3 years ago

The code sounds good, do not hesitate to PR so I can review (preferably with a few unit tests if you have some spare time, using a mock for readdir, but I can handle that)

Neobii commented 3 years ago

Aha, I was afraid of bloating the monorepo! I think the finding files recursively and dealing with index type things might be in a lib folder rather than the mdx type stuff.

However, we could put this in the mdx mdx first tag regex

eric-burel commented 3 years ago

It's better to bloat the monorepo than the starter imo, because you are not forced to install all packages through NPM, only the ones you use, so it's a safe place for adding whatever we want. The Starter has to be streamlined as much as possible (it's already bloated with styling stuff...).