Loading MDX using static files
Unanswered
Blanc de Hotot posted this in #help-forum
Blanc de HototOP
Hello fam again!!! I've noticed that MDX pages take a second to load assuming because of the compiler, so the UI isn't immediately responsive when navigating to a static MDX page. I've tried wrapping the content in a Suspense but since the page.mdx file doesn't actually have any async content, the Suspense never triggers.(Using Next 13+)
import Loading from "@/ui/loading";
import { ScrollArea } from "@/ui/shadcn/scrollarea";
import { Suspense } from "react";
export default async function MdxLayout({ children }: { children: React.ReactNode }) {
return (
<Suspense fallback={<Loading />}>
<ScrollArea
className={`w-full flex flex-col items-center justify-center max-h-[calc(100vh-4.5rem)] my-4 px-4 pt-8 pb-0`}
>
<div className="prose dark:prose-invert max-w-prose mx-auto pb-20">
{children}
</div>
</ScrollArea>
</Suspense>
);
}Any ideas on getting the loading state to trigger?
7 Replies
Blanc de HototOP
MDX help would be appreciated!
@Blanc de Hotot MDX help would be appreciated!
Sweat bee
have you figured this out?
Boerboel
Try using generateStaticParams, you can build any dynamic routes in your case the slug for all your blogs, you can generate it static in build so it comes in instantly
@Sweat bee have you figured this out?
Blanc de HototOP
unfortunately no, but praz's response seems promising
Sweat bee
thanks. will try
Boerboel
^ this works, it builds the page in build time so it caches everything