fix(website): migrate blog from next-mdx-remote to @next/mdx
next-mdx-remote evaluates MDX at runtime with a different React version than Next.js 16's internal canary, causing build failures. Switch to @next/mdx which compiles MDX through Next.js's own bundler pipeline. - Replace next-mdx-remote with @next/mdx, @mdx-js/mdx, @mdx-js/loader - Use dynamic imports for blog MDX files instead of MDXRemote - Add remark-frontmatter so compiler skips YAML frontmatter blocks - Gate cache/CSP headers to production only (immutable dev chunks were poisoning browser cache) Made-with: Cursor
This commit is contained in:
@@ -1,5 +1,10 @@
|
||||
import createMDX from "@next/mdx";
|
||||
|
||||
const isProd = process.env.NODE_ENV === "production";
|
||||
|
||||
/** @type {import('next').NextConfig} */
|
||||
const nextConfig = {
|
||||
pageExtensions: ["ts", "tsx", "md", "mdx"],
|
||||
allowedDevOrigins: ["*.ngrok-free.dev"],
|
||||
experimental: {
|
||||
optimizePackageImports: ["framer-motion", "motion", "gsap", "@gsap/react"],
|
||||
@@ -11,10 +16,9 @@ const nextConfig = {
|
||||
// formats: ["image/avif", "image/webp"],
|
||||
},
|
||||
async headers() {
|
||||
if (!isProd) return [];
|
||||
|
||||
return [
|
||||
// Next.js chunks include a content hash in their filename, so they are
|
||||
// safe to cache indefinitely. Vercel sets this automatically on its CDN,
|
||||
// but the explicit header also covers self-hosted deployments.
|
||||
{
|
||||
source: "/_next/static/(.*)",
|
||||
headers: [
|
||||
@@ -24,8 +28,6 @@ const nextConfig = {
|
||||
},
|
||||
],
|
||||
},
|
||||
// Lottie JSON files are large (1.4–2.6 MB each) and change infrequently.
|
||||
// A 1-year cache means repeat visitors skip the expensive re-download.
|
||||
{
|
||||
source: "/animation/(.*)",
|
||||
headers: [
|
||||
@@ -35,8 +37,6 @@ const nextConfig = {
|
||||
},
|
||||
],
|
||||
},
|
||||
// Public images: 7-day TTL with a 1-day stale-while-revalidate window
|
||||
// so content updates eventually propagate without blocking visitors.
|
||||
{
|
||||
source: "/images/(.*)",
|
||||
headers: [
|
||||
@@ -76,4 +76,10 @@ const nextConfig = {
|
||||
},
|
||||
};
|
||||
|
||||
export default nextConfig;
|
||||
const withMDX = createMDX({
|
||||
options: {
|
||||
remarkPlugins: ["remark-frontmatter"],
|
||||
},
|
||||
});
|
||||
|
||||
export default withMDX(nextConfig);
|
||||
|
||||
Reference in New Issue
Block a user