Skip to content

Commit

Permalink
review fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
jennspencer committed May 18, 2024
1 parent d3a153f commit 78666d9
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 17 deletions.
1 change: 0 additions & 1 deletion __tests__/components/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,6 @@ describe('Components', () => {
Object.values(fixtures).map(async fx => {
const component = await run(compile(fx));
const { container } = render(React.createElement(component));
console.log(container.innerHTML);
return expect(container.innerHTML).toMatchSnapshot();
});
});
Expand Down
2 changes: 1 addition & 1 deletion enums.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
export enum NodeTypes {
callout = 'callout',
callout = 'rdme-callout',
codeTabs = 'code-tabs',
emoji = 'emoji',
i = 'i',
Expand Down
26 changes: 11 additions & 15 deletions processor/transform/embeds.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,21 +5,17 @@ import { NodeTypes } from '../../enums';
const embedTransformer = () => {
return (tree: any) => {
visit(tree, 'link', (node, _, parent) => {
try {
if (parent.children.length > 1 || node.title !== '@embed') return;
const newNode = {
type: NodeTypes.embed,
data: {
hProperties: { title: node.children[0]?.value ?? node.url, url: node.url, provider: node.url },
hName: 'Embed',
},
position: node.position,
children: [],
};
parent = newNode;
} catch (e) {
console.log(e);
}
if (parent.type !== 'paragraph' || parent.children.length > 1 || node.title !== '@embed') return;
const newNode = {
type: NodeTypes.embed,
data: {
hProperties: { title: node.children[0]?.value ?? node.url, url: node.url, provider: node.url },
hName: 'Embed',
},
position: node.position,
children: [],
};
parent = newNode;
});
};
};
Expand Down
1 change: 1 addition & 0 deletions types.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ declare module 'mdast' {
interface RootContentMap {
[NodeTypes.callout]: Callout;
[NodeTypes.codeTabs]: CodeTabs;
[NodeTypes.embed]: Embed;
[NodeTypes.emoji]: Gemoji;
[NodeTypes.i]: FaEmoji;
}
Expand Down

0 comments on commit 78666d9

Please sign in to comment.