Skip to content

Commit d87864e

Browse files
committed
fix(plugin): set correct position of nodes
1 parent c054a8f commit d87864e

File tree

2 files changed

+28
-8
lines changed

2 files changed

+28
-8
lines changed

example/src/woly/atoms/button/usage.mdx

Lines changed: 23 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,22 @@ const Example = () => (
2323
);
2424
```
2525

26+
First
27+
28+
<Frame>
29+
<New />
30+
<button.Base />
31+
</Frame>
32+
33+
Second
34+
35+
<Frame>
36+
<New />
37+
<button.Base />
38+
</Frame>
39+
40+
Third
41+
2642
<Frame>
2743
<New />
2844
<button.Base />
@@ -39,10 +55,10 @@ const Example = () => (
3955

4056
### Props
4157

42-
| Name | Type | Default | Description |
43-
| ------- | ------------------------------- | ---------- | ---------------------------------------------------------- |
44-
| `text` | `React.ReactNode` | | Text appeared on the button |
45-
| `left` | `React.ReactNode` | `null` | Component to show on the left side of the text (ex.: Icon) |
46-
| `right` | `React.ReactNode` | `null` | Component on the right side of the text |
47-
| `type` | `'button' | 'submit' | 'reset'` | `'button'` | HTML type of the button |
48-
| `...` | `HTMLButtonElementProps` | `{}` | Other props is inherited from `HTMLButtonElement` |
58+
| Name | Type | Default | Description |
59+
| ------- | ------------------------ | -------- | ---------------------------------------------------------- | ---------- | ----------------------- |
60+
| `text` | `React.ReactNode` | | Text appeared on the button |
61+
| `left` | `React.ReactNode` | `null` | Component to show on the left side of the text (ex.: Icon) |
62+
| `right` | `React.ReactNode` | `null` | Component on the right side of the text |
63+
| `type` | `'button' | 'submit' | 'reset'` | `'button'` | HTML type of the button |
64+
| `...` | `HTMLButtonElementProps` | `{}` | Other props is inherited from `HTMLButtonElement` |

gatsby-theme-woly/plugins/remark-plugin.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,12 @@ module.exports = (options) => {
1919
});
2020
});
2121

22+
// When new element added to AST list, other elements is moved down
23+
// Absolute index of each element in `codes` has incorrect `at` position
24+
let shift = 0;
2225
codes.forEach(({ at, node, parent }) => {
23-
parent.children.splice(at + 1, 0, node);
26+
parent.children.splice(at + 1 + shift, 0, node);
27+
shift++;
2428
});
2529

2630
delete codes;

0 commit comments

Comments
 (0)