gvergnaud / nextjs-dynamic-routes

[Deprecated] Super simple way to create dynamic routes with Next.js
MIT License
140 stars 7 forks source link

Not working with name different from page #10

Closed lishine closed 5 years ago

lishine commented 5 years ago

I want: the route to be named 'home' but file to be named 'index' I write

router.add({
    name: 'home',
    pattern: '/',
    page: 'index',
})

But the loading is stuck

If I change to:

router.add({
    name: 'index',
    pattern: '/',
})

It works.

Am I doing something wrong? Last version of the lib, last stable next, react@next

        "@emotion/core": "^10.0.6",
        "@emotion/styled": "^10.0.6",
        "@zeit/next-sass": "^1.0.1",
        "express": "^4.16.4",
        "formik": "^1.4.2",
        "isomorphic-unfetch": "^3.0.0",
        "js-cookie": "^2.2.0",
        "next": "latest",
        "next-compose-plugins": "^2.1.1",
        "next-cookies": "^1.0.4",
        "next-redux-wrapper": "^2.1.0",
        "nextjs-dynamic-routes": "^2.3.0",
        "node-sass": "^4.11.0",
        "react": "^16.7.0-alpha.2",
        "react-dom": "^16.7.0-alpha.2",
        "react-easy-state": "^6.1.0",
        "react-modal": "^3.8.1",
        "react-progress-button": "^5.1.0",
        "react-reim": "^1.14.1",
        "reim": "^1.13.0",
        "yup": "^0.26.6"
lishine commented 5 years ago

Found out! page should be '/index'

lishine commented 5 years ago

This

router.add({
  name: 'characterAndFilm',
  pattern: '/character-and-film/:characterId/:filmId',
  page: 'character-and-film'
})

into this, right ?

router.add({
  name: 'characterAndFilm',
  pattern: '/character-and-film/:characterId/:filmId',
  page: '/character-and-film'
})
gvergnaud commented 5 years ago

right! I gess we could add support for both index and /index. You are welcome to open a PR to fix the readme if you want :) Thanks

gvergnaud commented 5 years ago

I just fixed the readme.