Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(mdx): remove overriding of the loader #3800

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .changeset/tender-impalas-invite.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@
"@remix-run/dev": patch
---

Adds support for handle, links, and loader to mdx routes
Adds support for `handle` and `links` to mdx routes
46 changes: 30 additions & 16 deletions integration/mdx-test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,24 +54,38 @@ test.describe("mdx", () => {
`,

"app/routes/blog/post.mdx": mdx`---
meta:
title: My First Post
description: Isn't this awesome?
headers:
Cache-Control: no-cache
links: [
{ rel: "stylesheet", href: "app.css" }
]
handle:
someData: "abc"
additionalData: 10
meta:
title: My First Post
description: Isn't this awesome?
headers:
Cache-Control: no-cache
links: [
{ rel: "stylesheet", href: "app.css" }
]
handle:
someData: "abc"
---
# This is some markdown!
`,

import { useLoaderData } from '@remix-run/react';

export const loader = async () => {
return { mamboNumber: 5 };
};

export function ComponentUsingData() {
const { mamboNumber } = useLoaderData();

return <div id="loader">Mambo Number: {mamboNumber}</div>;
}

# This is some markdown!

<ComponentUsingData />
`.trim(),

"app/routes/basic.mdx": mdx`
# This is some basic markdown!
`,
# This is some basic markdown!
`.trim(),
},
});
appFixture = await createAppFixture(fixture);
Expand All @@ -97,7 +111,7 @@ test.describe("mdx", () => {
"Isn't this awesome?"
);
expect(await app.getHtml("title")).toMatch("My First Post");
expect(await app.getHtml("#additionalData")).toMatch("Additional Data: 10");
expect(await app.getHtml("#loader")).toMatch(/Mambo Number:.+5/s);
expect(await app.getHtml("#handle")).toMatch("abc");
expect(await app.getHtml('link[rel="stylesheet"]')).toMatch("app.css");
});
Expand Down
1 change: 0 additions & 1 deletion packages/remix-dev/compiler/plugins/mdx.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,6 @@ export const headers = typeof attributes !== "undefined" && attributes.headers;
export const meta = typeof attributes !== "undefined" && attributes.meta;
export const handle = typeof attributes !== "undefined" && attributes.handle;
export const links = typeof attributes === "undefined" ? undefined : () => attributes.links;
export const loader = typeof attributes === "undefined" ? undefined : () => attributes;
`;

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