my blog https://overreacted.io

Simpler

Changed files
+11 -25
app
[slug]
patches
+11
app/[slug]/page.js
··· 12 12 13 13 export default async function PostPage({ params }) { 14 14 const file = await readFile("./public/" + params.slug + "/index.md", "utf8"); 15 + let postComponents = {}; 16 + try { 17 + postComponents = await import( 18 + "../../public/" + params.slug + "/components.js" 19 + ); 20 + } catch (e) { 21 + if (!e || e.code !== "MODULE_NOT_FOUND") { 22 + throw e; 23 + } 24 + } 15 25 const { content, data } = matter(file); 16 26 const discussUrl = `https://x.com/search?q=${encodeURIComponent( 17 27 `https://overreacted.io/${params.slug}/`, ··· 44 54 a: Link, 45 55 Server: Server, 46 56 Client: Client, 57 + ...postComponents, 47 58 }} 48 59 options={{ 49 60 mdxOptions: {
-25
patches/next-mdx-remote+4.4.1.patch
··· 1 - diff --git a/node_modules/next-mdx-remote/dist/rsc.js b/node_modules/next-mdx-remote/dist/rsc.js 2 - index 8ab7d78..a75b600 100644 3 - --- a/node_modules/next-mdx-remote/dist/rsc.js 4 - +++ b/node_modules/next-mdx-remote/dist/rsc.js 5 - @@ -2701,6 +2701,8 @@ async function serialize(source, { scope = {}, mdxOptions = {}, parseFrontmatter 6 - }; 7 - } 8 - 9 - +import Module from "node:module"; 10 - + 11 - /** 12 - * Copyright (c) HashiCorp, Inc. 13 - * SPDX-License-Identifier: MPL-2.0 14 - @@ -2722,8 +2724,9 @@ async function compileMDX({ source, options, components = {}, }) { 15 - // and all our components in scope for the function, which is the case here 16 - // we pass the names (via keys) in as the function's args, and execute the 17 - // function with the actual values. 18 - - const hydrateFn = Reflect.construct(Function, keys.concat(`${compiledSource}`)); 19 - - const Content = hydrateFn.apply(hydrateFn, values).default; 20 - + const AsyncFunction = Object.getPrototypeOf(async function() { }).constructor; 21 - + const hydrateFn = AsyncFunction(...keys.concat(`${compiledSource}`)); 22 - + const Content = (await hydrateFn.apply(hydrateFn, values)).default; 23 - return { 24 - content: React.createElement(Content, { components: components }), 25 - frontmatter,