【问题标题】:NextJS dynamic slug for routeNextJS 动态 slug 用于路由
【发布时间】:2020-07-14 19:40:51
【问题描述】:

有没有办法在 NextJS 中执行以下操作?

/route1
/translatedRoute1
/route2
/translatedRoute2

有这个文件夹结构

pages/
  [route1]/
    index.js
  [route2]/
    index.js

这将产生错误,因为 [route1] 和 [route2] 在所有情况下都将匹配。 我的想法是我想为英语和罗马尼亚语呈现相同的组件。

/about-us
/despre-noi

-> I want this to render the same component as "/about-us"

This can be achieved with

/en/about-us
/ro/about-us

But this is not the desired effect.

想要的效果是改变不同语言的slug

【问题讨论】:

    标签: next.js


    【解决方案1】:

    我认为您将不得不使用一些插件,因为这样的高级配置不是开箱即用的。

    在我看来,这就是您所需要的: https://github.com/vonschau/next-routes-with-locale#how-to-use

    【讨论】:

    • 我设法为我的特定用例找到了解决方法,但非常感谢:)!
    • @EmanuelCengher 你能发布一下你是怎么解决的吗?
    • @EmanuelCengher 你是怎么解决这个问题的?我有一个类似的问题
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2021-07-11
    • 2020-09-08
    • 2021-08-12
    • 2020-08-25
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多