我正在学习 NextJS13,并正在关注 Sonny Sangha 的在线博客教程“让我们使用 Next.js 13 构建一个博客(Sanity v3、TypeScript、Tailwind CSS、Auth、CMS、预览模式)”。完成本教程后,我想将站点部署到 Vercel,但是我遇到了这个问题:
应用程序/(用户)/page.tsx “查询的页面导出字段无效
相关页面的具体代码如下:
import { groq } from "next-sanity";
import { client } from "../../sanity/lib/client"
import BlogList from "../../components/BlogList";
export const query = groq`
*[_type == 'post'] {
...,
author->,
categories[]->,
} | order(_createdAt desc)
`;
export default async function HomePage() {
const posts = await client.fetch(query);
return (
<BlogList posts = {posts} />
);
}
我尝试了 getstaticprops 但显然这在 nextjs13 中已经过时了。并且不知道如何在不导出查询的情况下查询 sanity.io (我第一次使用 nextjs 构建任何东西)。任何帮助将不胜感激。
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号
只需删除
query的export,这样就只导出React组件(HomePage)。