我有这样的文件夹 struct :
/
|- ...
|- pages
|- info
| |- main.tsx
|- extra
|- main.tsx
/info/main
路由和/extra/main
路由都呈现相同的内容,包括getServerSideProps
.我的问题是如何在其中一个中实现逻辑,并在另一个中重用它,这样代码就不会重复.我试了extra/main.tsx
次:
import MainCmp from '../info/main';
export default MainCmp;
它可以工作,但不能执行getServerSideProps
次.还try 了rewrites
:
module.exports = {
async rewrites() {
return [
{
source: '/extra/main',
destination: '/info/main',
},
]
},
}
并再次工作,但然后URL是/info/main
,而不是/extra/main
时加载一些额外的…
有什么关于如何解决这个问题的提示吗?