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/numeric path params #3087

Merged
merged 3 commits into from
Apr 15, 2022
Merged

Fix/numeric path params #3087

merged 3 commits into from
Apr 15, 2022

Conversation

tony-sull
Copy link
Contributor

@tony-sull tony-sull commented Apr 12, 2022

Changes

Adds support for numeric route parameters in getStaticPaths(), for example when including years/months/days in a blog post URL

This also adds type validation for route parameters to throw an error when getStaticPaths() is given a parameter that isn't a string or number

Testing

getStaticPaths() test updated to include a route using a number for the year parameter

Docs

Related docs PR #345

@changeset-bot
Copy link

changeset-bot bot commented Apr 12, 2022

🦋 Changeset detected

Latest commit: e4b5509

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
astro Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@github-actions github-actions bot added pkg: astro Related to the core `astro` package (scope) test labels Apr 12, 2022
@tony-sull tony-sull linked an issue Apr 12, 2022 that may be closed by this pull request
1 task
@tony-sull tony-sull force-pushed the fix/numeric-path-params branch 2 times, most recently from a6474d7 to 3ee391e Compare April 14, 2022 07:43
@tony-sull tony-sull force-pushed the fix/numeric-path-params branch from 3ee391e to e4b5509 Compare April 15, 2022 12:38
Copy link
Contributor

@bholmesdev bholmesdev left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Finally unenc(n)umbered by bad type checks 👏

Copy link
Member

@natemoo-re natemoo-re left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice QoL improvement! LGTM.

@natemoo-re natemoo-re merged commit e0f838c into main Apr 15, 2022
@natemoo-re natemoo-re deleted the fix/numeric-path-params branch April 15, 2022 19:16
@github-actions github-actions bot mentioned this pull request Apr 15, 2022
Pimm added a commit to Pimm/astro that referenced this pull request Nov 27, 2022
A PR merged back in April changed the type of Params, allowing numbers to be provided in addition to strings. See withastro#3087. However, as said PR changed the type of Params instead of GetStaticPathsItem, it also affects Astro.params. This commit moves the change to GetStaticPathsItem, reverting the type of Astro.params.
@Pimm Pimm mentioned this pull request Nov 27, 2022
Pimm added a commit to Pimm/astro that referenced this pull request Nov 28, 2022
A PR merged back in April changed the type of Params, allowing numbers to be provided in addition to strings. See withastro#3087. However, as said PR changed the type of Params instead of GetStaticPathsItem, it also affects Astro.params. This commit moves the change to GetStaticPathsItem, reverting the type of Astro.params.
matthewp pushed a commit that referenced this pull request Nov 28, 2022
A PR merged back in April changed the type of Params, allowing numbers to be provided in addition to strings. See #3087. However, as said PR changed the type of Params instead of GetStaticPathsItem, it also affects Astro.params. This commit moves the change to GetStaticPathsItem, reverting the type of Astro.params.
SiriousHunter pushed a commit to SiriousHunter/astro that referenced this pull request Feb 3, 2023
* adding support for numeric params in getStaticPaths()

* chore: adding changeset

* ignore undefined params in type validation
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
pkg: astro Related to the core `astro` package (scope)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

🐛 BUG: dynamic route params as numbers break findPathItemByKey search
3 participants