Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Componentize the docs theme #332

Open
tyrw opened this issue Jan 20, 2022 · 5 comments
Open

Componentize the docs theme #332

tyrw opened this issue Jan 20, 2022 · 5 comments
Milestone

Comments

@tyrw
Copy link

tyrw commented Jan 20, 2022

Currently the themes are essentially all or nothing for a given page, which makes it harder to adopt Nextra in more advanced projects.

For our use case, we love the sidebar of the docs theme but we want to use a different navbar.

It would be wonderful if the theme followed the Next.js convention of using a file in components/layout.js, and we could do something like:

import { Default, Sidebar, Main, Footer } from "nextra-theme-docs";
import { CustomHeader } from "./custom-header.js";

export default function Layout(props) {
  const { meta, route, ...rest } = props;

  // Use custom layouts with common components anywhere
  if (route.startsWith("/custom")) {
    return function Layout({ children }) {
      return (
        <>
          <CustomHeader />
          <Sidebar />
          <Main>{ children }</Main>
          <Footer />
        </>
      );
    };
  }

  // Retain the default layout for all other routes
  return Default();
}

This would really make Nextra a killer app for us, as we would get all of the complexity of auto-generating the sidebar from the file tree, while retaining the ability to customize parts of the page directly instead of through configuration.

Also for context, our first attempt was looking at the docs theme in the core branch here. We quickly realized it would be brittle to start tweaking things and would also make it harder for us to contribute to Nextra once we had "ejected".

Nextra feels like a really powerful project, so thank you for building it!

@brendanfalk
Copy link

We would also be super interested in this @withfig - is there any way we can help?

@shuding
Copy link
Owner

shuding commented Feb 19, 2022

I’ve been thinking about this feature recently, and will start working on it! Componentize the theme will also give us the ability to hide specific part (like the sidebar) for specific pages.

@brendanfalk
Copy link

Awesome - that’s so great to hear! Thank you so much and as I said, please let us know if we can help!

@eivindml
Copy link

eivindml commented Mar 24, 2022

I would also love this! Our use case:

We have highly custom documentation code with much more tsx than md. So the mdx format creates more trouble than what it solves. Not all editors have great mdx support, so the developer experience is not as good as it could be!

But by renaming pages from _.mdx to _.tsx we loose all of the nice stuff that nextra provides.

@AnanyaGB
Copy link

AnanyaGB commented Sep 2, 2023

A feature like a custom navbar component using next.js conversion would be really great.

@dimaMachina dimaMachina added this to the 4.0 milestone Sep 5, 2023
@dimaMachina dimaMachina mentioned this issue Dec 26, 2023
10 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants