Skip to content

Commit

Permalink
feat(mdx): support exporting links function (#3801)
Browse files Browse the repository at this point in the history
  • Loading branch information
kentcdodds committed Jul 19, 2022
1 parent 9c4bbe8 commit 78a8dcc
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 2 deletions.
5 changes: 5 additions & 0 deletions .changeset/neat-nymphs.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@remix-run/dev": patch
---

support exporting links in mdx files
1 change: 1 addition & 0 deletions contributors.yml
Original file line number Diff line number Diff line change
Expand Up @@ -394,3 +394,4 @@
- zhe
- garand
- kiancross
- tagraves
6 changes: 6 additions & 0 deletions docs/guides/mdx.md
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,12 @@ headers:
Cache-Control: no-cache
---

import styles from "./first-post.css";

export const links = () => [
{ rel: "stylesheet", href: styles },
];

export const handle = {
someData: "abc",
};
Expand Down
9 changes: 8 additions & 1 deletion integration/mdx-test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,10 @@ headers:
Cache-Control: no-cache
---
export const links = () => [
{ rel: "stylesheet", href: "app.css" }
]
export const handle = {
someData: "abc"
}
Expand Down Expand Up @@ -101,7 +105,9 @@ export function ComponentUsingData() {
expect(await app.getHtml()).toMatch("This is some basic markdown!");
});

test("supports meta, headers, handle, and loader", async ({ page }) => {
test("supports links, meta, headers, handle, and loader", async ({
page,
}) => {
let app = new PlaywrightFixture(appFixture, page);
await app.goto("/blog/post");
expect(await app.getHtml('meta[name="description"]')).toMatch(
Expand All @@ -110,5 +116,6 @@ export function ComponentUsingData() {
expect(await app.getHtml("title")).toMatch("My First Post");
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");
});
});
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 @@ -71,7 +71,6 @@ 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 links = undefined;
`;

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

0 comments on commit 78a8dcc

Please sign in to comment.