Skip to content

Commit

Permalink
chore(mdx): add a comment to explain the hard coded attributes
Browse files Browse the repository at this point in the history
  • Loading branch information
ArmandPhilippot committed Apr 18, 2024
1 parent 00d093c commit 0a8e8f2
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions packages/integrations/mdx/src/rehype-images-to-component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,11 @@ function getImageComponentAttributes(props: Properties): MdxJsxAttribute[] {
for (const [prop, value] of Object.entries(props)) {
if (prop === 'src') continue;

/*
* <Image /> component expects an array for those attributes but the
* received properties are sanitized as strings. So we need to convert them
* back to an array.
*/
if (prop === 'widths' || prop === 'densities') {
attrs.push(createArrayAttribute(prop, String(value).split(' ')));
} else {
Expand Down

0 comments on commit 0a8e8f2

Please sign in to comment.