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

Add support of nested routes #5

Open
40818419 opened this issue May 24, 2018 · 2 comments
Open

Add support of nested routes #5

40818419 opened this issue May 24, 2018 · 2 comments
Assignees

Comments

@40818419
Copy link
Owner

...
routes: [
    { path: '/', redirect: '/parent' },
    { path: '/parent', component: Parent,
      children: [
        // an empty path will be treated as the default, e.g.
        // components rendered at /parent: Root -> Parent -> Default
        { path: '', component: Default },

        // components rendered at /parent/foo: Root -> Parent -> Foo
        { path: 'foo', component: Foo },
      ]
   }
]
...
@40818419 40818419 self-assigned this May 24, 2018
@CheyenneForbes
Copy link

any update on this?

@mbarouski
Copy link

@CheyenneForbes
Solved it this way:

const sitemapBuilder = new VueRouterSitemap(router);
sitemapBuilder.paths = parseRoutes(router.options.routes);
// ...
function parseRoutes(routes) {
  return routes.reduce((acc, curr) => {
    if (curr.children && curr.children.length > 0) {
      parseRoutes(curr.children).forEach(c => {
        acc.push({
          ...c,
          path: `${curr.path}/${c.path}`
        });
      });
    } else {
      acc.push(curr);
    }
    return acc;
  }, []);
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants