Skip to content

Commit

Permalink
feat(remix-dev): set handle from frontmatter in MDX files
Browse files Browse the repository at this point in the history
Fixes #4864.
  • Loading branch information
lpsinger authored and MichaelDeBoey committed Jan 4, 2023
1 parent 2c398e4 commit 8c8a94e
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
9 changes: 4 additions & 5 deletions docs/guides/mdx.md
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ You can reference your frontmatter data through "attributes". The title of this

### Advanced Example

You can even export all the other things in this module that you can in regular route modules in your mdx files like `loader` and `action`:
You can even export all the other things in this module that you can in regular route modules in your mdx files like `loader`, `action`, and `handle`:

```mdx
---
Expand All @@ -77,6 +77,9 @@ meta:

headers:
Cache-Control: no-cache

handle:
someData: abc
---

import styles from "./first-post.css";
Expand All @@ -85,10 +88,6 @@ export const links = () => [
{ rel: "stylesheet", href: styles },
];

export const handle = {
someData: "abc",
};

import { json } from "@remix-run/node";
import { useLoaderData } from "@remix-run/react";

Expand Down
1 change: 1 addition & 0 deletions packages/remix-dev/compiler/plugins/mdx.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ export function mdxPlugin(config: RemixConfig): esbuild.Plugin {
export const filename = ${JSON.stringify(path.basename(args.path))};
export const headers = typeof attributes !== "undefined" && attributes.headers;
export const meta = typeof attributes !== "undefined" && attributes.meta;
export const handle = typeof attributes !== "undefined" && attributes.handle;
`;

let compiled = await xdm.compile(fileContents, {
Expand Down

0 comments on commit 8c8a94e

Please sign in to comment.