diff --git a/content/4_Silver/Prefix_Sums.mdx b/content/4_Silver/Prefix_Sums.mdx index 9d8bf50..e2f783c 100644 --- a/content/4_Silver/Prefix_Sums.mdx +++ b/content/4_Silver/Prefix_Sums.mdx @@ -4,7 +4,7 @@ title: "Prefix Sums" author: Darren Yao, Eric Wei description: "Computing range sum queries in constant time over a fixed array." prerequisites: - - Bronze - Introduction to Data Structures + - intro-ds frequency: 3 --- diff --git a/gatsby-node.ts b/gatsby-node.ts index 0f400d2..8a36b9a 100644 --- a/gatsby-node.ts +++ b/gatsby-node.ts @@ -1,4 +1,4 @@ -import { moduleIDToSectionMap, SECTIONS } from './content/ordering'; +import { SECTIONS } from './content/ordering'; exports.onCreateNode = ({ node, actions, getNode }) => { const { createNodeField } = actions; @@ -7,7 +7,7 @@ exports.onCreateNode = ({ node, actions, getNode }) => { createNodeField({ name: 'division', node, - value: moduleIDToSectionMap[node.frontmatter.id], + value: ordering.moduleIDToSectionMap[node.frontmatter.id], }); } }; diff --git a/src/components/ModuleLayout/ModuleLayout.tsx b/src/components/ModuleLayout/ModuleLayout.tsx index b520b53..58f2313 100644 --- a/src/components/ModuleLayout/ModuleLayout.tsx +++ b/src/components/ModuleLayout/ModuleLayout.tsx @@ -248,6 +248,19 @@ const NavBar = ({ alignNavButtonsRight = true }) => { ); }; +const renderPrerequisite = (prerequisite, moduleLinks: ModuleLinkInfo[]) => { + let moduleLink = moduleLinks.find(x => x.id === prerequisite); + if (moduleLink) + return ( +
  • + + {SECTION_LABELS[moduleLink.division]} - {moduleLink.title} + +
  • + ); + return
  • {prerequisite}
  • ; +}; + export default function ModuleLayout({ module, children, @@ -447,6 +460,39 @@ export default function ModuleLayout({ + + {module.prerequisites && ( +
    +
    +
    + + + +
    +
    +

    + Prerequisites +

    +
    +
      + {module.prerequisites.map(x => + renderPrerequisite(x, moduleLinks) + )} +
    +
    +
    +
    +
    + )} + {children}

    diff --git a/src/components/markdown/MDXProvider.tsx b/src/components/markdown/MDXProvider.tsx index a9b6ce0..fba1f6d 100644 --- a/src/components/markdown/MDXProvider.tsx +++ b/src/components/markdown/MDXProvider.tsx @@ -25,7 +25,7 @@ const components = { children: React.ReactNode; title: string; }) => ( -
    +
    { - return
  • {prerequisite}
  • ; -}; - export default function Template(props) { const { mdx } = props.data; // data.markdownRemark holds your post data const { body } = mdx; const module = React.useMemo(() => graphqlToModuleInfo(mdx), [mdx]); const division = module.division; - const prereqs = mdx.frontmatter.prerequisites; - return (
    - {prereqs && ( -
    -
    -
    - - - -
    -
    -

    - Prerequisites -

    -
    -
      - {prereqs.map(renderPrerequisite)} -
    -
    -
    -
    -
    - )} - {module.description && (

    {module.description}