Skip to content

Fix/numeric path params#3087

Merged
natemoo-re merged 3 commits intomainfrom
fix/numeric-path-params
Apr 15, 2022
Merged

Fix/numeric path params#3087
natemoo-re merged 3 commits intomainfrom
fix/numeric-path-params

Conversation

@tony-sull
Copy link
Copy Markdown
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
Copy Markdown

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
Copy Markdown
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
Copy Markdown
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
@ascorbic ascorbic mentioned this pull request Jul 22, 2025
1 task
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