Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Next Next commit
fix readme-components
  • Loading branch information
kellyjosephprice committed May 23, 2024
commit 077f7efbad92c2e63c70080aca79ac143f105a7e
5 changes: 4 additions & 1 deletion __tests__/transformers/readme-components.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,10 @@ describe('Readme Components Transformer', () => {
const docs = {
['rdme-callout']: {
md: `> 📘 It works!`,
mdx: `<Callout icon="📘" heading="It works!" />`,
mdx: `
<Callout icon="📘">
It works!
</Callout>`,
},
code: {
md: `
Expand Down
8 changes: 3 additions & 5 deletions processor/transform/readme-components.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,17 +78,15 @@ const coerceJsxToMd =

parent.children[index] = mdNode;
} else if (node.name === 'Callout') {
const { heading, icon } = attributes<{ heading?: string; icon: string }>(node);

const child = mdast(heading);
const { icon, empty = false } = attributes<{ empty?: boolean; icon: string }>(node);

// @ts-ignore
const mdNode: Callout = {
children: [child?.children?.[0], ...node.children].filter(Boolean) as any,
children: node.children as any,
type: NodeTypes.callout,
data: {
hName: node.name,
hProperties: { icon },
hProperties: { icon, empty },
},
position: node.position,
};
Expand Down
1 change: 1 addition & 0 deletions types.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ type Callout = Omit<Blockquote, 'type'> & {
hName: 'Callout';
hProperties: {
icon: string;
empty: boolean;
};
};
};
Expand Down