-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
404 site nav and page head component
- Loading branch information
Showing
11 changed files
with
191 additions
and
43 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
10 changes: 0 additions & 10 deletions
10
site/content/exercises/en-US/circuitpython/robotics/index-summary.mdx
This file was deleted.
Oops, something went wrong.
12 changes: 7 additions & 5 deletions
12
site/content/exercises/en-US/circuitpython/robotics/index.mdx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,14 @@ | ||
--- | ||
order: 1 | ||
title: CircuitPython | ||
title: Robotics with CircuitPython | ||
--- | ||
|
||
![Mu Blink](../../images/circuitpython/mu.png) | ||
import Setup from '../setup.mdx'; | ||
|
||
## Introduction to CircuitPython - Level 1 | ||
## Intro to Robotics with CircuitPython | ||
|
||
This is the original single day workshop with Circuit Playground Express and CircuitPython. Includes an overview of the board's sensors and lights through code. Allows students to dig into an aspect of the device they enjoy for an afternoon of exploration. | ||
Our curriculum for robotics with CircuitPython. | ||
|
||
[Go to exercises](/exercises/en-US/circuitpython/level-1/) | ||
### [Microcontroller Setup Instructions](http://opensource.morganstanley.com/cpx-training/exercises/en-US/circuitpython/setup_bluefruit/) | ||
|
||
<Setup /> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
--- | ||
order: 1 | ||
title: Overview of Programs | ||
--- | ||
|
||
## Languages | ||
|
||
Component that outputs all available languages. | ||
|
||
## Overview of Programs and technologies | ||
|
||
[CircuitPython](/exercises/en-US/circuitpython) | ||
|
||
[MakeCode](/exercises/en-US/makecode) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import React from 'react'; | ||
|
||
function PageHead({ title, children }) { | ||
return ( | ||
<> | ||
<title>{title} | Makerspace</title> | ||
{children} | ||
</> | ||
); | ||
} | ||
|
||
export default PageHead; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,101 @@ | ||
import React from 'react'; | ||
import { Link } from 'gatsby'; | ||
|
||
function getCategories(nodes) { | ||
const potentialValues = []; | ||
nodes.forEach((node) => { | ||
const cat = node.frontmatter.category; | ||
if (typeof cat !== 'undefined' && !potentialValues.includes(cat)) { | ||
potentialValues.push(cat); | ||
} | ||
}); | ||
return potentialValues; | ||
} | ||
|
||
function getLevels(nodes) { | ||
const potentialValues = []; | ||
nodes.forEach((node) => { | ||
const level = node.frontmatter.level; | ||
if (typeof level !== 'undefined' && !potentialValues.includes(level)) { | ||
potentialValues.push(level); | ||
} | ||
}); | ||
return potentialValues; | ||
} | ||
|
||
const PageListItems = ({ location, nodes }) => { | ||
return nodes.map((node, i) => { | ||
const title = node.frontmatter.title; | ||
const exercise = node.frontmatter.exercise; | ||
const toc = node.tableOfContents.items; | ||
return ( | ||
<li key={`exercise-${i}`}> | ||
<Link to={node.fields.slug}> | ||
{exercise ? `${exercise} ) ` : ''} | ||
{title} | ||
</Link> | ||
<nav className="nav exercise-content-nav"> | ||
<ul> | ||
{toc && | ||
toc.map((item, j) => ( | ||
<li key={`toc-${j}`}> | ||
<Link to={item.url}>{item.title}</Link> | ||
</li> | ||
))} | ||
</ul> | ||
</nav> | ||
</li> | ||
); | ||
}); | ||
}; | ||
|
||
const PagesByLevel = ({ levels, location, nodes }) => ( | ||
<nav className="nav exercise-nav"> | ||
{levels.map((level, i) => { | ||
const currentLevelNodes = nodes.filter( | ||
(node) => node.frontmatter.level === level | ||
); | ||
return ( | ||
<div key={`level-${i}`}> | ||
{levels.length > 1 && <h3>Level {level}</h3>} | ||
<ul> | ||
<PageListItems location={location} nodes={currentLevelNodes} /> | ||
</ul> | ||
</div> | ||
); | ||
})} | ||
</nav> | ||
); | ||
|
||
const PagesByCategory = ({ categories, location, nodes }) => { | ||
return categories.map((category, i) => { | ||
const currentCategoryNodes = nodes.filter( | ||
(node) => node.frontmatter.category === category | ||
); | ||
const levels = getLevels(currentCategoryNodes); | ||
return ( | ||
<> | ||
{category !== null && <h2>{category}</h2>} | ||
<PagesByLevel | ||
levels={levels} | ||
location={location} | ||
nodes={currentCategoryNodes} | ||
/> | ||
</> | ||
); | ||
}); | ||
}; | ||
|
||
const SiteMap = ({ location, nodes }) => { | ||
const categories = getCategories(nodes); | ||
|
||
return ( | ||
<PagesByCategory | ||
categories={categories} | ||
location={location} | ||
nodes={nodes} | ||
/> | ||
); | ||
}; | ||
|
||
export default SiteMap; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,26 +1,55 @@ | ||
import React from 'react'; | ||
import { graphql } from 'gatsby'; | ||
import { Link, graphql } from 'gatsby'; | ||
|
||
import Layout from '../components/layout'; | ||
import PageHead from '../components/head'; | ||
import SiteMap from '../components/site-map'; | ||
|
||
import { siteFragment } from '../fragments/site'; | ||
|
||
const NotFoundPage = ({ location }) => { | ||
const NotFoundPage = ({ data, location }) => { | ||
const nodes = data.allMdx.nodes; | ||
|
||
return ( | ||
<Layout location={location}> | ||
<h1>Not Found</h1> | ||
<p>You just hit a route that doesn't exist... the sadness.</p> | ||
<div className="content"> | ||
<h2>404 Not Found</h2> | ||
<p> | ||
Sorry, the url you're looking for appears to be missing. Check out the | ||
sitemap below to find your expected page. | ||
</p> | ||
<SiteMap location={location} nodes={nodes} toc={0} /> | ||
</div> | ||
</Layout> | ||
); | ||
}; | ||
|
||
export default NotFoundPage; | ||
|
||
export const Head = () => <title>404: Not Found</title>; | ||
export const Head = () => <PageHead title="404 Not Found"></PageHead>; | ||
|
||
export const pageQuery = graphql` | ||
query { | ||
site { | ||
...SiteMetadata | ||
} | ||
allMdx { | ||
nodes { | ||
id | ||
tableOfContents | ||
frontmatter { | ||
title | ||
exercise | ||
level | ||
category | ||
} | ||
internal { | ||
contentFilePath | ||
} | ||
fields { | ||
slug | ||
} | ||
} | ||
} | ||
} | ||
`; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters