Skip to content

Commit

Permalink
Improve nav tree template
Browse files Browse the repository at this point in the history
  • Loading branch information
JakeSCahill committed Apr 26, 2023
1 parent 927ec0a commit e33671a
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 13 deletions.
12 changes: 12 additions & 0 deletions src/helpers/length.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
'use-strict'

module.exports = (obj) => {
return Object.values(obj).filter((component) => {
return !(
component.latest &&
component.latest.asciidoc &&
component.latest.asciidoc.attributes &&
component.latest.asciidoc.attributes['page-exclude-from-dropdown-selector']
)
}).length
}
2 changes: 0 additions & 2 deletions src/js/09-switch-theme.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
let theme = window.localStorage.getItem('theme')

function setTheme (switchButton) {
console.log(theme)
const img = switchButton.querySelector('img:first-child')
if (theme === 'dark') {
const newSrc = img.src.replace('view-sun', 'view-moon')
Expand All @@ -24,7 +23,6 @@
}

switchButton.addEventListener('click', function () {
console.log(theme)
theme = theme === 'light' ? 'dark' : 'light'
window.localStorage.setItem('theme', theme)
setTheme(this)
Expand Down
14 changes: 8 additions & 6 deletions src/partials/form-404.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,6 @@
</form>

<script>
const form = document.getElementById('notfound');
var url = document.getElementById('url');
var date = document.getElementById('date');
url.value = window.location.href;
date.value = new Date();
const handleSubmit = (e) => {
e.preventDefault();
const formData = new FormData(e.target)
Expand All @@ -33,5 +28,12 @@ fetch("/", {
})
}
form.addEventListener('submit', handleSubmit)
document.getElementById('submit-button').click();
window.addEventListener("DOMContentLoaded", (event) => {
const form = document.getElementById('notfound');
var url = document.getElementById('url');
var date = document.getElementById('date');
url.value = window.location.href;
date.value = new Date();
document.getElementById('submit-button').click();
});
</script>
10 changes: 5 additions & 5 deletions src/partials/nav-explore.hbs
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
{{#if (and (ne page.component.name 'home') (ne page.component.name 'ROOT'))}}
<div class="nav-panel-explore{{#unless page.navigation}} is-active{{/unless}}" data-panel="explore">
{{#if page.component}}
<div class="context">
<div class="container has-dropdown">
{{#if (or (eq page.attributes.exclude-from-dropdown-selector true) (eq page.layout '404'))}}
<span class="title">Explore Docs</span>
{{else}}
<span class="title">{{page.component.title}}</span>
{{/if}}
<div class="components">
{{#each site.components}}
{{#if (and (ne this.name 'home') (ne this.name 'ROOT'))}}
{{#if (ne this.asciidoc.attributes.page-exclude-from-dropdown-selector true)}}
<span class="component
{{~#if (eq this.title @root.page.component.title)}} is-current{{/if}}">
<a href="{{{relativize ./url}}}">{{{./title}}}</a>
Expand All @@ -29,6 +31,4 @@
</div>
{{/if}}
</div>
{{/if}}
</div>
{{/if}}

0 comments on commit e33671a

Please sign in to comment.