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

I want some explanation #6

Open
andrrms opened this issue Sep 20, 2020 · 4 comments
Open

I want some explanation #6

andrrms opened this issue Sep 20, 2020 · 4 comments
Assignees
Labels
question Further information is requested

Comments

@andrrms
Copy link

andrrms commented Sep 20, 2020

I am new to this framework and kinda new to React and I was trying to look for a decent routing system when I found your solution. Could you explain better how to implement it? I would like to create a project from scratch with this solution but I found the code very confusing.

@bdombro
Copy link
Collaborator

bdombro commented Sep 21, 2020 via email

@siminture
Copy link
Owner

siminture commented Sep 29, 2020

Routes and navigation menus are usually the same structure, similar to a sitemap file.
There are two options:

  • define the page components, in the app page according to the sitemap structure to define the route, and in the navigation menu to do the same thing;
  • define the sitemap, according to the sitemap to generate routing, navigation menu;

Including the title of the page, access control of the page, etc. can be defined in the sitemap file.

In this project, the routeConfig.js is a sitemap file.
The hierarchize function is used to generate a hierarchical path and page ID, and if you are so confused, you can manually specify the path and page ID without using it.

{
    key: 'home',
    uniqueId: 'home',
    name: 'Home',
    icon: 'Home',
    path: '/',
    component: React.lazy(() = > import('./components/pages/Dashboard')),
    children: [{
        key: 'login',
        uniqueId: 'home-login',
        path: '/login',
        name: 'Login',
        isPublic: true,
        isHidden: true,
        component: React.lazy(() = > import('./components/pages/Login')),
    }, {
        key: 'mangement',
        uniqueId: 'home-mangement',
        path: '/mangement',
        name: 'System Management',
        icon: 'managementApp',
        children: [{
            key: 'organization',
            uniqueId: 'home-mangement-organization',
            path: '/mangement/organization',
            name: 'Organization',
            icon: 'Org'
        }, ]
    }]
}

My more recommended solution is use the webpack plugin before packaging according to the pages directory structure to generate Sitemap files.

e.g. gatsby & gatsby source filesystem plugin
https://www.gatsbyjs.com/plugins/gatsby-source-filesystem/

@siminture siminture self-assigned this Sep 30, 2020
@siminture siminture added the question Further information is requested label Sep 30, 2020
@Akshay090
Copy link

@siminture thanks for making this starter project, it helped a lot.
I want to know more about this style of routing, can you link to something I can refer to.
I have previously seen this style in dashboards by Creative Tim, maybe this is a common pattern followed in dashboard projects.

@ace3
Copy link

ace3 commented Nov 3, 2020

at first , the route structure is really daunting, but after reading the hierarchize function, i really love the idea.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

5 participants