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

The ability to handle routes like :category/:topic without having to prefix with a parent path #359

Closed
2 tasks
fireflysemantics opened this issue Apr 23, 2023 · 2 comments
Labels
enhancement New feature or request

Comments

@fireflysemantics
Copy link

Which scope/s are relevant/related to the feature request?

create-analog

Information

Currently all dynamic routes in AnalogJS have to be in a parent folder or prefixed with a parent path.

Dynamic routes are defined by using the filename as the route path enclosed in square brackets. Dynamic routes must be placed inside a parent folder, or prefixed with a parent path and a period.

I have an app that defines a route like this:

  {
    path: ':category/:topic',
    component: TopicComponent,
    data: ROUTE_DATA,
    resolve: { topic: topicResolver },
    canActivate: [topicGuard]
  },

And it renders URLs like this:

https://developer.fireflysemantics.com/blogs/blogs--design--the-power-of-the-simplest-possible-example
https://developer.fireflysemantics.com/guides/guides--macos--mac-os-keyboard-shortcuts

And these routes are currently being statically rendered by Scully.

If I switch to AnalogJS, I'd have to create a component for each category even though they can all be handled by the same component:

  • blogs
  • tasks
  • examples
  • concepts
  • formulas

Describe any alternatives/workarounds you're currently using

Currently using Scully.

I would be willing to submit a PR to fix this issue

  • Yes
  • No
@fireflysemantics fireflysemantics added the enhancement New feature or request label Apr 23, 2023
@brandonroberts
Copy link
Member

Similar to #273

You can define route paths as src/app/pages/[category].[topic].page.ts for the equivalent route.

@fireflysemantics
Copy link
Author

fireflysemantics commented May 4, 2023

Hi Brandon,

I also thought this would work:

You can define route paths as src/app/pages/[category].[topic].page.ts for the equivalent route.

So I tried it with this application:

https://github.com/fireflysemantics/analog-project/tree/main/src/app/pages

And if I enter the URL:

http://localhost:5173/blog/1234

It renders the right page. However if I try to match this route:

/[productId].[partid].page.ts

With a URL like:

http://localhost:5173/1234/1234

It reroutes to the error page. Thoughts?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants