Skip to content

Commit

Permalink
Fix extra spacing on pages with no sections
Browse files Browse the repository at this point in the history
  • Loading branch information
josevalim committed Feb 4, 2023
1 parent 5331a4b commit 5350bc5
Show file tree
Hide file tree
Showing 15 changed files with 271 additions and 254 deletions.
8 changes: 8 additions & 0 deletions assets/js/handlebars/helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,14 @@ Handlebars.registerHelper('isNonEmptyArray', function (entry, options) {
}
})

Handlebars.registerHelper('isEmptyArray', function (entry, options) {
if (Array.isArray(entry) && entry.length === 0) {
return options.fn(this)
} else {
return options.inverse(this)
}
})

Handlebars.registerHelper('isLocal', function (nodeId, options) {
const pathSuffix = window.location.pathname.split('/').pop()
const nodePage = nodeId + '.html'
Expand Down
27 changes: 17 additions & 10 deletions assets/js/handlebars/templates/sidebar-items.handlebars
Original file line number Diff line number Diff line change
Expand Up @@ -16,17 +16,24 @@
{{else}}
{{{node.title}}}
{{/if}}
<span class="icon-expand"></span>
{{#isEmptyArray node.headers}}
{{else}}
<span class="icon-expand"></span>
{{/isEmptyArray}}
</a>

<ul>
{{#isArray node.headers}}
{{#each node.headers}}
<li>
<a href="{{node.id}}.html#{{{anchor}}}">{{{id}}}</a>
</li>
{{/each}}
{{else}}
{{#isArray node.headers}}
{{#isNonEmptyArray node.headers}}
<ul>
{{#each node.headers}}
<li>
<a href="{{node.id}}.html#{{{anchor}}}">{{{id}}}</a>
</li>
{{/each}}
</ul>
{{/isNonEmptyArray}}
{{else}}
<ul>
{{#showSections node}}
<li class="docs {{#isLocal node.id}}open{{/isLocal}}">
<a href="{{node.id}}.html#content" class="expand">
Expand Down Expand Up @@ -62,7 +69,7 @@
</ul>
</li>
{{/each}}
{{/isArray}}
</ul>
{{/isArray}}
</li>
{{/each}}
1 change: 1 addition & 0 deletions formatters/epub/dist/epub-elixir-3VL772VM.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 5350bc5

Please sign in to comment.