Skip to content

Commit

Permalink
Simply don't render a tocEntry if we don't yet have a translation
Browse files Browse the repository at this point in the history
  • Loading branch information
Tom Coleman committed Sep 5, 2018
1 parent e89ae99 commit 033430d
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 19 deletions.
9 changes: 0 additions & 9 deletions content/react/es/addons.md

This file was deleted.

21 changes: 11 additions & 10 deletions src/lib/tocEntries.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
export default function tocEntries(toc, pages) {
return toc.map(slug => {
const node = pages.edges.map(e => e.node).find(({ fields }) => fields.chapter === slug);
return toc
.map(slug => {
const node = pages.edges.map(e => e.node).find(({ fields }) => fields.chapter === slug);

if (!node) {
throw new Error(
`Didn't find chapter for slug:"${slug}" -- is the config's TOC in sync with the chapters?`
);
}
const { tocTitle, title, description } = node.frontmatter;
// Just don't include a sidebar link if we do not have this chapter
if (!node) {
return null;
}
const { tocTitle, title, description } = node.frontmatter;

return { slug: node.fields.slug, title: tocTitle || title, description };
});
return { slug: node.fields.slug, title: tocTitle || title, description };
})
.filter(e => !!e);
}

0 comments on commit 033430d

Please sign in to comment.