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

feat(router): overhaul route discovery engine #444

Merged

Conversation

markostanimirovic
Copy link
Member

@markostanimirovic markostanimirovic commented May 28, 2023

PR Checklist

Please check if your PR fulfills the following requirements:

PR Type

What kind of change does this PR introduce?

  • Bugfix
  • Feature
  • Code style update (formatting, local variables)
  • Refactoring (no functional changes, no api changes)
  • Build related changes
  • CI related changes
  • Documentation content changes
  • Other... Please describe:

Which package are you modifying?

  • vite-plugin-angular
  • vite-plugin-nitro
  • astro-angular
  • create-analog
  • router
  • platform
  • content
  • nx-plugin
  • trpc

What is the current behavior?

  • It's not possible to create named nested pages without a parent (layout) page.
  • Creating pages within the pathless directory and pathless layouts are not supported.

Closes #237, #273

What is the new behavior?

  • We can create named nested routes without a layout route.
/pages
  /blog
    posts.page.ts
  • We can create pages within the pathless directories.
/pages
  /(auth)
    login.page.ts
    signup.page.ts
  • We can define the layout page for pages within the pathless directory.
/pages
  /(auth)
    login.page.ts
    signup.page.ts
  (auth).page.ts
  • We can create nested wildcard routes:
/pages
  /blog
    posts.page.ts
    [...blog-not-found].md
  blog.page.ts
  index.page.ts
  [...not-found].md

Does this PR introduce a breaking change?

  • Yes
  • No

[optional] What gif best describes this PR or how it makes you feel?

hooray-letsgo

EDIT: 😅

magic

@netlify
Copy link

netlify bot commented May 28, 2023

Deploy Preview for analog-docs ready!

Name Link
🔨 Latest commit b98c66c
🔍 Latest deploy log https://app.netlify.com/sites/analog-docs/deploys/647a11a4ba40050008240fb3
😎 Deploy Preview https://deploy-preview-444--analog-docs.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site settings.

@netlify
Copy link

netlify bot commented May 28, 2023

Deploy Preview for analog-blog ready!

Name Link
🔨 Latest commit b98c66c
🔍 Latest deploy log https://app.netlify.com/sites/analog-blog/deploys/647a11a4a2b72400080b890c
😎 Deploy Preview https://deploy-preview-444--analog-blog.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site settings.

@netlify
Copy link

netlify bot commented May 28, 2023

Deploy Preview for analog-app ready!

Name Link
🔨 Latest commit b98c66c
🔍 Latest deploy log https://app.netlify.com/sites/analog-app/deploys/647a11a40b7be800089a9bc1
😎 Deploy Preview https://deploy-preview-444--analog-app.netlify.app/
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site settings.

@markostanimirovic markostanimirovic marked this pull request as ready for review June 1, 2023 23:39
packages/router/src/lib/routes.ts Outdated Show resolved Hide resolved
packages/router/src/lib/routes.ts Show resolved Hide resolved
@brandonroberts brandonroberts changed the title feat(router): overhaul feat(router): overhaul route discovery engine Jun 2, 2023
@brandonroberts brandonroberts merged commit d99869c into analogjs:main Jun 2, 2023
@zawasp
Copy link
Contributor

zawasp commented Jun 3, 2023

Does this by any chance also fix #412 ?

@matheo
Copy link

matheo commented Aug 19, 2023

@markostanimirovic the router-discovery doesn't support two levels of nesting right?
I was trying to do this:

pages/
└── admin/
    └── entity/
            ├── add.page.ts
            └── (list).page.ts

I just started to try analogjs and I came with the expectation of infinite nesting 😅
but now I realize that once inside a subfolder I have to use the dot notation in the inner filenames.

@matheo
Copy link

matheo commented Aug 19, 2023

@brandonroberts it would be nice to have a command printing the detected routes somehow,
I tried to check the generated code with no luck

@brandonroberts
Copy link
Member

@matheo routing nested in folders is supported. What do you mean by using dot notation inside nested folders? Any file with a .page.ts extension should be picked up.

You can log the routes

import { routes } from '@analogjs/router';

console.log(routes);

Villanuevand pushed a commit to Villanuevand/analog that referenced this pull request Sep 12, 2023
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

Successfully merging this pull request may close these issues.

RFC: Add support for pathless layout routes
4 participants