Skip to content

Commit ac59286

Browse files
Merge branch 'next'
2 parents 8933fb2 + 352fb99 commit ac59286

File tree

11 files changed

+175
-37
lines changed

11 files changed

+175
-37
lines changed

.github/workflows/bundlewatch.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ jobs:
88
if: "!contains(github.event.head_commit.message, 'SKIP CI')"
99
steps:
1010
- uses: actions/checkout@v5
11-
- uses: actions/setup-node@v4
11+
- uses: actions/setup-node@v6
1212
with:
1313
node-version: 20.x
1414

.github/workflows/ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ jobs:
1616
- uses: actions/checkout@v5
1717

1818
- name: Use Node.js ${{ matrix.node-version }}
19-
uses: actions/setup-node@v4
19+
uses: actions/setup-node@v6
2020
with:
2121
node-version: ${{ matrix.node-version }}
2222

.github/workflows/release.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ jobs:
1818
persist-credentials: false # install breaks with persistant creds!
1919

2020
- name: Setup node
21-
uses: actions/setup-node@v4
21+
uses: actions/setup-node@v6
2222
with:
2323
node-version: 20
2424

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
import { migrate } from '../helpers';
2+
3+
describe('mdx migration of recipes', () => {
4+
it('compiles recipes correctly', () => {
5+
const md = `
6+
In a callout:
7+
8+
> 🚀 Launch Example Code:
9+
>
10+
> [block:tutorial-tile]{"backgroundColor":"#0b1c36","emoji":"👉","id":"67d85229d1ac0900248b3111","link":"https://developer.moneygram.com/v1.0/recipes/amend-modify-receviers-name-headers","slug":"amend-modify-receviers-name-headers","title":"Amend - Modify Recevier's Name - Headers"}[/block]
11+
12+
Or on a line by itself:
13+
14+
[block:tutorial-tile]
15+
{
16+
"backgroundColor":"#0b1c36",
17+
"emoji":"👉",
18+
"id":"67d85229d1ac0900248b3111",
19+
"link":"https://developer.moneygram.com/v1.0/recipes/amend-modify-receviers-name-headers",
20+
"slug":"amend-modify-receviers-name-headers",
21+
"title":"Amend - Modify Recevier's Name - Headers"
22+
}
23+
[/block]
24+
`;
25+
26+
const mdx = migrate(md);
27+
expect(mdx).toMatchInlineSnapshot(`
28+
"In a callout:
29+
30+
<Callout icon="🚀" theme="default">
31+
### Launch Example Code:
32+
33+
<Recipe slug="amend-modify-receviers-name-headers" title="Amend - Modify Recevier's Name - Headers" />
34+
</Callout>
35+
36+
Or on a line by itself:
37+
38+
<Recipe slug="amend-modify-receviers-name-headers" title="Amend - Modify Recevier's Name - Headers" />
39+
"
40+
`);
41+
});
42+
});

components/MCPIntro/index.tsx

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
import React from 'react';
2+
3+
// We render a placeholder in this library, as the actual implemenation is
4+
// deeply tied to the main app
5+
const MCPIntro = () => {
6+
const style = {
7+
height: '200px',
8+
border: '1px solid var(--color-border-default, rgba(black, 0.1))',
9+
borderRadius: 'var(--border-radius-lg, 7.5px)',
10+
display: 'flex',
11+
flexDirection: 'column' as const,
12+
padding: '20px',
13+
gap: '15px',
14+
};
15+
16+
const placeholderStyle = {
17+
borderRadius: 'var(--border-radius-md, 5px)',
18+
backgroundColor: 'var(--color-skeleton, #384248)',
19+
};
20+
21+
const headerStyle = {
22+
...placeholderStyle,
23+
height: '24px',
24+
width: '200px',
25+
};
26+
27+
const lineStyle = {
28+
...placeholderStyle,
29+
height: '12px',
30+
width: '100%',
31+
};
32+
33+
return (
34+
<div className="MCPIntro" style={style}>
35+
<div style={headerStyle} />
36+
<div style={{ ...lineStyle, width: '90%' }} />
37+
<div style={{ ...lineStyle, width: '95%' }} />
38+
<div style={{ ...lineStyle, width: '85%' }} />
39+
<div style={{ ...lineStyle, width: '92%' }} />
40+
<div style={{ ...lineStyle, width: '88%' }} />
41+
</div>
42+
);
43+
};
44+
45+
export default MCPIntro;

components/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ export { default as Glossary } from './Glossary';
1010
export { default as HTMLBlock } from './HTMLBlock';
1111
export { default as Heading } from './Heading';
1212
export { default as Image } from './Image';
13+
export { default as MCPIntro } from './MCPIntro';
1314
export { default as Table } from './Table';
1415
export { default as TableOfContents } from './TableOfContents';
1516
export { default as Tabs, Tab } from './Tabs';

lib/compile.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,12 @@ import remarkGfm from 'remark-gfm';
1010

1111
import MdxSyntaxError from '../errors/mdx-syntax-error';
1212
import { rehypeToc } from '../processor/plugin/toc';
13-
import { defaultTransforms, tailwindTransformer, handleMissingComponents } from '../processor/transform';
13+
import {
14+
defaultTransforms,
15+
tailwindTransformer,
16+
handleMissingComponents,
17+
validateMCPIntro,
18+
} from '../processor/transform';
1419

1520
import { rehypePlugins as defaultRehypePlugins } from './ast-processor';
1621

@@ -40,6 +45,7 @@ const compile = (
4045
handleMissingComponents,
4146
{ components, missingComponents: ['ignore', 'throw'].includes(missingComponents) ? missingComponents : 'ignore' },
4247
],
48+
[validateMCPIntro],
4349
];
4450

4551
if (useTailwind) {

package-lock.json

Lines changed: 37 additions & 33 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

processor/transform/index.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import readmeComponentsTransformer from './readme-components';
1313
import readmeToMdx from './readme-to-mdx';
1414
import tablesToJsx from './tables-to-jsx';
1515
import tailwindTransformer from './tailwind';
16+
import validateMCPIntro from './validate-mcpintro';
1617
import variablesTransformer from './variables';
1718

1819
export {
@@ -26,6 +27,7 @@ export {
2627
tablesToJsx,
2728
tailwindTransformer,
2829
handleMissingComponents,
30+
validateMCPIntro,
2931
variablesTransformer,
3032
};
3133

processor/transform/readme-to-mdx.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ const readmeToMdx = (): Transform => tree => {
5252
});
5353

5454
// Converts tutorial tiles to Recipe components in the migration process
55+
// Retaining this for backwards compatibility
5556
visit(tree, NodeTypes.tutorialTile, (tile, index, parent: Parent) => {
5657
const { ...attrs } = tile as Recipe;
5758

@@ -63,6 +64,17 @@ const readmeToMdx = (): Transform => tree => {
6364
});
6465
});
6566

67+
visit(tree, NodeTypes.recipe, (tile, index, parent: Parent) => {
68+
const { ...attrs } = tile as Recipe;
69+
70+
parent.children.splice(index, 1, {
71+
type: 'mdxJsxFlowElement',
72+
name: 'Recipe',
73+
attributes: toAttributes(attrs, ['slug', 'title']),
74+
children: [],
75+
});
76+
});
77+
6678
visit(tree, 'figure', (figure, index, parent) => {
6779
const [image, caption] = figure.children;
6880

0 commit comments

Comments
 (0)