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

想要配置一个不带左侧导航的首页可以实现吗 #157

Closed lh-js closed 1 year ago

lh-js commented 1 year ago

想要配置一个不带左侧导航的首页可以实现吗

csr632 commented 1 year ago

支持的,_theme.tsx 的ThemeConfig.sideNavs支持传入一个函数:

import { createTheme, defaultSideNavs } from 'vite-pages-theme-doc'

export default createTheme({
  // ...
  sideNavs: (ctx) => {
    if (ctx.loadState.routePath === '/') {
      // hive sideNavs in this page
      return null
    }
    // otherwise use the default sideNavs behaviour
    return defaultSideNavs(ctx);
  },
})

Demo: https://stackblitz.com/edit/vitejs-vite-plugin-react-pages-2ma2q2?file=pages%2F_theme.tsx&terminal=dev