nextra icon indicating copy to clipboard operation
nextra copied to clipboard

How to use in single website with both landing page and /docs route.?

Open softmarshmallow opened this issue 4 years ago • 3 comments

I have this site grida.co - https://github.com/gridaco/grida.co Which has both landing page and docs site (currently not using nextra)

And I'm wondering if i can spcecify nextra to only interpret specific directory - /docs and convert them to a docs site. not all of the entire repository.

Thanks!

softmarshmallow avatar Dec 17 '21 11:12 softmarshmallow

I want this too. Will this be available in nextra v2.0?

PabloLION avatar Jul 16 '22 21:07 PabloLION

I tested some work-arounds in NextJS Docs.

  1. Add a /pages/docs folder Just add this folder and Nextra will handle all .mdx file. The problem with this method is that all pages will show always show a top level "docs" folder.
  2. With basePath Here in https://nextjs.org/docs/migrating/incremental-adoption, there's an option to host a NextJS as subpath. Notice that you need to pass the nextConfig into withNextra. Problem here is I don't know and I didn't test if a rewrite is needed.

PabloLION avatar Jul 17 '22 21:07 PabloLION

The repo I used to test is here https://github.com/PabloLION/test-nextra

PabloLION avatar Jul 17 '22 21:07 PabloLION

Use https://github.com/shuding/nextra/tree/core/examples/swr-site as an example

dimaMachina avatar Sep 07 '22 11:09 dimaMachina

The problem with this method is that all pages will show always show a top level "docs" folder.

We can move "docs" from sidebar to NavBar by creating _meta.json outside "docs" folder with contents.

{
    "docs": {
      "title": "Docs",
      "type": "page"
    }
}

Before: image

After: image

Ref: https://nextra.site/docs/docs-theme/page-configuration#navbar-items

If we don't want "docs" at all, we can hide it: https://nextra.site/docs/docs-theme/page-configuration#hidden-routes

bube5h avatar Sep 13 '23 18:09 bube5h