astro icon indicating copy to clipboard operation
astro copied to clipboard

When creating a page with `getStaticPaths` which return a `number` param, later `Astro.params` returns a `string`

Open marceloverdijk opened this issue 2 years ago • 14 comments

What version of astro are you using?

1.0.5

Are you using an SSR adapter? If so, which one?

None

What package manager are you using?

npm

What operating system are you using?

Mac

Describe the Bug

When creating a page with getStaticPaths which return a number param, later Astro.params returns a string.

---
import Layout from '../../layouts/Layout.astro';

export function getStaticPaths() {
  return [
    { params: { year: 1990 } }, // year is a number
    { params: { year: 1991 } },
    { params: { year: 1992 } },
  ]
}

const { year } = Astro.params
---

<Layout title="Season">
  {JSON.stringify(year)}
</Layout>

when accessing /seasons/1990 this prints:

"1990"

although expected:

1990

Link to Minimal Reproducible Example

https://stackblitz.com/edit/github-ydxdyc?file=src/pages/seasons/[year].astro

Participation

  • [ ] I am willing to submit a pull request for this issue.

marceloverdijk avatar Aug 13 '22 22:08 marceloverdijk