我正在使用 React/NextJS 创建一个最终将用作静态站点的应用程序。我已经预定义了需要在子目录中创建的 url。例如,/technology/
应该去/technology/index.html
如何在 Nextjspages
结构中创建它?
我尝试了以下各种组合,但没有运气:
- 添加
trailingSlash
到我的 nextjs 配置中:
module.exports.trailingSlash = true;
添加
technology.js
到我的页面目录(也尝试过/technology/index.js
)添加
exportPathMap
到我的 next.config.js:
exportPathMap: async function (
defaultPathMap,
{ dev, dir, outDir, distDir, buildId }
) {
return {
'/': { page: '/' },
'/technology/index.html': { page: '/technology' },
};
},
trailingSlash: true