1

I have updateblog button my dynamically routed [detail].js page for individual blogs.

In [detail].js page

<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>

In [update].js page

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 },
    };
  });

Still I am not able to update my blog after creating it.

juliomalves
  • 42,130
  • 20
  • 150
  • 146
Akash
  • 21
  • 3
  • Does this answer your question: [How to add new pages without rebuilding an app with +150k static pages?](https://stackoverflow.com/a/66037031/1870780)? You have to return `fallback: 'blocking'` in `getStaticPaths`. – juliomalves Mar 02 '22 at 13:05

0 Answers0