chore: nits

This commit is contained in:
endiliey 2018-09-16 01:40:56 +08:00
parent 85f0fd69c0
commit 15a810fee5
3 changed files with 12 additions and 18 deletions

View file

@ -102,9 +102,7 @@ async function loadDocs({siteDir, docsDir, env, siteConfig}) {
}) })
); );
/* /* Get the titles of the previous and next ids so that we can use them */
Get the titles of the previous and next ids so that we can use them
*/
Object.keys(docsMetadatas).forEach(currentID => { Object.keys(docsMetadatas).forEach(currentID => {
const previousID = idx(docsMetadatas, [currentID, 'previous']); const previousID = idx(docsMetadatas, [currentID, 'previous']);
if (previousID) { if (previousID) {

View file

@ -22,16 +22,19 @@ export default class Docs extends React.Component {
{thisSidebar[categoryName].map(rawLinkID => { {thisSidebar[categoryName].map(rawLinkID => {
const linkID = (language ? `${language}-` : '') + rawLinkID; const linkID = (language ? `${language}-` : '') + rawLinkID;
const linkMetadata = docsMetadatas[linkID]; const linkMetadata = docsMetadatas[linkID];
if (!linkMetadata) {
throw new Error(
`Improper sidebars.json file, document with id '${linkID}' not found.`
);
}
const linkClassName = const linkClassName =
linkID === thisID ? 'navListItemActive' : 'navListItem'; linkID === thisID ? 'navListItemActive' : 'navListItem';
return ( return (
linkMetadata && ( <li className={linkClassName} key={linkID}>
<li className={linkClassName} key={linkID}> <Link className="navItem" to={linkMetadata.permalink}>
<Link className="navItem" to={linkMetadata.permalink}> {linkMetadata.sidebar_label || linkMetadata.title}
{linkMetadata.sidebar_label || linkMetadata.title} </Link>
</Link> </li>
</li>
)
); );
})} })}
</ul> </ul>

View file

@ -2,14 +2,7 @@ import React from 'react';
export default props => { export default props => {
if (props.error) { if (props.error) {
return ( return <div align="center">Error 🔥🔥🔥</div>;
<div>
Error!{' '}
<button type="button" onClick={props.retry}>
Retry
</button>
</div>
);
} }
if (props.pastDelay) { if (props.pastDelay) {
return <div align="center">Loading...</div>; return <div align="center">Loading...</div>;