vitejs / vite-plugin-react-pages

A vite framework for building react app. Especially suitable for document site and demos/playgrounds of react components.
https://vitejs.github.io/vite-plugin-react-pages/
MIT License
459 stars 70 forks source link

Can the filebased routing be used standalone? #4

Closed thelinuxlich closed 3 years ago

thelinuxlich commented 3 years ago

I would like to add a filebased routing implementation to my starter pack https://github.com/thelinuxlich/react-modern-starter

csr632 commented 3 years ago

The filebased routing can't be used standalone. Because the routing mechanism is coupled with ssr, theming .etc. But I think you can implement a filebased routing plugin by yourself. You can refer to this code fromvite-plugin-react-pages: https://github.com/vitejs/vite-plugin-react-pages/blob/daab754690e75f1a30c6bd8ea7581c2af308b465/packages/react-pages/src/node/index.ts#L66

In the client side, the bootstrap code will import pageList from '@!virtual-modules/pages'; and render routes with it.

thelinuxlich commented 3 years ago

Oh, looking at the code it doesn't seem to have id support yet, so it's kinda on the same state as my poor-man's autorouting https://github.com/thelinuxlich/react-modern-starter/blob/main/src/AutoRouting.jsx

csr632 commented 3 years ago

Do you mean url parameter? I actually just supported url parameter a couple minutes ago.

3