-
Notifications
You must be signed in to change notification settings - Fork 351
Link directly to page if sidebar item has no subitems #855
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Link directly to page if sidebar item has no subitems #855
Conversation
Hello, @nbw! This is your first Pull Request that will be reviewed by Ebert, an automatic Code Review service. It will leave comments on this diff with potential issues and style violations found in the code as you push new commits. You can also see all the issues found on this Pull Request on its review page. Please check our documentation for more information. |
} | ||
|
||
function flatten(array) { | ||
return array.reduce(function(a, b){ return a.concat(b);}, []) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Requires a space before '}'.
} | ||
|
||
function flatten(array) { | ||
return array.reduce(function(a, b){ return a.concat(b);}, []) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Extra semicolon.
} | ||
|
||
function flatten(array) { | ||
return array.reduce(function(a, b){ return a.concat(b);}, []) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Missing space before opening brace.
} | ||
|
||
function flatten(array) { | ||
return array.reduce(function(a, b){ return a.concat(b);}, []) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Missing space before function parentheses.
} | ||
} | ||
|
||
function flatten(array) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Missing space before function parentheses.
if (flatten(nodeItems).length === 0){ | ||
return options.fn(this); | ||
} else { | ||
return options.inverse(this); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Extra semicolon.
].filter(Array.isArray); | ||
|
||
if (flatten(nodeItems).length === 0){ | ||
return options.fn(this); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Extra semicolon.
node.headers | ||
].filter(Array.isArray); | ||
|
||
if (flatten(nodeItems).length === 0){ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Missing space before opening brace.
node.macros, | ||
node.callbacks, | ||
node.headers | ||
].filter(Array.isArray); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Extra semicolon.
node.macros, | ||
node.callbacks, | ||
node.headers | ||
].filter(Array.isArray); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wouldn't a simpler implementation instead traverse this list of nodeItems and then check that they are null or an empty list? This way we don't need to flatten nor build a very large list only to check its length later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fair point @josevalim. Refactored to iterate through nodeItems and return true as soon as it detects content. Otherwise, false.
❤️ 💚 💙 💛 💜 |
Summary
For sidebar items with no subitems, link directly to the page.
Issue
Hex docs show a "Top" sub header even if there are no other contents. As an example, go to the Phoenix Hex documentation, click Guides then Installation and you'll see something like:
In order to actually view the page, you have to click Top. This feels unnecessary.
Solution
Check if there are any contents in each sidebar item, specifically for:
If there are no items link directly to the page.
Screenshots
Currently
With Top removed
Testing
Verified by generating docs for the ex_docs repo.
Note
I didn't commit any new dist/app files: