我有 updateblog 按钮,我的动态路由 [detail].js 页面用于各个博客
在[详细].js页面中
<Link href={`/Update/${post._id}`} passHref>
<div className="ml-4 md:border-2 px-2 pb-2 md:border-yellow-300 rounded-xl cursor-pointer">
<EditFilled />
</div>
</Link>
在[更新].js页面中
export const getStaticProps = async (context) => {
const id = context.params.update;
const res = await fetch("https://dailyblog-server.herokuapp.com/posts");
const data = await res.json();
const newData = await data.find((p) => p._id === id);
return {
props: { post: newData },
revalidate: 1,
};
};
export const getStaticPaths = async () => {
const res = await fetch("https://dailyblog-server.herokuapp.com/posts");
const data = await res.json();
const paths = data.map((blog) => {
return {
params: { update: blog._id },
};
});
创建博客后我仍然无法更新我的博客......