import BuildInfo from '@/components/BuildInfo/BuildInfo';
import NavLink from '@/components/NavLink/NavLink';
import { api } from '@/utils/api';
import Doc from './doc.mdx';
import RevalidateButton from '@/components/RevalidateButton/RevalidateButon';

export const metadata = {
  title: 'Dynamic revalidate page',
};

const PostPage = async () => {
  const [post] = await api.post('99');
  const [image] = await api.images();

  return (
    <div className="blog">
      <Doc />
      <article>
        <BuildInfo />
        <RevalidateButton />
        <h2>{post.title}</h2>
        <p>{post.body}</p>
        <div className="grid">
          <img src={image} alt="dog" width={400} />
        </div>
        <NavLink href={`/users/${post.userId}`} className={'secondary'}>
          Author Page
        </NavLink>
      </article>
    </div>
  );
};

export default PostPage;
import { NextResponse } from 'next/server';
import { revalidatePath } from 'next/cache';

import type { NextRequest } from 'next/server';

export async function GET(request: NextRequest) {
  const path = request.nextUrl.searchParams.get('path') || '/';

  revalidatePath(path);

  return NextResponse.json({ revalidated: true, now: Date.now() });
}

temporibus sit alias delectus eligendi possimus magni

quo deleniti praesentium dicta non quod aut est molestias molestias et officia quis nihil itaque dolorem quia

dog
Author Page