Skip to content

Commit

Permalink
add dig helper to simplify lookup of component order on 404 page
Browse files Browse the repository at this point in the history
  • Loading branch information
mojavelinux committed Oct 5, 2023
1 parent c2bc811 commit f6e4429
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
10 changes: 10 additions & 0 deletions src/helpers/dig.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
'use strict'

module.exports = (object, path) => {
const paths = path.split('.')
let result = object
for (let i = 0, len = paths.length; i < len; i++) {
if (!(result = result[paths[i]])) break
}
return result
}
2 changes: 1 addition & 1 deletion src/layouts/404.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
</head>
<body class="status-404">
{{> header}}
{{> body componentOrder=(lookup (lookup (lookup (siteStartPage) 'asciidoc') 'attributes') 'page-component-order')}}
{{> body componentOrder=(dig (siteStartPage) 'asciidoc.attributes.page-component-order')}}
{{> footer}}
</body>
</html>

0 comments on commit f6e4429

Please sign in to comment.