Last active
February 24, 2017 20:55
-
-
Save whichsteveyp/f78e74d3c4329bc913c3bd506d64b3e8 to your computer and use it in GitHub Desktop.
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
const API = ({ match, data }) => { | |
// this i left as is | |
const { params: { mod, header, environment } } = match; | |
const doc = data.api.find(doc => mod === doc.title.slug); | |
// don't mind the tern here as much, maybe would split the find to its own `validDocHeaderMatch` | |
const validHeader = doc && (header ? !!doc.headers.find(h => h.slug === header) : true ); | |
// this is my 😍 for conditional JSX thus far | |
return <Block> | |
{!doc && <Redirect to={`/${environment}`}/>} | |
{(doc && !validHeader) && <Redirect to={`/${enviroment}/api/${mod}`}/>} | |
{(doc && validHeader) && <MarkdownViewer html={doc.markup}/>} | |
</Block>; | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
line 12: sometimes when the values are null, this resolves to 0 and displays in the UI as 0