Skip to content

Commit 697a9f4

Browse files
refactor: consolidate 0-slots handling to rely on markdown
1 parent f870bab commit 697a9f4

1 file changed

Lines changed: 6 additions & 12 deletions

File tree

src/steps/mdx-to-gridtables.ts

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -72,28 +72,22 @@ export default function mdxToBlocks(ctx: Helix.UniversalContext) {
7272
continue;
7373
}
7474

75-
const isHorizontalLine = node.name === 'HorizontalLine';
76-
77-
// These components does not a fallback repeat
78-
const isDefaultNode = node.name === 'Fragment' || node.name === 'iframe';
79-
8075
// get slots
8176
const slotsAttr = getAttribute(node, 'slots');
82-
const slotsValue = getAttributeValue(slotsAttr, '');
77+
const slotsValue = getAttributeValue(slotsAttr, null);
8378
// if (!slotsValue) {
8479
// // TODO: throw error for invalid document
8580
// break;
8681
// }
87-
const slots = isHorizontalLine
88-
? []
89-
: slotsValue
90-
.split(',')
82+
const slots = slotsValue
83+
? slotsValue.split(',')
9184
.map((slot) => slot.trim())
92-
.filter((slot) => slot.length > 0);
85+
.filter((slot) => slot.length > 0)
86+
: [];
9387

9488
// repeat the block N times if repeat="N" is set
9589
const repeatAttr = getAttribute(node, 'repeat');
96-
const repeat = isDefaultNode ? 0 : parseInt(getAttributeValue(repeatAttr, '1'), 10);
90+
const repeat = parseInt(getAttributeValue(repeatAttr, '1'), 10);
9791

9892
// get variants as string
9993
const variantAttr = getAttribute(node, 'variant');

0 commit comments

Comments
 (0)