rohit-gohri / redocusaurus

OpenAPI for Docusaurus with Redoc
https://redocusaurus.vercel.app/
MIT License
629 stars 114 forks source link

Using / for API reference #273

Closed jrub closed 1 year ago

jrub commented 1 year ago

Hi there,

I'm using '/' as route on the config so that the main page is the API Reference (the Redoc component). However, no matter if I use the cusom page or custom layout, I get stuck into "Loading".

When using a different route like '/api', it works fine.

Any clue? Thx!

jrub commented 1 year ago

PS: when using yarn build, it fails with [ERROR] Docusaurus server-side rendering could not render static page with path /.

rohit-gohri commented 1 year ago

Are using both the route option and also creating a custom page using index.jsx/tsx file in the pages directory? Then these options might conflict, you can remove one of them and I think it should work.

If you have a link to the repo that would be great to debug this

jrub commented 1 year ago

With route completely removed from the config, and using https://github.com/rohit-gohri/redocusaurus/blob/main/website/src/pages/examples/custom-layout/index.jsx as my only src/pages/index , it's stuck on Loading.

However, now I tried to remove all the /src and using route: '/' on config and it loads fine.

Could it be that import useSpecData from '@theme/useSpecData'; does not load at all?

jrub commented 1 year ago

@rohit-gohri here you have an example config and page https://github.com/jrub/redocusaurus_test

rohit-gohri commented 1 year ago

Figured it out. The id in useSpecData is supposed to be the same id you specify in the docusaurus config (here https://github.com/jrub/redocusaurus_test/blob/63a8e30710d18c586e835ff3d41047f450091a2b/docusaurus.config.js#L66). Let me know if this is not the fix.

I guess it's not very clear in the docs. Added it as a TODO to the existing docs ticket (https://github.com/rohit-gohri/redocusaurus/issues/147).

jrub commented 1 year ago

Cool! That worked, thank you 🙏