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

fix(pathname.ts): ssg dynamic routes #1197

Merged
merged 1 commit into from
Sep 2, 2022

Conversation

robisim74
Copy link
Contributor

fix #1196

What is it?

  • Feature / enhancement
  • Bug
  • Docs / tests

Description

The issue comes from here: https://github.com/BuilderIO/qwik/blob/main/packages/qwik-city/utils/pathname.ts#L59

Using replace in this way, when the parameter is missing, results in a double // that is no longer normalized.

I preferred to fix the normalizePathname function rather than the getPathnameForDynamicRoute, so as to avoid other similar situations.

Use cases and why

When I run ssg with the following routes folder:

routes
    [...id]
        page
            index.tsx
        index.tsx

I expect in dist folder (using myId and an empty value for id:

myId
    page
        index.html
    index.html

page
    index.html
index.html

Instead, when the id parameter is empty, nested page is removed.

Checklist:

  • My code follows the developer guidelines of this project
  • I have performed a self-review of my own code
  • I have made corresponding changes to the documentation
  • Added new tests to cover the fix / functionality

fix ssg dynamic routes with optional parameters in root folder and nested pages

fix QwikDev#1196
@adamdbradley adamdbradley merged commit a8d18b9 into QwikDev:main Sep 2, 2022
@adamdbradley
Copy link
Contributor

This is great, and thanks for adding tests!

@robisim74
Copy link
Contributor Author

(Thanks you for your work.... you are solving a lot of problems of web development)

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.

SSG: dynamic routes with optional parameter & nested pages not working
2 participants