diff --git a/src/components/TutorialSection.js b/src/components/TutorialSection.js index edde5d8b8..18bf09ed6 100644 --- a/src/components/TutorialSection.js +++ b/src/components/TutorialSection.js @@ -1,8 +1,14 @@ -import React from 'react'; +import React, { Children, cloneElement } from 'react'; import PropTypes from 'prop-types'; import { css } from '@emotion/core'; +import { isMdxType } from '../utils/mdx'; const TutorialSection = ({ children }) => { + const totalSteps = Children.toArray(children).filter((child) => + isMdxType(child, 'TutorialStep') + ).length; + let step = 1; + return (
{ } `} > - {children} + {Children.map(children, (child) => { + if (isMdxType(child, 'TutorialStep')) { + return cloneElement(child, { stepNumber: step++, totalSteps }); + } + + return child; + })}
); };