import React from 'react'; import PropTypes from 'prop-types'; import { Link, graphql } from 'gatsby'; import Helmet from 'react-helmet'; import { ListGroup, ListGroupItem } from '@freecodecamp/react-bootstrap'; import LearnLayout from '../../components/layouts/Learn'; import FullWidthRow from '../../components/helpers/FullWidthRow'; import ButtonSpacer from '../../components/helpers/ButtonSpacer'; import { MarkdownRemark, AllChallengeNode } from '../../redux/propTypes'; import './intro.css'; const propTypes = { data: PropTypes.shape({ markdownRemark: MarkdownRemark, allChallengeNode: AllChallengeNode }) }; function renderMenuItems({ edges = [] }) { return edges .map(({ node }) => node) .map(({ title, fields: { slug } }) => ( {title} )); } function IntroductionPage({ data: { markdownRemark, allChallengeNode } }) { const { html, frontmatter: { block } } = markdownRemark; const firstLesson = allChallengeNode && allChallengeNode.edges[0].node; const firstLessonPath = firstLesson ? firstLesson.fields.slug : '/strange-place'; return ( {block} | freeCodeCamp.org
Go to the first lesson View the curriculum

Upcoming Lessons

{allChallengeNode ? renderMenuItems(allChallengeNode) : null}
); } IntroductionPage.displayName = 'IntroductionPage'; IntroductionPage.propTypes = propTypes; export default IntroductionPage; export const query = graphql` query IntroPageBySlug($slug: String!, $block: String!) { markdownRemark(fields: { slug: { eq: $slug } }) { frontmatter { block } html } allChallengeNode( filter: { block: { eq: $block } } sort: { fields: [superOrder, order, challengeOrder] } ) { edges { node { fields { slug } title } } } } `;