natemoo-re / microsite

Do more with less JavaScript. Microsite is a smarter, performance-obsessed static site generator powered by Preact and Snowpack.

Home Page:https://npm.im/microsite

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

getStaticPaths uses module’s path when returning params object

eyelidlessness opened this issue · comments

Steps to reproduce

  1. Install microsite@next
  2. Create a page posts.tsx
  3. Follow these instructions from the docs
  4. Return { paths: [ { params: { id: '1' } }, { params: { id: '2' } } ] }
  5. Build

Expected result

Two pages will be built, with their respective content:

  • /posts/1.html
  • /posts/2.html

Observed result

Both pages will be built at posts.html, with whichever finished last winning.

Notes and workaround

  • The non-params string version worked as expected for me.
  • The path template static typing is cool, and it’s awesome to see that TS feature used in the wild! However, it loses inference on any other returned params.
  • I’m happy to take a look at both issues if I’m able to come up for air this weekend 🙂

However, it loses inference on any other returned params.

To clarify why this might matter, I had originally intended to provide the expected path params but also preserve some intermediate metadata for getStaticProps. Recreating that was trivial for my use case, but may be expensive for other projects.